Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 6684842

Browse files
authored
sg: ops - only replace registry if there is an existing reg (#57526)
only replace registry if there is an existing reg
1 parent 8f73d26 commit 6684842

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

dev/sg/internal/images/helm.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ func UpdateHelmManifest(ctx context.Context, registry Registry, path string, op
5555
std.Out.WriteLine(output.Styled(output.StyleWarning, fmt.Sprintf("skipping updating registry as it's public which we assume is the default, %q", err.Error())))
5656
}
5757
}
58-
valuesFileString = strings.ReplaceAll(
59-
valuesFileString,
60-
existingReg,
61-
filepath.Join(registry.Host(), registry.Org()),
62-
)
58+
59+
if existingReg != "" {
60+
valuesFileString = strings.ReplaceAll(
61+
valuesFileString,
62+
existingReg,
63+
filepath.Join(registry.Host(), registry.Org()),
64+
)
65+
}
6366

6467
// Collect all images.
6568
var imgs []string

dev/sg/sg_ops.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func opsUpdateImages(
155155
path string,
156156
registryType string,
157157
deploymentType string,
158-
pintag string,
158+
pinTag string,
159159
dockerUsername string,
160160
dockerPassword string,
161161
skipImages []string,
@@ -190,15 +190,15 @@ func opsUpdateImages(
190190
return false
191191
}
192192

193-
if pintag != "" {
194-
std.Out.WriteNoticef("pinning images to tag %q", pintag)
193+
if pinTag != "" {
194+
std.Out.WriteNoticef("pinning images to tag %q", pinTag)
195195
// We're pinning a tag.
196196
op = func(registry images.Registry, r *images.Repository) (*images.Repository, error) {
197197
if !images.IsSourcegraph(r) || shouldSkip(r) {
198198
return nil, images.ErrNoUpdateNeeded
199199
}
200200

201-
newR, err := registry.GetByTag(r.Name(), pintag)
201+
newR, err := registry.GetByTag(r.Name(), pinTag)
202202
if err != nil {
203203
return nil, err
204204
}

0 commit comments

Comments
 (0)