diff --git a/pkg/commands/edit/set/setimage.go b/pkg/commands/edit/set/setimage.go index 347166fa9..a5d7aec44 100644 --- a/pkg/commands/edit/set/setimage.go +++ b/pkg/commands/edit/set/setimage.go @@ -160,7 +160,7 @@ func parse(arg string) (image.Image, error) { // matches if there is an image name to overwrite // =<:|@> if s := strings.Split(arg, separator); len(s) == 2 { - p, err := parseOverwrite(s[1]) + p, err := parseOverwrite(s[1], true) return image.Image{ Name: s[0], NewName: p.name, @@ -171,7 +171,7 @@ func parse(arg string) (image.Image, error) { // matches only for overwrites // <:|@> - p, err := parseOverwrite(arg) + p, err := parseOverwrite(arg, false) return image.Image{ Name: p.name, NewTag: p.tag, @@ -181,7 +181,7 @@ func parse(arg string) (image.Image, error) { // parseOverwrite parses the overwrite parameters // from the given arg into a struct -func parseOverwrite(arg string) (overwrite, error) { +func parseOverwrite(arg string, overwriteImage bool) (overwrite, error) { // match @ if d := strings.Split(arg, "@"); len(d) > 1 { return overwrite{ @@ -197,5 +197,12 @@ func parseOverwrite(arg string) (overwrite, error) { tag: t[2], }, nil } + + // match + if len(arg) > 0 && overwriteImage { + return overwrite{ + name: arg, + }, nil + } return overwrite{}, errImageInvalidArgs } diff --git a/pkg/commands/edit/set/setimage_test.go b/pkg/commands/edit/set/setimage_test.go index e851d4f56..a48accf3b 100644 --- a/pkg/commands/edit/set/setimage_test.go +++ b/pkg/commands/edit/set/setimage_test.go @@ -84,6 +84,18 @@ func TestSetImage(t *testing.T) { " name: image1", }}, }, + { + description: "=", + given: given{ + args: []string{"ngnix=localhost:5000/my-project/ngnix"}, + }, + expected: expected{ + fileOutput: []string{ + "images:", + "- name: ngnix", + " newName: localhost:5000/my-project/ngnix", + }}, + }, { given: given{ args: []string{"ngnix=localhost:5000/my-project/ngnix:dev-01"},