Add --dry option to view the generated spec without saving (#1504)
This commit is contained in:
@@ -48,7 +48,7 @@ func Commands() *cobra.Command {
|
||||
flag.RunTimeMaxMemory, flag.ReplicasMin,
|
||||
flag.ReplicasMax, flag.RunTimeTargetCPU,
|
||||
|
||||
flag.NamespaceFunction, flag.NamespaceEnvironment, flag.SpecSave},
|
||||
flag.NamespaceFunction, flag.NamespaceEnvironment, flag.SpecSave, flag.SpecDry},
|
||||
})
|
||||
|
||||
getCmd := &cobra.Command{
|
||||
|
||||
@@ -301,10 +301,15 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// It also prints warning/error if necessary.
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// if we're writing a spec, don't create the function
|
||||
// save to spec file or display the spec to console
|
||||
if input.Bool(flagkey.SpecDry) {
|
||||
return spec.SpecDry(*opts.function)
|
||||
}
|
||||
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
err := spec.SpecSave(*opts.function, opts.specFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating function spec")
|
||||
return errors.Wrap(err, "error saving function spec")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user