diff --git a/pkg/kbld/cmd/resolve.go b/pkg/kbld/cmd/resolve.go index ee134ae7..c62f5366 100644 --- a/pkg/kbld/cmd/resolve.go +++ b/pkg/kbld/cmd/resolve.go @@ -235,8 +235,6 @@ func (o *ResolveOptions) emitLockOutput(conf ctlconf.Conf, resolvedImages *Proce }) } - c.Overrides = ctlconf.UniqueImageOverrides(c.Overrides) - return c.WriteToFile(o.LockOutput) case o.ImgpkgLockOutput != "": iLock := lockconfig.ImagesLock{ diff --git a/pkg/kbld/config/config.go b/pkg/kbld/config/config.go index 1fff03ef..e935d8ee 100644 --- a/pkg/kbld/config/config.go +++ b/pkg/kbld/config/config.go @@ -6,7 +6,6 @@ package config import ( "fmt" "io/ioutil" - "reflect" semver "github.com/hashicorp/go-version" "github.com/k14s/imgpkg/pkg/imgpkg/lockconfig" @@ -324,13 +323,21 @@ func (d Config) WriteToFile(path string) error { return nil } +// Equal reports whether `this` ImageOverride is equal to `that` ImageOverride. +// (`ImageMeta` is descriptive — not identifying — so not part of equality) +func (this ImageOverride) Equal(that ImageOverride) bool { + return this.ImageRef == that.ImageRef && + this.NewImage == that.NewImage && + this.Preresolved == that.Preresolved && + this.TagSelection == that.TagSelection +} + func UniqueImageOverrides(overrides []ImageOverride) []ImageOverride { var result []ImageOverride for _, override := range overrides { var found bool for _, addedOverride := range result { - // using DeepEqual instead of '==' since ImageOverride contains a slice - if reflect.DeepEqual(addedOverride, override) { + if override.Equal(addedOverride) { found = true break }