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

(PDK-1107) Config fetch and [] should have no side effects #726

Merged
merged 1 commit into from
Aug 14, 2019

Conversation

glennsarti
Copy link
Contributor

Previously even querying a configuration setting would save the default value to
disk. This is undesirable, and not expected as a user, because not all defaults
should persist on disk, across multiple PDK sessions/projects/modules. This
commit:

  • Modifies the Config::Namespace class to have a new parameter called
    persistent_defaults.
  • Modified the [] and fetch methods in Namespace to optioally call save_data
    when a default value is queried and persistent_defaults is set to true. This
    is affected in #default_config_value method.
  • Added a wrapper method for mkdir_p for the FileSystem class so it could be
    mocked correctly in tests. Currently it was creating folder structures in the
    root of the PDK project.
  • Updated the namespace and config tests to ensure that the analytics settings
    use the persistent_defaults Namespace setting.

@coveralls
Copy link

coveralls commented Aug 8, 2019

Coverage Status

Coverage increased (+0.01%) to 92.075% when pulling de73b47 on glennsarti:get-should-not-side-effect into 520eee4 on puppetlabs:master.

Previously even querying a configuration setting would save the default value to
disk. This is undesirable, and not expected as a user, because not all defaults
should persist on disk, across multiple PDK sessions/projects/modules. This
commit:

* Modifies the Config::Namespace class to have a new parameter called
  persistent_defaults.
* Modified the [] and fetch methods in Namespace to optioally call save_data
  when a default value is queried and persistent_defaults is set to true. This
  is affected in #default_config_value method.
* Added a wrapper method for mkdir_p for the FileSystem class so it could be
  mocked correctly in tests.  Currently it was creating folder structures in the
  root of the PDK project.
* Updated the namespace and config tests to ensure that the analytics settings
  use the persistent_defaults Namespace setting.
Copy link
Contributor

@scotje scotje 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 to me, was this extracted from the other PR? It seems very familiar. 😄

@glennsarti
Copy link
Contributor Author

@scotje Yes. I extracted this commit from pdk config get so I can at least get something merged. I also need this for the pdk config schema PR

@glennsarti
Copy link
Contributor Author

Will wait for +1 from @rodjek before merge.

@rodjek rodjek merged commit ab5e290 into puppetlabs:master Aug 14, 2019
@glennsarti glennsarti deleted the get-should-not-side-effect branch August 19, 2019 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants