improve image command messages

This commit is contained in:
Nestor
2019-01-23 07:59:58 +01:00
parent b22e43a4a7
commit e49bd3ab1d
2 changed files with 21 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ var (
errImageInvalidArgs = errors.New(`invalid format of image, use one of the following options: errImageInvalidArgs = errors.New(`invalid format of image, use one of the following options:
- <image>=<newimage>:<newtag> - <image>=<newimage>:<newtag>
- <image>=<newimage>@<newtag> - <image>=<newimage>@<newtag>
- <image>=<newimage>
- <image>:<newtag> - <image>:<newtag>
- <image>@<digest>`) - <image>@<digest>`)
) )
@@ -53,23 +54,34 @@ func newCmdSetImage(fsys fs.FileSystem) *cobra.Command {
Short: `Sets images and their new names, new tags or digests in the kustomization file`, Short: `Sets images and their new names, new tags or digests in the kustomization file`,
Example: ` Example: `
The command The command
set image postgres=my-registry/postgres:latest nginx:1.8.0 my-app=my-registry/my-app alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3 set image postgres=eu.gcr.io/my-project/postgres:latest my-app=my-registry/my-app@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add will add
image: image:
- name: postgres - name: postgres
newName: my-registry/postgres newName: eu.gcr.io/my-project/postgres
newTag: latest newTag: latest
- name: nginx - digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
newTag: 1.8.0 name: my-app
- name: my-app
newName: my-registry/my-app newName: my-registry/my-app
to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.
The command
set image node:8.15.0 mysql=mariadb alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add
image:
- name: node
newTag: 8.15.0
- name: mysql
newName: mariadb
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3 - digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
name: alpine name: alpine
to the kustomization file if it doesn't exist, to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists. and overwrite the previous ones if the image name exists.
`, `,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
err := o.Validate(args) err := o.Validate(args)

View File

@@ -41,7 +41,7 @@ func newCmdSetImageTag(fsys fs.FileSystem) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "imagetag", Use: "imagetag",
Short: "[*** DEPRECATED, use: kustomize edit set image ***] Sets images and their new tags or digests in the kustomization file", Short: "The `imagetag` command is deprecated, instead use `edit set image`.",
Example: ` Example: `
The command The command
set imagetag nginx:1.8.0 my-app:latest alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3 set imagetag nginx:1.8.0 my-app:latest alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
@@ -59,7 +59,7 @@ to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image tag exists. and overwrite the previous ones if the image tag exists.
`, `,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
log.Print("This is a deprecated command, it still works but will be removed in a further release. Use better kustomize edit set image") log.Print(cmd.Short)
err := o.Validate(args) err := o.Validate(args)
if err != nil { if err != nil {
return err return err