diff --git a/kustomize/commands/edit/set/setimage.go b/kustomize/commands/edit/set/setimage.go index e68d7b1912..daae1578c5 100644 --- a/kustomize/commands/edit/set/setimage.go +++ b/kustomize/commands/edit/set/setimage.go @@ -231,6 +231,14 @@ func parse(arg string) (types.Image, error) { func parseOverwrite(arg string, overwriteImage bool) (overwrite, error) { // match @ 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], diff --git a/kustomize/commands/edit/set/setimage_test.go b/kustomize/commands/edit/set/setimage_test.go index 9dce4e45de..44c99ce55d 100644 --- a/kustomize/commands/edit/set/setimage_test.go +++ b/kustomize/commands/edit/set/setimage_test.go @@ -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: "=", given: given{