Project

General

Profile

Refactor #6158

Improve default parameter gathering and handling

Added by Marek Hulán almost 5 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Param#set_default is a pain. We use it for setting values according to yaml default values dump. Parameters have already some default value set by parsers (either 'foreman::parameter1' if it's set by parameter (parameter1 = $foreman::parameter1) or correct value 'value1' (e.g. parameter1 = 'value1'). We currently can't distinguish between these two cases. Parser should indicate whether we need to lookup value from default values dump or we should cleanse dump before passing it to set_default. E.g. on puppet 2.7 we have :undefined as a value for direct value parameters. Puppet 3.3 has correct default value 'value1' because it's dumped as 'value1' => 'value1'.

Associated revisions

Revision e5aa246c (diff)
Added by Dominic Cleal about 2 years ago

refs #6158 - prefix variables in defaults with `$` (#31)

Revision 963005a9 (diff)
Added by Dominic Cleal about 2 years ago

fixes #6158 - only dump defaults for param defaults starting `$` (#194)

Refactors how defaults from the manifest and the defaults dump are
stored, keeping them in separate variables and expecting any params
with other variables as the default to have `$` prefixes.

Only params with a `$` default prefix will be dumped, so any other
default string values will not be dumped and are persisted correctly.

History

#1 Updated by Marek Hulán almost 5 years ago

  • Description updated (diff)

#2 Updated by Dominic Cleal over 2 years ago

I think the lack of distinction between the two types of value also causes the param default to be set to nil when a string default is specified. The string default is passed to dump_values(), e.g. dump_values("a value") which ends up in the defaults hash.

set_defaults is called with the output hash from dump_defaults() containing {"a value" => "nil"} and so the param default is set to nil rather than "a value".

Probably this should be fixed by retaining the "$" prefix in kafo_parsers on default values that are set to variables, then it's easy to tell them apart.

#3 Updated by Dominic Cleal over 2 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#4 Updated by The Foreman Bot over 2 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/kafo_parsers/pull/31 added

#5 Updated by The Foreman Bot over 2 years ago

  • Pull request https://github.com/theforeman/kafo/pull/194 added

#6 Updated by Dominic Cleal over 2 years ago

I hope I've cleared up the described ambiguity in defaults handling by introducing the '$' prefix for variable names, and better separating the manifest default and the dumped default inside Param.

#7 Updated by Dominic Cleal about 2 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF