Skip to content

Commit

Permalink
switch the 'apply the registry override first in a image sync
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Martin <[email protected]>
  • Loading branch information
amartin120 committed Feb 11, 2024
1 parent 6c2b970 commit 0c55d00
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cmd/hauler/cli/store/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ func processContent(ctx context.Context, fi *os.File, o *SyncOpts, s *store.Layo
}
a := cfg.GetAnnotations()
for _, i := range cfg.Spec.Images {

// Check if the user provided a registry. If a registry is provided in the annotation, use it for the images that don't have a registry in their ref name.
if a[consts.ImageAnnotationRegistry] != "" {
newRef,_ := reference.Parse(i.Name)
if newRef.Context().RegistryStr() == "" {
newRef,_ = reference.Relocate(i.Name, a[consts.ImageAnnotationRegistry])
}
i.Name = newRef.Name()
}

// Check if the user provided a key. The flag from the CLI takes precedence over the annotation. The individual image key takes precedence over both.
if a[consts.ImageAnnotationKey] != "" || o.Key != "" || i.Key != "" {
Expand Down Expand Up @@ -175,15 +184,6 @@ func processContent(ctx context.Context, fi *os.File, o *SyncOpts, s *store.Layo
}
l.Debugf("platform for image [%s]", platform)

// Check if the user provided a registry. If a registry is provided in the annotation, use it for the images that don't have a registry in their ref name.
if a[consts.ImageAnnotationRegistry] != "" {
newRef,_ := reference.Parse(i.Name)
if newRef.Context().RegistryStr() == "" {
newRef,_ = reference.Relocate(i.Name, a[consts.ImageAnnotationRegistry])
}
i.Name = newRef.Name()
}

err = storeImage(ctx, s, i, platform)
if err != nil {
return err
Expand Down

0 comments on commit 0c55d00

Please sign in to comment.