mirror of https://github.com/docker/cli.git
Merge pull request #29955 from vieux/improve_secret_Create
remove -f on secret create and unify usage with other commands
This commit is contained in:
commit
fa1b74a77e
|
@ -27,17 +27,17 @@ func newSecretCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "create [OPTIONS] SECRET",
|
Use: "create [OPTIONS] SECRET file|-",
|
||||||
Short: "Create a secret from a file or STDIN as content",
|
Short: "Create a secret from a file or STDIN as content",
|
||||||
Args: cli.ExactArgs(1),
|
Args: cli.ExactArgs(2),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
createOpts.name = args[0]
|
createOpts.name = args[0]
|
||||||
|
createOpts.file = args[1]
|
||||||
return runSecretCreate(dockerCli, createOpts)
|
return runSecretCreate(dockerCli, createOpts)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.VarP(&createOpts.labels, "label", "l", "Secret labels")
|
flags.VarP(&createOpts.labels, "label", "l", "Secret labels")
|
||||||
flags.StringVarP(&createOpts.file, "file", "f", "", "Read from a file or STDIN ('-')")
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,6 @@ func runSecretCreate(dockerCli *command.DockerCli, options createOptions) error
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if options.file == "" {
|
|
||||||
return fmt.Errorf("Please specify either a file name or STDIN ('-') with --file")
|
|
||||||
}
|
|
||||||
|
|
||||||
var in io.Reader = dockerCli.In()
|
var in io.Reader = dockerCli.In()
|
||||||
if options.file != "-" {
|
if options.file != "-" {
|
||||||
file, err := system.OpenSequential(options.file)
|
file, err := system.OpenSequential(options.file)
|
||||||
|
|
Loading…
Reference in New Issue