-
Notifications
You must be signed in to change notification settings - Fork 104
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
(PDK-1113) Use PDK configuration instead of AnswerFile class #842
Conversation
+10 to folding answer file functionality into pdk config. This does not actually remove the file yet though correct? Just a unified frontend to the existing file alongside other config? |
Correct, and I don't think we'll actually need to move the file either. It's doing a perfectly fine job right now, and for the most part hidden to users day-to-day activities. I'm actually thinking of adding a
|
To me, it makes sense to leave the config files referenced by other tools in place and just provide a frontend to them as you say. For files only referenced by PDK however, I'm in favor of eventually converging those into a single file for each config layer for simplification. |
26c9b9d
to
fa90e7a
Compare
|
3335918
to
91127fc
Compare
Previously the load_data method took a single string as the name of the file to load, however the actual file loaded was the file attribute of the class. This commit modifies the file loading to actually load the filename passed. This hasn't been an issue as yet, as both the filename and file parameters have been the same.
91127fc
to
c13edbc
Compare
Need to change this PR for the changes of PR 841 |
c13edbc
to
ae44fda
Compare
lib/pdk/generate/module.rb
Outdated
|
||
defaults = PDK::Module::Metadata::DEFAULTS.dup | ||
|
||
defaults['name'] = "#{opts[:username]}-#{opts[:module_name]}" unless opts[:module_name].nil? | ||
defaults['author'] = PDK.answers['author'] unless PDK.answers['author'].nil? | ||
defaults['license'] = PDK.answers['license'] unless PDK.answers['license'].nil? | ||
defaults['author'] = PDK.config.get_within_scopes('module_defaults.author') unless PDK.config.get_within_scopes('module_defaults.author').nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should come up with a helper around this get-and-set-unless-nil pattern that isn't so verbose. Maybe a method that yields the value to a block if not nil?
Something like
PDK.config.with_scoped_value('module_defaults.author') { |v| defaults['author'] = v }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that! Will implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit which does this.
Previously the PDK had two ways to retrieve the same configuration information. One via the PDK::Config classes and the other the AnswerFile class. This should only be one. This commit removes the AnswerClass (and associated features) and instead uses PDK::Config for setting management * Removes the PDK::AnswerFile class, and instead has a single helper method for the default file location. This may eventually be moved into the PDK::Config namespace as well * Removes the hidden `--answer-file` command line option and instead uses an environment variable PDK_ANSWER_FILE. This feature is not supported and is only used to acceptance testing. Note that we moved to an environment variable as there was a subtle race condition where the CLI reads from PDK::Config, but the CLI also moves the user answer file location. By using an environment variable this race condition can no longer occur. * Move setting reads from PDK.answers to PDK.config.pdk_setting(....) * Move setting writes from PDK.answers.update! to PDK.config.user['module_defaults']['....'] = * Modify tests for the setting read/write changes * Added a Mock configuration RSpec Context to stop any test information affecting actual real setting files. Previously module answer files were being modified
Previously the user needed to write verbose amounts of code to "do something if and only if the setting value is not nil". This commit adds a helper called `with_scoped_value` which will yield the setting value if and only if the value is not nil. This commit then updates the PDK to use this helper and adds tests for this new helper method.
ae44fda
to
8955729
Compare
CI is green! |
Builds on #841MergedPreviously the PDK had two ways to retrieve the same configuration information.
One via the PDK::Config classes and the other the AnswerFile class. This should
only be one. This commit removes the AnswerClass (and associated features) and
instead uses PDK::Config for setting management
Removes the PDK::AnswerFile class, and instead has a single helper method for
the default file location. This may eventually be moved into the PDK::Config
namespace as well
Removes the hidden
--answer-file
command line option and instead uses anenvironment variable PDK_ANSWER_FILE. This feature is not supported and is
only used to acceptance testing. Note that we moved to an environment
variable as there was a subtle race condition where the CLI reads from
PDK::Config, but the CLI also moves the user answer file location. By using
an environment variable this race condition can no longer occur.
Move setting reads from PDK.answers to PDK.config.pdk_setting(....)
Move setting writes from PDK.answers.update! to
PDK.config.user['module_defaults']['....'] =
Modify tests for the setting read/write changes
Added a Mock configuration RSpec Context to stop any test information
affecting actual real setting files. Previously module answer files were
being modified