From 250bc590a95c997ceb3170ad74dadab1c2aa5670 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Mon, 20 Sep 2021 20:44:10 -0700 Subject: [PATCH] Rename "meta" to "origin" All of the information being stored in the "metas" section are information about the sourcing of each image. The term "source" however, is already used in this domain to mean a configuration from which an image is produced from sources. Origin is a softer claim than provenance; the latter of which is generally taken to mean provable. --- pkg/kbld/cmd/image.go | 24 +++++----- pkg/kbld/cmd/image_queue.go | 4 +- pkg/kbld/cmd/inspect.go | 6 +-- pkg/kbld/cmd/resolve.go | 6 +-- pkg/kbld/config/config.go | 12 ++--- .../config/{image_meta.go => image_origin.go} | 36 +++++++-------- pkg/kbld/config/images_lock.go | 4 +- pkg/kbld/image/built.go | 32 ++++++------- pkg/kbld/image/digested.go | 2 +- pkg/kbld/image/err.go | 6 ++- pkg/kbld/image/factory.go | 4 +- pkg/kbld/image/preresolved.go | 18 ++++---- pkg/kbld/image/resolved.go | 8 ++-- pkg/kbld/image/tag_selected.go | 2 +- pkg/kbld/image/tagged.go | 8 ++-- test/e2e/lock_output_test.go | 46 +++++++++---------- test/e2e/resolve_test.go | 16 +++---- 17 files changed, 118 insertions(+), 116 deletions(-) rename pkg/kbld/config/{image_meta.go => image_origin.go} (61%) diff --git a/pkg/kbld/cmd/image.go b/pkg/kbld/cmd/image.go index b1f1af89..9a199552 100644 --- a/pkg/kbld/cmd/image.go +++ b/pkg/kbld/cmd/image.go @@ -14,9 +14,9 @@ import ( type Images []Image type Image struct { - URL string - Metas []ctlconf.Meta // empty when deserialized - metasRaw []interface{} // populated when deserialized + URL string + Origins []ctlconf.Origin // empty when deserialized + originsRaw []interface{} // populated when deserialized } func (imgs Images) ForImage(url string) (Image, bool) { @@ -30,7 +30,7 @@ func (imgs Images) ForImage(url string) (Image, bool) { // TODO only works after deserialization func (i Image) Description() string { - yamlBytes, err := yaml.Marshal(i.metasRaw) + yamlBytes, err := yaml.Marshal(i.originsRaw) if err != nil { return "[]" // TODO deal better? } @@ -39,12 +39,12 @@ func (i Image) Description() string { } type imageStruct struct { - URL string `json:"url"` - Metas []interface{} `json:"metas,omitempty"` + URL string `json:"url"` + Origins []interface{} `json:"origins,omitempty"` } func (st imageStruct) equal(other imageStruct) bool { - return st.URL == other.URL && reflect.DeepEqual(st.Metas, other.Metas) + return st.URL == other.URL && reflect.DeepEqual(st.Origins, other.Origins) } func contains(structs []imageStruct, st imageStruct) bool { @@ -60,9 +60,9 @@ func newImageStructs(images []Image) []imageStruct { var result []imageStruct for _, img := range images { st := newImageStruct(img) - // if Metas is empty then the image was already in digest form and we didn't need to resolve + // if Origins is empty then the image was already in digest form and we didn't need to resolve // it, so the annotation isn't very useful - if len(st.Metas) > 0 { + if len(st.Origins) > 0 { // also check for duplicates before adding if !contains(result, st) { result = append(result, st) @@ -74,8 +74,8 @@ func newImageStructs(images []Image) []imageStruct { func newImageStruct(image Image) imageStruct { result := imageStruct{URL: image.URL} - for _, meta := range image.Metas { - result.Metas = append(result.Metas, meta) + for _, origin := range image.Origins { + result.Origins = append(result.Origins, origin) } return result } @@ -83,7 +83,7 @@ func newImageStruct(image Image) imageStruct { func newImages(structs []imageStruct) []Image { var result []Image for _, st := range structs { - result = append(result, Image{URL: st.URL, metasRaw: st.Metas}) + result = append(result, Image{URL: st.URL, originsRaw: st.Origins}) } return result } diff --git a/pkg/kbld/cmd/image_queue.go b/pkg/kbld/cmd/image_queue.go index 42687504..c7557fc3 100644 --- a/pkg/kbld/cmd/image_queue.go +++ b/pkg/kbld/cmd/image_queue.go @@ -55,7 +55,7 @@ func (b *ImageQueue) worker(workWg *sync.WaitGroup, queueCh <-chan UnprocessedIm func (b *ImageQueue) work(workWg *sync.WaitGroup, unprocessedImageURL UnprocessedImageURL) { defer workWg.Done() - imgURL, metas, err := b.imgFactory.New(unprocessedImageURL.URL).URL() + imgURL, origins, err := b.imgFactory.New(unprocessedImageURL.URL).URL() if err != nil { b.outputErrsLock.Lock() b.outputErrs = append(b.outputErrs, fmt.Errorf("Resolving image '%s': %s", unprocessedImageURL.URL, err)) @@ -64,6 +64,6 @@ func (b *ImageQueue) work(workWg *sync.WaitGroup, unprocessedImageURL Unprocesse } b.outputImagesLock.Lock() - b.outputImages.Add(unprocessedImageURL, Image{URL: imgURL, Metas: metas}) + b.outputImages.Add(unprocessedImageURL, Image{URL: imgURL, Origins: origins}) b.outputImagesLock.Unlock() } diff --git a/pkg/kbld/cmd/inspect.go b/pkg/kbld/cmd/inspect.go index 51b91123..fe6ff81f 100644 --- a/pkg/kbld/cmd/inspect.go +++ b/pkg/kbld/cmd/inspect.go @@ -67,14 +67,14 @@ func (o *InspectOptions) Run() error { } for _, resWithImg := range foundImages { - metasDesc, err := resWithImg.MetasDescription() + originsDesc, err := resWithImg.OriginsDescription() if err != nil { return err } table.Rows = append(table.Rows, []uitable.Value{ uitable.NewValueString(resWithImg.URL), - uitable.NewValueString(metasDesc), + uitable.NewValueString(originsDesc), uitable.NewValueString(resWithImg.Resource.Description()), }) } @@ -106,7 +106,7 @@ type foundResourceWithImage struct { Resource ctlres.Resource } -func (s foundResourceWithImage) MetasDescription() (string, error) { +func (s foundResourceWithImage) OriginsDescription() (string, error) { images, err := NewResourceWithImages(s.Resource.DeepCopyRaw(), nil).Images() if err != nil { return "", err diff --git a/pkg/kbld/cmd/resolve.go b/pkg/kbld/cmd/resolve.go index 7567cbe1..e55f0802 100644 --- a/pkg/kbld/cmd/resolve.go +++ b/pkg/kbld/cmd/resolve.go @@ -262,12 +262,12 @@ func (o *ResolveOptions) imgpkgLockAnnotations(i ProcessedImageItem) map[string] anns := map[string]string{ ctlconf.ImagesLockKbldID: i.UnprocessedImageURL.URL, } - if len(i.Metas) > 0 { - bs, err := yaml.Marshal(i.Metas) + if len(i.Origins) > 0 { + bs, err := yaml.Marshal(i.Origins) if err != nil { return anns } - anns[ctlconf.ImagesLockKbldMetas] = string(bs) + anns[ctlconf.ImagesLockKbldOrigins] = string(bs) } return anns diff --git a/pkg/kbld/config/config.go b/pkg/kbld/config/config.go index fefa7bca..029b2eef 100644 --- a/pkg/kbld/config/config.go +++ b/pkg/kbld/config/config.go @@ -68,7 +68,7 @@ type ImageOverride struct { NewImage string `json:"newImage"` Preresolved bool `json:"preresolved,omitempty"` TagSelection *versions.VersionSelection `json:"tagSelection,omitempty"` - ImageMetas []Meta `json:"metas,omitempty"` + ImageOrigins []Origin `json:"origins,omitempty"` } type ImageDestination struct { @@ -169,17 +169,17 @@ func NewConfigFromImagesLock(res ctlres.Resource) (Config, error) { overridesConfig := NewConfig() for _, image := range imagesLock.Images { - imgMeta, err := NewMetasFromString(image.Annotations[ImagesLockKbldMetas]) + imgOrigins, err := NewOriginsFromString(image.Annotations[ImagesLockKbldOrigins]) if err != nil { - return Config{}, fmt.Errorf("Unmarshaling %s as %s annotation: %s", res.Description(), ImagesLockKbldMetas, err) + return Config{}, fmt.Errorf("Unmarshaling %s as %s annotation: %s", res.Description(), ImagesLockKbldOrigins, err) } iOverride := ImageOverride{ ImageRef: ImageRef{ Image: image.Annotations[ImagesLockKbldID], }, - NewImage: image.Image, - Preresolved: true, - ImageMetas: imgMeta, + NewImage: image.Image, + Preresolved: true, + ImageOrigins: imgOrigins, } overridesConfig.Overrides = append(overridesConfig.Overrides, iOverride) } diff --git a/pkg/kbld/config/image_meta.go b/pkg/kbld/config/image_origin.go similarity index 61% rename from pkg/kbld/config/image_meta.go rename to pkg/kbld/config/image_origin.go index 16f9a57d..2774a056 100644 --- a/pkg/kbld/config/image_meta.go +++ b/pkg/kbld/config/image_origin.go @@ -7,44 +7,44 @@ import ( "sigs.k8s.io/yaml" ) -type Meta struct { - Git *MetaGit `json:"git,omitempty"` - Local *MetaLocal `json:"local,omitempty"` - Resolved *MetaResolved `json:"resolved,omitempty"` - Tagged *MetaTagged `json:"tagged,omitempty"` - Preresolved *MetaPreresolved `json:"preresolved,omitempty"` +type Origin struct { + Git *OriginGit `json:"git,omitempty"` + Local *OriginLocal `json:"local,omitempty"` + Resolved *OriginResolved `json:"resolved,omitempty"` + Tagged *OriginTagged `json:"tagged,omitempty"` + Preresolved *OriginPreresolved `json:"preresolved,omitempty"` } -type MetaGit struct { +type OriginGit struct { RemoteURL string `json:"remoteURL"` SHA string `json:"sha"` Dirty bool `json:"dirty"` Tags []string `json:"tags,omitempty"` } -type MetaLocal struct { +type OriginLocal struct { Path string `json:"path"` } -type MetaResolved struct { +type OriginResolved struct { URL string `json:"url"` Tag string `json:"tag,omitempty"` } -type MetaTagged struct { +type OriginTagged struct { Tags []string `json:"tags"` } -type MetaPreresolved struct { +type OriginPreresolved struct { URL string `json:"url"` Tag string `json:"tag,omitempty"` } -func NewMetasFromString(str string) ([]Meta, error) { - var metas []Meta +func NewOriginsFromString(str string) ([]Origin, error) { + var origins []Origin - // Ignores unknown types of meta. At this time... - // - "Meta" are provided as primarily optional diagnostic information + // Ignores unknown types of origin. At this time... + // - "Origin" are provided as primarily optional diagnostic information // rather than operational data (read: less important). Losing // this information does not change the correctness of kbld's // primary purpose during deployment: to rewrite image references. @@ -56,10 +56,10 @@ func NewMetasFromString(str string) ([]Meta, error) { // of warnings. So, the feature would quickly need an enhancement // to de-dup such warnings. (read: added complexity) // see also https://github.com/vmware-tanzu/carvel-kbld/issues/160 - err := yaml.Unmarshal([]byte(str), &metas) + err := yaml.Unmarshal([]byte(str), &origins) if err != nil { - return []Meta{}, err + return []Origin{}, err } - return metas, nil + return origins, nil } diff --git a/pkg/kbld/config/images_lock.go b/pkg/kbld/config/images_lock.go index 61532b65..8defb4a4 100644 --- a/pkg/kbld/config/images_lock.go +++ b/pkg/kbld/config/images_lock.go @@ -4,6 +4,6 @@ package config const ( - ImagesLockKbldID = "kbld.carvel.dev/id" - ImagesLockKbldMetas = "kbld.carvel.dev/metas" + ImagesLockKbldID = "kbld.carvel.dev/id" + ImagesLockKbldOrigins = "kbld.carvel.dev/origins" ) diff --git a/pkg/kbld/image/built.go b/pkg/kbld/image/built.go index 5fe257f0..573aec5e 100644 --- a/pkg/kbld/image/built.go +++ b/pkg/kbld/image/built.go @@ -32,8 +32,8 @@ func NewBuiltImage(url string, buildSource ctlconf.Source, imgDst *ctlconf.Image return BuiltImage{url, buildSource, imgDst, docker, pack, kubectlBuildkit, ko, bazel} } -func (i BuiltImage) URL() (string, []ctlconf.Meta, error) { - metas, err := i.sources() +func (i BuiltImage) URL() (string, []ctlconf.Origin, error) { + origins, err := i.sources() if err != nil { return "", nil, err } @@ -54,12 +54,12 @@ func (i BuiltImage) URL() (string, []ctlconf.Meta, error) { return "", nil, err } - return i.optionalPushWithDocker(dockerTmpRef, metas) + return i.optionalPushWithDocker(dockerTmpRef, origins) case i.buildSource.KubectlBuildkit != nil: url, err := i.kubectlBuildkit.BuildAndPush( urlRepo, i.buildSource.Path, i.imgDst, *i.buildSource.KubectlBuildkit) - return url, metas, err + return url, origins, err case i.buildSource.Ko != nil: dockerTmpRef, err := i.ko.Build(urlRepo, i.buildSource.Path, i.buildSource.Ko.Build) @@ -67,7 +67,7 @@ func (i BuiltImage) URL() (string, []ctlconf.Meta, error) { return "", nil, err } - return i.optionalPushWithDocker(dockerTmpRef, metas) + return i.optionalPushWithDocker(dockerTmpRef, origins) case i.buildSource.Bazel != nil: dockerTmpRef, err := i.bazel.Run(urlRepo, i.buildSource.Path, i.buildSource.Bazel.Run) @@ -75,7 +75,7 @@ func (i BuiltImage) URL() (string, []ctlconf.Meta, error) { return "", nil, err } - return i.optionalPushWithDocker(dockerTmpRef, metas) + return i.optionalPushWithDocker(dockerTmpRef, origins) default: if i.buildSource.Docker == nil { @@ -96,37 +96,37 @@ func (i BuiltImage) URL() (string, []ctlconf.Meta, error) { return "", nil, err } - return i.optionalPushWithDocker(dockerTmpRef, metas) + return i.optionalPushWithDocker(dockerTmpRef, origins) } } -func (i BuiltImage) optionalPushWithDocker(dockerTmpRef ctlbdk.DockerTmpRef, metas []ctlconf.Meta) (string, []ctlconf.Meta, error) { +func (i BuiltImage) optionalPushWithDocker(dockerTmpRef ctlbdk.DockerTmpRef, origins []ctlconf.Origin) (string, []ctlconf.Origin, error) { if i.imgDst != nil { digest, err := i.docker.Push(dockerTmpRef, i.imgDst.NewImage) if err != nil { return "", nil, err } - url, metas2, err := NewDigestedImageFromParts(i.imgDst.NewImage, digest.AsString()).URL() + url, moreOrigins, err := NewDigestedImageFromParts(i.imgDst.NewImage, digest.AsString()).URL() if err != nil { return "", nil, err } - return url, append(metas, metas2...), nil + return url, append(origins, moreOrigins...), nil } - return dockerTmpRef.AsString(), metas, nil + return dockerTmpRef.AsString(), origins, nil } -func (i BuiltImage) sources() ([]ctlconf.Meta, error) { - var sources []ctlconf.Meta +func (i BuiltImage) sources() ([]ctlconf.Origin, error) { + var sources []ctlconf.Origin absPath, err := filepath.Abs(i.buildSource.Path) if err != nil { return nil, err } - sources = append(sources, ctlconf.Meta{Local: &ctlconf.MetaLocal{Path: absPath}}) + sources = append(sources, ctlconf.Origin{Local: &ctlconf.OriginLocal{Path: absPath}}) gitRepo := NewGitRepo(absPath) @@ -138,7 +138,7 @@ func (i BuiltImage) sources() ([]ctlconf.Meta, error) { return nil, err } - git := ctlconf.MetaGit{SHA: sha} + git := ctlconf.OriginGit{SHA: sha} git.RemoteURL, err = gitRepo.RemoteURL() if err != nil { @@ -155,7 +155,7 @@ func (i BuiltImage) sources() ([]ctlconf.Meta, error) { return nil, err } - sources = append(sources, ctlconf.Meta{Git: &git}) + sources = append(sources, ctlconf.Origin{Git: &git}) } return sources, nil diff --git a/pkg/kbld/image/digested.go b/pkg/kbld/image/digested.go index 18351aa1..55eb67e9 100644 --- a/pkg/kbld/image/digested.go +++ b/pkg/kbld/image/digested.go @@ -41,7 +41,7 @@ func NewDigestedImageFromParts(url, digest string) DigestedImage { return DigestedImage{nameWithDigest, nil} } -func (i DigestedImage) URL() (string, []ctlconf.Meta, error) { +func (i DigestedImage) URL() (string, []ctlconf.Origin, error) { if i.parseErr != nil { return "", nil, i.parseErr } diff --git a/pkg/kbld/image/err.go b/pkg/kbld/image/err.go index 2b34611f..f9c7b9a4 100644 --- a/pkg/kbld/image/err.go +++ b/pkg/kbld/image/err.go @@ -3,7 +3,9 @@ package image -import ctlconf "github.com/k14s/kbld/pkg/kbld/config" +import ( + ctlconf "github.com/k14s/kbld/pkg/kbld/config" +) type ErrImage struct { err error @@ -13,4 +15,4 @@ var _ Image = ErrImage{} func NewErrImage(err error) ErrImage { return ErrImage{err} } -func (i ErrImage) URL() (string, []ctlconf.Meta, error) { return "", nil, i.err } +func (i ErrImage) URL() (string, []ctlconf.Origin, error) { return "", nil, i.err } diff --git a/pkg/kbld/image/factory.go b/pkg/kbld/image/factory.go index 5cb230ac..7cf991b1 100644 --- a/pkg/kbld/image/factory.go +++ b/pkg/kbld/image/factory.go @@ -17,7 +17,7 @@ import ( ) type Image interface { - URL() (string, []ctlconf.Meta, error) + URL() (string, []ctlconf.Origin, error) } type Factory struct { @@ -39,7 +39,7 @@ func (f Factory) New(url string) Image { if overrideConf, found := f.shouldOverride(url); found { url = overrideConf.NewImage if overrideConf.Preresolved { - return NewPreresolvedImage(url, overrideConf.ImageMetas) + return NewPreresolvedImage(url, overrideConf.ImageOrigins) } else if overrideConf.TagSelection != nil { return NewTagSelectedImage(url, overrideConf.TagSelection, f.registry) } diff --git a/pkg/kbld/image/preresolved.go b/pkg/kbld/image/preresolved.go index b9022a72..154c3ed5 100644 --- a/pkg/kbld/image/preresolved.go +++ b/pkg/kbld/image/preresolved.go @@ -8,21 +8,21 @@ import ( ) type PreresolvedImage struct { - url string - metas []ctlconf.Meta + url string + origins []ctlconf.Origin } -func NewPreresolvedImage(url string, metas []ctlconf.Meta) PreresolvedImage { - return PreresolvedImage{url, copyAndAppendMeta(metas)} +func NewPreresolvedImage(url string, origins []ctlconf.Origin) PreresolvedImage { + return PreresolvedImage{url, copyAndAppendOrigins(origins)} } -func (i PreresolvedImage) URL() (string, []ctlconf.Meta, error) { - imageMetas := copyAndAppendMeta(i.metas, ctlconf.Meta{Preresolved: &ctlconf.MetaPreresolved{URL: i.url}}) - return i.url, imageMetas, nil +func (i PreresolvedImage) URL() (string, []ctlconf.Origin, error) { + imageOrigins := copyAndAppendOrigins(i.origins, ctlconf.Origin{Preresolved: &ctlconf.OriginPreresolved{URL: i.url}}) + return i.url, imageOrigins, nil } -func copyAndAppendMeta(existing []ctlconf.Meta, new ...ctlconf.Meta) []ctlconf.Meta { - all := make([]ctlconf.Meta, len(existing), len(existing)+len(new)) +func copyAndAppendOrigins(existing []ctlconf.Origin, new ...ctlconf.Origin) []ctlconf.Origin { + all := make([]ctlconf.Origin, len(existing), len(existing)+len(new)) copy(all, existing) return append(all, new...) } diff --git a/pkg/kbld/image/resolved.go b/pkg/kbld/image/resolved.go index 073e29e2..600d30fa 100644 --- a/pkg/kbld/image/resolved.go +++ b/pkg/kbld/image/resolved.go @@ -21,7 +21,7 @@ func NewResolvedImage(url string, registry ctlreg.Registry) ResolvedImage { return ResolvedImage{url, registry} } -func (i ResolvedImage) URL() (string, []ctlconf.Meta, error) { +func (i ResolvedImage) URL() (string, []ctlconf.Origin, error) { tag, err := regname.NewTag(i.url, regname.WeakValidation) if err != nil { return "", nil, err @@ -44,12 +44,12 @@ func (i ResolvedImage) URL() (string, []ctlconf.Meta, error) { return "", nil, fmt.Errorf("Expected digest resolution to be consistent over two separate requests") } - url, metas, err := NewDigestedImageFromParts(tag.Repository.String(), imgDescriptor.Digest.String()).URL() + url, origins, err := NewDigestedImageFromParts(tag.Repository.String(), imgDescriptor.Digest.String()).URL() if err != nil { return "", nil, err } - metas = append(metas, ctlconf.Meta{Resolved: &ctlconf.MetaResolved{URL: i.url, Tag: tag.TagStr()}}) + origins = append(origins, ctlconf.Origin{Resolved: &ctlconf.OriginResolved{URL: i.url, Tag: tag.TagStr()}}) - return url, metas, nil + return url, origins, nil } diff --git a/pkg/kbld/image/tag_selected.go b/pkg/kbld/image/tag_selected.go index 0842c5bf..5a87dd83 100644 --- a/pkg/kbld/image/tag_selected.go +++ b/pkg/kbld/image/tag_selected.go @@ -25,7 +25,7 @@ func NewTagSelectedImage(url string, selection *versions.VersionSelection, return TagSelectedImage{url, selection, registry} } -func (i TagSelectedImage) URL() (string, []ctlconf.Meta, error) { +func (i TagSelectedImage) URL() (string, []ctlconf.Origin, error) { repo, err := regname.NewRepository(i.url, regname.WeakValidation) if err != nil { return "", nil, err diff --git a/pkg/kbld/image/tagged.go b/pkg/kbld/image/tagged.go index 7325fc29..df2e1fc6 100644 --- a/pkg/kbld/image/tagged.go +++ b/pkg/kbld/image/tagged.go @@ -20,8 +20,8 @@ func NewTaggedImage(image Image, imgDst ctlconf.ImageDestination, registry ctlre return TaggedImage{image, imgDst, registry} } -func (i TaggedImage) URL() (string, []ctlconf.Meta, error) { - url, metas, err := i.image.URL() +func (i TaggedImage) URL() (string, []ctlconf.Origin, error) { + url, origins, err := i.image.URL() if err != nil { return "", nil, err } @@ -46,8 +46,8 @@ func (i TaggedImage) URL() (string, []ctlconf.Meta, error) { } } - metas = append(metas, ctlconf.Meta{Tagged: &ctlconf.MetaTagged{Tags: i.imgDst.Tags}}) + origins = append(origins, ctlconf.Origin{Tagged: &ctlconf.OriginTagged{Tags: i.imgDst.Tags}}) } - return url, metas, err + return url, origins, err } diff --git a/test/e2e/lock_output_test.go b/test/e2e/lock_output_test.go index 50995052..4809beca 100644 --- a/test/e2e/lock_output_test.go +++ b/test/e2e/lock_output_test.go @@ -11,31 +11,31 @@ import ( ) var ( - imgLockWithResolvedMetas = `--- + imgLockWithResolvedOrigins = `--- apiVersion: imgpkg.carvel.dev/v1alpha1 images: - annotations: kbld.carvel.dev/id: nginx:1.14.2 - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - resolved: tag: 1.14.2 url: nginx:1.14.2 image: index.docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d - annotations: kbld.carvel.dev/id: sample-app - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - resolved: tag: 1.15.1 url: nginx:1.15.1 image: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 kind: ImagesLock ` - imgLockWithBuiltMetas = `--- + imgLockWithBuiltOrigins = `--- apiVersion: imgpkg.carvel.dev/v1alpha1 images: - annotations: kbld.carvel.dev/id: nginx:1.14.2 - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - local: path: path/to/source - git: @@ -45,7 +45,7 @@ images: image: index.docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d - annotations: kbld.carvel.dev/id: sample-app - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - local: path: path/to/source - git: @@ -55,12 +55,12 @@ images: image: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 kind: ImagesLock ` - imgLockWithBuiltAndPreresolvedMetas = `--- + imgLockWithBuiltAndPreresolvedOrigins = `--- apiVersion: imgpkg.carvel.dev/v1alpha1 images: - annotations: kbld.carvel.dev/id: nginx:1.14.2 - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - local: path: path/to/source - git: @@ -72,7 +72,7 @@ images: image: index.docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d - annotations: kbld.carvel.dev/id: sample-app - kbld.carvel.dev/metas: | + kbld.carvel.dev/origins: | - local: path: path/to/source - git: @@ -237,8 +237,8 @@ images: t.Fatalf("Failed while reading " + path) } - if string(bs) != imgLockWithResolvedMetas { - t.Fatalf("Expected >>>%s<<< to match >>>%s<<<", bs, imgLockWithResolvedMetas) + if string(bs) != imgLockWithResolvedOrigins { + t.Fatalf("Expected >>>%s<<< to match >>>%s<<<", bs, imgLockWithResolvedOrigins) } } @@ -266,7 +266,7 @@ images: - image: nginx:1.14.2 - image: sample-app --- -` + imgLockWithResolvedMetas +` + imgLockWithResolvedOrigins out, _ := kbld.RunWithOpts([]string{"-f", "-"}, RunOpts{ StdinReader: strings.NewReader(input), @@ -279,14 +279,14 @@ images: metadata: annotations: kbld.k14s.io/images: | - - metas: + - origins: - resolved: tag: 1.15.1 url: nginx:1.15.1 - preresolved: url: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 url: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 - - metas: + - origins: - resolved: tag: 1.14.2 url: nginx:1.14.2 @@ -299,7 +299,7 @@ metadata: } } -func TestImgpkgLockFileMetasSuccessful(t *testing.T) { +func TestImgpkgLockFileOriginsSuccessful(t *testing.T) { env := BuildEnv(t) kbld := Kbld{t, env.Namespace, env.KbldBinaryPath, Logger{}} @@ -308,9 +308,9 @@ images: - image: nginx:1.14.2 - image: sample-app --- -` + imgLockWithBuiltMetas +` + imgLockWithBuiltOrigins - path := "/tmp/kbld-test-lock-metas" + path := "/tmp/kbld-test-lock-origins" defer os.RemoveAll(path) out, _ := kbld.RunWithOpts([]string{"-f", "-", "--imgpkg-lock-output=" + path}, RunOpts{ StdinReader: strings.NewReader(input), @@ -323,7 +323,7 @@ images: metadata: annotations: kbld.k14s.io/images: | - - metas: + - origins: - local: path: path/to/source - git: @@ -333,7 +333,7 @@ metadata: - preresolved: url: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 url: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682 - - metas: + - origins: - local: path: path/to/source - git: @@ -353,12 +353,12 @@ metadata: t.Fatalf("Failed while reading " + path) } - if string(bs) != imgLockWithBuiltAndPreresolvedMetas { - t.Fatalf("Expected >>>%s<<< to match >>>%s<<<", bs, imgLockWithBuiltAndPreresolvedMetas) + if string(bs) != imgLockWithBuiltAndPreresolvedOrigins { + t.Fatalf("Expected >>>%s<<< to match >>>%s<<<", bs, imgLockWithBuiltAndPreresolvedOrigins) } } -func TestImgpkgLockOutputSuccessfulDigestedImageHasNoMetas(t *testing.T) { +func TestImgpkgLockOutputSuccessfulDigestedImageHasNoOrigins(t *testing.T) { env := BuildEnv(t) kbld := Kbld{t, env.Namespace, env.KbldBinaryPath, Logger{}} @@ -389,7 +389,7 @@ images: t.Fatalf("Failed while reading " + path) } - // For Digest references, Image Lock should not have metas since there is no image metadata + // For Digest references, Image Lock should not have origins since there is no image metadata if string(bs) != imgLock { t.Fatalf("Expected >>>%s<<< to match >>>%s<<<", bs, imgLock) } diff --git a/test/e2e/resolve_test.go b/test/e2e/resolve_test.go index 91aaab2b..cb1bdea0 100644 --- a/test/e2e/resolve_test.go +++ b/test/e2e/resolve_test.go @@ -49,7 +49,7 @@ func TestResolveSuccessfulWithAnnotations(t *testing.T) { // The repetition in this input is so it can test for: // 1) resolving - // 2) filtering annotations with null metas (which happens with digests, which don't get resolved) + // 2) filtering annotations with null origins (which happens with digests, which don't get resolved) // 3) de-duplicating annotations input := ` kind: Object @@ -69,12 +69,12 @@ kind: Object metadata: annotations: kbld.k14s.io/images: | - - metas: + - origins: - resolved: tag: 1.14.2 url: nginx:1.14.2 url: index.docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d - - metas: + - origins: - resolved: tag: 1.14.2 url: library/nginx:1.14.2 @@ -125,15 +125,15 @@ kind: Object metadata: annotations: kbld.k14s.io/images: | - - metas: + - origins: - preresolved: url: aaa url: aaa - - metas: + - origins: - preresolved: url: bbb url: bbb - - metas: + - origins: - preresolved: url: ccc url: ccc @@ -491,12 +491,12 @@ kind: Object metadata: annotations: kbld.k14s.io/images: | - - metas: + - origins: - resolved: tag: 1.14.1 url: index.docker.io/library/nginx:1.14.1 url: index.docker.io/library/nginx@sha256:32fdf92b4e986e109e4db0865758020cb0c3b70d6ba80d02fe87bad5cc3dc228 - - metas: + - origins: - resolved: tag: 1.14.2 url: index.docker.io/library/nginx:1.14.2