Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support edit set image with both tag and digest #4714

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion kustomize/commands/edit/set/setimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,16 @@ func parse(arg string) (types.Image, error) {
// parseOverwrite parses the overwrite parameters
// from the given arg into a struct
func parseOverwrite(arg string, overwriteImage bool) (overwrite, error) {
// match <image>@<digest>
// match <image[:tag]>@<digest>
if d := strings.Split(arg, "@"); len(d) > 1 {
// match <image>:<tag>@<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