diff --git a/pkg/bundle/create/create.go b/pkg/bundle/create/create.go index 169bad7e4..19cb33d6e 100644 --- a/pkg/bundle/create/create.go +++ b/pkg/bundle/create/create.go @@ -65,6 +65,7 @@ func (o *Options) RunFull(ctx context.Context, flags *pflag.FlagSet) error { if len(cfg.Mirror.Operators) != 0 { opts := operator.NewMirrorOptions(*o.RootOptions) + opts.SkipImagePin = o.SkipImagePin assocs, err := opts.Full(ctx, cfg) if err != nil { return meta, run, err diff --git a/pkg/operator/mirror.go b/pkg/operator/mirror.go index d1d8ded81..085aae50e 100644 --- a/pkg/operator/mirror.go +++ b/pkg/operator/mirror.go @@ -323,7 +323,13 @@ func pinImages(ctx context.Context, dc *declcfg.DeclarativeConfig, resolverConfi var errs []error for i, b := range dc.Bundles { + if !isImagePinned(b.Image) { + + if !isImageTagged(b.Image) { + logrus.Warnf("bundle %s: bundle image tag not set", b.Name) + continue + } if dc.Bundles[i].Image, err = image.ResolveToPin(ctx, resolver, b.Image); err != nil { errs = append(errs, err) continue @@ -331,6 +337,12 @@ func pinImages(ctx context.Context, dc *declcfg.DeclarativeConfig, resolverConfi } for j, ri := range b.RelatedImages { if !isImagePinned(ri.Image) { + + if !isImageTagged(ri.Image) { + logrus.Warnf("bundle %s: related image tag not set", b.Name) + continue + } + if b.RelatedImages[j].Image, err = image.ResolveToPin(ctx, resolver, ri.Image); err != nil { errs = append(errs, err) continue @@ -347,6 +359,11 @@ func isImagePinned(img string) bool { return strings.Contains(img, "@") } +// isImageTagged returns true if img has a tag. +func isImageTagged(img string) bool { + return strings.Contains(img, ":") +} + func (o *MirrorOptions) writeDC(dc *declcfg.DeclarativeConfig, ctlgRef imgreference.DockerImageReference) (string, error) { // Write catalog declarative config file to src so it is included in the archive