Skip to content

Commit

Permalink
Docs: replace default column with required
Browse files Browse the repository at this point in the history
  • Loading branch information
jumboduck committed Sep 7, 2021
1 parent 20fdc41 commit b20d9f5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
23 changes: 20 additions & 3 deletions cmd/reporter/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ func generateReSTFiles(cmd *cobra.Command, dir string) error {
lines = append(lines, " :header-rows: 1")
lines = append(lines, "")
lines = append(lines, " * - ENV_VAR_NAME")
lines = append(lines, " - Default")
lines = append(lines, " - Required?")
lines = append(lines, " - Notes")
cmd.Flags().VisitAll(func(f *pflag.Flag) {
if f.Name != "help" {
lines = append(lines, fmt.Sprintf(" * - %s", merkelyEnvVar(f.Name)))
lines = append(lines, fmt.Sprintf(" - %s", f.DefValue))
lines = append(lines, fmt.Sprintf(" - %s", f.Usage))
lines = append(lines, fmt.Sprintf(" - %s", required(f.DefValue)))
lines = append(lines, fmt.Sprintf(" - %s", usage(f.Usage, f.DefValue)))
}
})
for _, line := range lines {
Expand All @@ -114,3 +114,20 @@ func merkelyEnvVar(s string) string {
s = strings.ToUpper(s)
return "MERKELY_" + s
}

func required(s string) string {
if len(s) == 0 {
return "yes"
} else {
return "no"
}
}

func usage(usage string, def string) string {
var result string
result += usage
if required(def) == "no" {
result += " Defaults to :code:`" + def + "`."
}
return result
}
26 changes: 13 additions & 13 deletions docs/rst/merkely_report_env_ecs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
:header-rows: 1

* - ENV_VAR_NAME
- Default
- Required?
- Notes
* - MERKELY_API_TOKEN
-
- yes
- the merkely API token.
* - MERKELY_CLUSTER
-
- yes
- name of the ECS cluster
* - MERKELY_CONFIG_FILE
- merkely
- [optional] the merkely config file path.
- no
- [optional] the merkely config file path. Defaults to :code:`merkely`.
* - MERKELY_DRY_RUN
- false
- whether to send the request to the endpoint or just log it in stdout.
- no
- whether to send the request to the endpoint or just log it in stdout. Defaults to :code:`false`.
* - MERKELY_HOST
- https://app.merkely.com
- the merkely endpoint.
- no
- the merkely endpoint. Defaults to :code:`https://app.merkely.com`.
* - MERKELY_MAX_API_RETRIES
- 3
- how many times should API calls be retried when the API host is not reachable.
- no
- how many times should API calls be retried when the API host is not reachable. Defaults to :code:`3`.
* - MERKELY_OWNER
-
- yes
- the merkely organization.
* - MERKELY_SERVICE_NAME
-
- yes
- name of the ECS service
32 changes: 16 additions & 16 deletions docs/rst/merkely_report_env_k8s.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
:header-rows: 1

* - ENV_VAR_NAME
- Default
- Required?
- Notes
* - MERKELY_API_TOKEN
-
- yes
- the merkely API token.
* - MERKELY_CONFIG_FILE
- merkely
- [optional] the merkely config file path.
- no
- [optional] the merkely config file path. Defaults to :code:`merkely`.
* - MERKELY_DRY_RUN
- false
- whether to send the request to the endpoint or just log it in stdout.
- no
- whether to send the request to the endpoint or just log it in stdout. Defaults to :code:`false`.
* - MERKELY_EXCLUDE_NAMESPACE
- []
- the comma separated list of namespaces (or namespaces regex patterns) NOT to harvest artifacts info from. Can't be used together with --namespace.
- no
- the comma separated list of namespaces (or namespaces regex patterns) NOT to harvest artifacts info from. Can't be used together with --namespace. Defaults to :code:`[]`.
* - MERKELY_HOST
- https://app.merkely.com
- the merkely endpoint.
- no
- the merkely endpoint. Defaults to :code:`https://app.merkely.com`.
* - MERKELY_KUBECONFIG
-
- yes
- kubeconfig path for the target cluster
* - MERKELY_MAX_API_RETRIES
- 3
- how many times should API calls be retried when the API host is not reachable.
- no
- how many times should API calls be retried when the API host is not reachable. Defaults to :code:`3`.
* - MERKELY_NAMESPACE
- []
- the comma separated list of namespaces (or namespaces regex patterns) to harvest artifacts info from. Can't be used together with --exclude-namespace.
- no
- the comma separated list of namespaces (or namespaces regex patterns) to harvest artifacts info from. Can't be used together with --exclude-namespace. Defaults to :code:`[]`.
* - MERKELY_OWNER
-
- yes
- the merkely organization.

0 comments on commit b20d9f5

Please sign in to comment.