Skip to content

Commit c51441d

Browse files
committed
Fix builder-bumper major version bump
Fix updating the `main` Dockerfile for major version bumps. * Add prefix handling to `majorVersionReplacer()`. Fixes: #235 Signed-off-by: SuperQ <[email protected]>
1 parent f77765f commit c51441d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmd/builder-bumper/main.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ func shaReplacer(old, new *goVersion) func(string) (string, error) {
202202
}
203203
}
204204

205-
func majorVersionReplacer(old, new *goVersion) func(string) (string, error) {
205+
func majorVersionReplacer(prefix string, old, new *goVersion) func(string) (string, error) {
206206
return func(out string) (string, error) {
207-
return strings.ReplaceAll(out, old.Major(), new.Major()), nil
207+
return strings.ReplaceAll(out, prefix+old.Major(), prefix+new.Major()), nil
208208
}
209209
}
210210

@@ -241,14 +241,15 @@ func replaceMajor(old, current, next *goVersion) error {
241241
return replace(path,
242242
[]func(string) (string, error){
243243
golangVersionReplacer("GOLANG_VERSION ", old, next),
244+
majorVersionReplacer("quay.io/prometheus/golang-builder:", old, next),
244245
shaReplacer(old, next),
245246
},
246247
)
247248
}
248249
return replace(path,
249250
[]func(string) (string, error){
250251
golangVersionReplacer("", old, next),
251-
majorVersionReplacer(old, next),
252+
majorVersionReplacer("", old, next),
252253
},
253254
)
254255
})
@@ -262,8 +263,8 @@ func replaceMajor(old, current, next *goVersion) error {
262263
// Update CircleCI.
263264
err = replace(".circleci/config.yml",
264265
[]func(string) (string, error){
265-
majorVersionReplacer(current, next),
266-
majorVersionReplacer(old, current),
266+
majorVersionReplacer("", current, next),
267+
majorVersionReplacer("", old, current),
267268
},
268269
)
269270
if err != nil {
@@ -273,8 +274,8 @@ func replaceMajor(old, current, next *goVersion) error {
273274
// Update Makefile.
274275
err = replace("Makefile",
275276
[]func(string) (string, error){
276-
majorVersionReplacer(current, next),
277-
majorVersionReplacer(old, current),
277+
majorVersionReplacer("", current, next),
278+
majorVersionReplacer("", old, current),
278279
},
279280
)
280281
if err != nil {
@@ -285,9 +286,9 @@ func replaceMajor(old, current, next *goVersion) error {
285286
return replace("README.md",
286287
[]func(string) (string, error){
287288
fullVersionReplacer(current, next),
288-
majorVersionReplacer(current, next),
289+
majorVersionReplacer("", current, next),
289290
fullVersionReplacer(old, current),
290-
majorVersionReplacer(old, current),
291+
majorVersionReplacer("", old, current),
291292
},
292293
)
293294
}

0 commit comments

Comments
 (0)