Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support edit set image with both tag and digest
  • Loading branch information
mgsh committed Jul 16, 2022
1 parent 2f2ba40 commit 5502cc5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kustomize/commands/edit/set/setimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ func parse(arg string) (types.Image, error) {
func parseOverwrite(arg string, overwriteImage bool) (overwrite, error) {
// match <image>@<digest>
if d := strings.Split(arg, "@"); len(d) > 1 {
// to support images with tag and digest
if t := strings.Split(d[0], ":"); len(t) > 1 {
return overwrite{
name: t[0],
tag: t[1],
digest: d[1],
}, nil
}
return overwrite{
name: d[0],
digest: d[1],
Expand Down
13 changes: 13 additions & 0 deletions kustomize/commands/edit/set/setimage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ func TestSetImage(t *testing.T) {
" name: image1",
}},
},
{
description: "image with tag and digest",
given: given{
args: []string{"org/image1:tag@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3"},
},
expected: expected{
fileOutput: []string{
"images:",
"- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3",
" name: org/image1",
" newTag: tag",
}},
},
{
description: "<image>=<image>",
given: given{
Expand Down

0 comments on commit 5502cc5

Please sign in to comment.