Skip to content

Commit

Permalink
(bug) Show YAML plan parameters without defaults as required
Browse files Browse the repository at this point in the history
This fixes a minor bug in `Bolt::PAL.get_plan_info` that incorrectly
built the parameter hash for YAML plans, resulting in an inaccurate
usage line in `bolt plan show <plan>` output.

Previously, if a YAML plan parameter did not have a default value,
the parameter hash would receive a value of `nil` for the parameter's
default value. When this hash is received by the outputter to display
the plan info, it would check whether the parameter had a default value
key specified to determine whether it should display the parameter as
optional or required in the usage line. Since parameters for YAML plans
would always have this key, the outputter would show all parameters as
optional. Now, the default value key is only added if there is a default
value for the parameter.

!bug

* **Show YAML plan parameters without default values as optional**

  Bolt was displaying YAML plan parameters without default values as
  optional in `bolt plan show` output. Now, Bolt will show a parameter
  without a default value as required.
  • Loading branch information
beechtom committed Aug 18, 2020
1 parent 910baec commit bb1c9c4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bolt/pal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def get_plan_info(plan_name)
end
params[name] = { 'type' => type_str }
params[name]['sensitive'] = param.type_expr.instance_of?(Puppet::Pops::Types::PSensitiveType)
params[name]['default_value'] = param.value
params[name]['default_value'] = param.value unless param.value.nil?
params[name]['description'] = param.description if param.description
end
{
Expand Down
1 change: 0 additions & 1 deletion spec/bolt/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,6 @@ def stub_config(file_content = {})
"parameters" => {
"nodes" => {
"type" => "TargetSpec",
"default_value" => nil,
"sensitive" => false
},
"param_optional" => {
Expand Down

0 comments on commit bb1c9c4

Please sign in to comment.