Add --dry option to view the generated spec without saving (#1504)

This commit is contained in:
Ta-Ching Chen
2020-01-24 20:43:42 +08:00
committed by GitHub
parent 2338fbb06f
commit 520cc0e130
19 changed files with 128 additions and 65 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ func Commands() *cobra.Command {
Required: []flag.Flag{flag.MqtFnName, flag.MqtTopic},
Optional: []flag.Flag{flag.MqtName, flag.MqtMQType, flag.MqtRespTopic,
flag.MqtErrorTopic, flag.MqtMaxRetries, flag.MqtMsgContentType,
flag.NamespaceFunction, flag.SpecSave},
flag.NamespaceFunction, flag.SpecSave, flag.SpecDry},
})
updateCmd := &cobra.Command{
+6 -1
View File
@@ -147,11 +147,16 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't call the API
// save to spec file or display the spec to console
if input.Bool(flagkey.SpecDry) {
return spec.SpecDry(*opts.trigger)
}
if input.Bool(flagkey.SpecSave) {
specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.ObjectMeta.Name)
err := spec.SpecSave(*opts.trigger, specFile)
if err != nil {
return errors.Wrap(err, "error creating message queue trigger spec")
return errors.Wrap(err, "error saving message queue trigger spec")
}
return nil
}