mirror of https://github.com/knative/client.git
Make image flag mandatory for service create command (#60)
`service create` command always requires and specify `--image` to run. This patch changes: - Add validation check if image is empty or not. - Add image to `MarkFlagRequired()`. - to add `--image IMAGE` in help message
This commit is contained in:
parent
aa11ceab12
commit
58e478bba4
|
|
@ -33,6 +33,7 @@ func (p *ConfigurationEditFlags) AddFlags(command *cobra.Command) {
|
|||
command.Flags().StringArrayVarP(&p.Env, "env", "e", []string{},
|
||||
"Environment variable to set. NAME=value; you may provide this flag "+
|
||||
"any number of times to set multiple environment variables.")
|
||||
command.MarkFlagRequired("image")
|
||||
}
|
||||
|
||||
func (p *ConfigurationEditFlags) Apply(config *servingv1alpha1.ConfigurationSpec) error {
|
||||
|
|
|
|||
|
|
@ -29,12 +29,15 @@ func NewServiceCreateCommand(p *KnParams) *cobra.Command {
|
|||
var editFlags ConfigurationEditFlags
|
||||
|
||||
serviceCreateCommand := &cobra.Command{
|
||||
Use: "create NAME",
|
||||
Use: "create NAME --image IMAGE",
|
||||
Short: "Create a service.",
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
if len(args) != 1 {
|
||||
return errors.New("requires the service name.")
|
||||
}
|
||||
if editFlags.Image == "" {
|
||||
return errors.New("requires the image name to run.")
|
||||
}
|
||||
|
||||
namespace := cmd.Flag("namespace").Value.String()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue