Skip to content

Commit

Permalink
Resolves #465 - Allow variable descriptions to be empty in runbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-r-west committed Aug 11, 2024
1 parent 6728f41 commit 302fe08
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
8 changes: 7 additions & 1 deletion cmd/runbooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
44 changes: 22 additions & 22 deletions docs/runbook-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 302fe08

Please sign in to comment.