From 302fe0879531445d58303d93ecbb06eb98e6430c Mon Sep 17 00:00:00 2001 From: Steve Ramage Date: Sun, 11 Aug 2024 10:14:32 -0700 Subject: [PATCH] Resolves #465 - Allow variable descriptions to be empty in runbooks --- cmd/runbooks.go | 8 ++++++- docs/runbook-development.md | 44 ++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/cmd/runbooks.go b/cmd/runbooks.go index ceff758..97a0a88 100644 --- a/cmd/runbooks.go +++ b/cmd/runbooks.go @@ -420,7 +420,13 @@ func processRunbookVariablesOnCommand(runbookActionRunActionCommand *cobra.Comma log.Errorf("Could not set flag as required, this is a bug of some kind %s: %v", key, err) } } else { - runbookActionRunActionCommand.Flags().StringVar(runbookStringArguments[key], key, variable.Default, variable.Description.Short) + description := "" + + if variable.Description != nil { + description = variable.Description.Short + } + + runbookActionRunActionCommand.Flags().StringVar(runbookStringArguments[key], key, variable.Default, description) } runbookActionRunActionCommand.RegisterFlagCompletionFunc(key, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/docs/runbook-development.md b/docs/runbook-development.md index 021e887..2ad7383 100644 --- a/docs/runbook-development.md +++ b/docs/runbook-development.md @@ -147,7 +147,7 @@ Flags: If you would like to use a dashed argument name you need to use a different syntax in the chart: ``` -{{ . index "dashed-argument-name" }} +{{ index . "dashed-argument-name" }} ``` #### Showing the output @@ -170,30 +170,30 @@ name: hello-world description: short: "A hello world runbook" actions: - sequential-sleeps: - variables: + sequential-sleeps: + variables: + count: + type: INT + default: 2 + description: + short: "The number of sleeps" + commands: + - |2 + {{- range untilStep 0 .count 1}} + - sleep 1 + {{- end -}} + concurrent-sleeps: + variables: count: - type: INT - default: 2 - description: - short: "The number of sleeps" - commands: - - |2 + type: INT + default: 2 + description: + short: "The number of sleeps" + commands: + - | {{- range untilStep 0 .count 1}} - - sleep 1 + sleep 1 {{- end -}} - concurrent-sleeps: - variables: - count: - type: INT - default: 2 - description: - short: "The number of sleeps" - commands: - - | - {{- range untilStep 0 .count 1}} - sleep 1 - {{- end -}} ``` It's important for all commands to be indended the same amount, and start with a `-` this will cause the entire string to be valid as a Yaml array.