Skip to content

Commit

Permalink
Add kbld.carvel.dev/metas in imgpkg lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
cari-lynn committed Jul 22, 2021
1 parent 4f495a1 commit 293147e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pkg/kbld/cmd/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
ctlser "github.com/k14s/kbld/pkg/kbld/search"
"github.com/k14s/kbld/pkg/kbld/version"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
)

type ResolveOptions struct {
Expand Down Expand Up @@ -245,9 +246,16 @@ func (o *ResolveOptions) emitLockOutput(conf ctlconf.Conf, resolvedImages *Proce
},
}
for _, urlImagePair := range resolvedImages.All() {
imagesYAML, err := yaml.Marshal(urlImagePair.Image.Metas)
if err != nil {
return err
}
iLock.Images = append(iLock.Images, lockconfig.ImageRef{
Image: urlImagePair.Image.URL,
Annotations: map[string]string{ctlconf.ImagesLockKbldID: urlImagePair.UnprocessedImageURL.URL},
Image: urlImagePair.Image.URL,
Annotations: map[string]string{
ctlconf.ImagesLockKbldID: urlImagePair.UnprocessedImageURL.URL,
ctlconf.ImagesLockKbldMetas: string(imagesYAML),
},
})
}
return iLock.WriteToPath(o.ImgpkgLockOutput)
Expand Down
3 changes: 2 additions & 1 deletion pkg/kbld/config/images_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
package config

const (
ImagesLockKbldID = "kbld.carvel.dev/id"
ImagesLockKbldID = "kbld.carvel.dev/id"
ImagesLockKbldMetas = "kbld.carvel.dev/metas"
)
8 changes: 8 additions & 0 deletions test/e2e/lock_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ apiVersion: imgpkg.carvel.dev/v1alpha1
images:
- annotations:
kbld.carvel.dev/id: nginx:1.14.2
kbld.carvel.dev/metas: |
- Tag: 1.14.2
Type: resolved
URL: nginx:1.14.2
image: index.docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
- annotations:
kbld.carvel.dev/id: sample-app
kbld.carvel.dev/metas: |
- Tag: 1.15.1
Type: resolved
URL: nginx:1.15.1
image: index.docker.io/library/nginx@sha256:4a5573037f358b6cdfa2f3e8a9c33a5cf11bcd1675ca72ca76fbe5bd77d0d682
kind: ImagesLock
`
Expand Down

0 comments on commit 293147e

Please sign in to comment.