Skip to content

Commit

Permalink
fix(create): Bug/issue 106 (#107)
Browse files Browse the repository at this point in the history
* fix: skipped operator images with no tag specified*
  • Loading branch information
jpower432 authored Oct 5, 2021
1 parent 75c2ff9 commit df490dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/bundle/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions pkg/operator/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,26 @@ 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
}
}
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
Expand All @@ -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
Expand Down

0 comments on commit df490dd

Please sign in to comment.