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-1612) Add PDK::Context and context detection #853

Merged
merged 2 commits into from
Feb 20, 2020

Conversation

glennsarti
Copy link
Contributor

Previously the PDK assumed it was always within a Puppet Module, but the PDK can
be used in far more different contexts. This commit implements the PDK Context
RFC [1], in preparation for other parts of the PDK to consume it, for example
PDK validators:

  • Adds the base Context and three concrete contexts: None, Module and
    ControlRepo
  • Adds a memoized context object to PDK (PDK.context), for consumption by other
    parts of the PDK
  • Updates the module pdk compatibility methods to accept a module path instead
    of assume the PDK is always in a module. This is needed for the Module context
    to check if an arbitrary module is PDK compatible
  • Adds two test fixtures (a Puppet module and a control repo) for use by rspec
    for contex detection
  • Adds tests for context detection via PDK::Context.create

[1] https://github.com/puppetlabs/pdk-planning/blob/master/RFCs/0007-add-pdk-context.md

This commit fixes a typo error in the memoization test for PDK.config as it was
accidentally testing PDK.logger.
@glennsarti glennsarti requested a review from a team as a code owner February 18, 2020 03:04
@coveralls
Copy link

coveralls commented Feb 18, 2020

Coverage Status

Coverage increased (+0.1%) to 91.479% when pulling 6429d25 on glennsarti:pdk-1612-add-pdk-context into bfcd14a on puppetlabs:master.

lib/pdk/context.rb Outdated Show resolved Hide resolved
lib/pdk/util.rb Outdated Show resolved Hide resolved
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 pending resolution of @rodjek's comments

Previously the PDK assumed it was always within a Puppet Module, but the PDK can
be used in far more different contexts.  This commit implements the PDK Context
RFC [1], in preparation for other parts of the PDK to consume it, for example
PDK validators:

* Adds the base Context and three concrete contexts: None, Module and
  ControlRepo
* Adds a memoized context object to PDK (PDK.context), for consumption by other
  parts of the PDK
* Updates the module pdk compatibility methods to accept a module path instead
  of assume the PDK is always in a module. This is needed for the Module context
  to check if an arbitrary module is PDK compatible
* Adds two test fixtures (a Puppet module and a control repo) for use by rspec
  for contex detection
* Adds tests for context detection via PDK::Context.create

[1] https://github.com/puppetlabs/pdk-planning/blob/master/RFCs/0007-add-pdk-context.md
@glennsarti glennsarti merged commit 5211ebf into puppetlabs:master Feb 20, 2020
@rodjek rodjek added this to the February 2020 milestone Feb 26, 2020
@rodjek rodjek added the feature label Feb 26, 2020
@glennsarti glennsarti deleted the pdk-1612-add-pdk-context branch March 5, 2020 04:56
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.

4 participants