File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 66# you may not use this file except in compliance with the License.
77# You may obtain a copy of the License at
88#
9- # https://www.apache.org/licenses/LICENSE-2.0
9+ # https://www.apache.org/licenses/LICENSE-2.0
1010#
1111# Unless required by applicable law or agreed to in writing, software
1212# distributed under the License is distributed on an "AS IS" BASIS,
2626TARGET_DIR=" $1 "
2727NEW_VERSION=" $2 "
2828
29- # Define the pattern to search for and the new suffix
30- PATTERN=" github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/"
29+ PREFIX=" github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/"
3130NEW_SUFFIX=" ?ref=$NEW_VERSION "
3231
3332# Set locale to C to avoid character encoding issues with sed
3433export LC_CTYPE=C
3534
3635# Find and replace strings in .tf files, excluding .terraform directories
3736find " $TARGET_DIR " -type f -name " *.tf" -not -path " */.terraform/*" -print0 | while IFS= read -r -d $' \0' file; do
38- # Corrected sed command
39- # Replaces the entire '?ref=v...' with the new suffix.
40- # The backslashes `\\` before the first `?` are removed because it's no longer a capture group.
41- sed -i " s|${PATTERN} [^\" [:space:]]*\\ ?ref=v[0-9.]*\" |&${NEW_SUFFIX} \" |g" " $file "
37+ sed -i " s|\\ (\" $PREFIX [^\" ?[:space:]]*\\ )?ref=v[0-9.]*\" |\\ 1$NEW_SUFFIX \" |g" " $file "
4238done
4339
4440# Unset the locale variable
You can’t perform that action at this time.
0 commit comments