Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jan 4, 2017

Conversation

domcleal
Copy link
Contributor

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.


Needs theforeman/kafo_parsers#31, I can increase the min kafo_parsers version in the gemspec if/when that's released.

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good and works fine, just two nits to consider

end

def default=(default)
default = nil if ['UNSET', :undef].include?(default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you extract ['UNSET', :undef] from here and manifest_default= to some constant, e.g. UNSETTING_VALUES so they do not get out of sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to UNSET_VALUES.

end

def manifest_default_params_variable
manifest_default[1..-1] if manifest_default.to_s.start_with?('$')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if dump_default_needed? or rename/alias the method so it makes sense in this context

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used dump_default_needed?.

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.
@domcleal
Copy link
Contributor Author

domcleal commented Jan 4, 2017

PR updated with the suggested changes.

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @domcleal, merging.

@ares ares merged commit 963005a into theforeman:master Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants