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

More flexible & generic config #267

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

faudebert
Copy link

@faudebert faudebert commented Jul 1, 2020

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

None.

Describe the changes you're proposing

This pull-request makes (hopefully) better use of jinja.map and allows to seamlessly rename meta-state. While not useful per se for the official repository, renaming permits easier reusability when forking the formula (ex. you want to use both original and forked formulas in your environment).

Pillar / config required to test the proposed changes

No specific pillar is required. If my changes are correct, you should not see any visible changes when applying your state.

If interested, you could test meta-state renaming (ex. mv nginx-formula/{nginx,mynginx}). Considering no other changes have been made, you should be able to use mynginx meta-state as drop-in replacement for nginx. Also note that pillar namespace defaults to the meta-state name (i.e. mynginx in that example).

Optionnaly, you can customize the formula pillar namespace by setting {meta-state-name}:pillar:namespace pillar (ex. mynginx:pillar:namespace: mynginx2).

Debug log showing how the proposed changes work

None for now.

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

@pull-assistant
Copy link

pull-assistant bot commented Jul 1, 2020

Score: 0.89

Best reviewed: commit by commit


Optimal code review plan (1 warning)

refactor(import): uniformize map.jinja imports

nginx/certificates.sls 50% changes removed in refactor(pillar): na...

     refactor(certs): use jinja.map to get pillars

     refactor(meta-state): use relative includes

     refactor(pillar): namespace defaults to meta-state name

     refactor(pillar): store defaults into yaml files

     refactor(pillar): factorize some defaults

Powered by Pull Assistant. Last update 4edd99f ... 5d1addc. Read the comment docs.

@faudebert faudebert force-pushed the upstream/generic-namespaces branch 2 times, most recently from 5a9f6e0 to 19a6656 Compare July 2, 2020 10:05
@faudebert faudebert changed the title Upstream/generic namespaces More flexible & generic config Jul 2, 2020
@faudebert faudebert mentioned this pull request Jul 2, 2020
19 tasks
Copy link
Member

@noelmcloughlin noelmcloughlin left a comment

Choose a reason for hiding this comment

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

LGTM, can be merged before #268. thanks @faudebert

nginx/certificates.sls Outdated Show resolved Hide resolved
@myii
Copy link
Member

myii commented Jul 15, 2020

@sticky-note Would you mind reviewing this PR?

Copy link
Member

@daks daks left a comment

Choose a reason for hiding this comment

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

The rest looks good to me but haven't checked in details.

@@ -357,3 +357,7 @@ nginx:
- alt_nginx.service
nginx_snippet_file_managed:
- alt_server.conf

# Configure formula pillar namespace
pillar:
Copy link
Member

Choose a reason for hiding this comment

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

This pillar:namespace parameter and use seems to be something new accross all community formulas, but it may be a solution to a problem @myii @sticky-note are discussing.

This is already done mostly everywhere and covers few remaining
locations.
Allow to rename the meta-state without having to change substates
references. This might be useful one wants to use this formula with a
(renamed) fork within the same environment.
This might be useful if one wants to use this formula with a (renamed)
fork within the same environment.

Note this also permits to override pillar namespace by defining
'{meta-state name}:pillar:namespace: str'.
@faudebert
Copy link
Author

Rebased on master and followed @daks advice regarding using relative includes (thanks!).

Let me know if I can do anything to help with the merge process.

@sticky-note
Copy link
Member

@daks @faudebert @noelmcloughlin Sorry for latency.
@faudebert Is that possible to make use of map.jinja from template-formula.
I think it is the best moment to integrate this.
-> https://github.com/saltstack-formulas/template-formula/blob/5d36fda7a473a5aefbf4ff80cb9747cf608771c9/TEMPLATE/map.jinja
You can remove all between the REMOVEME tags and all after this line https://github.com/saltstack-formulas/template-formula/blob/5d36fda7a473a5aefbf4ff80cb9747cf608771c9/TEMPLATE/map.jinja#L54.
And you can do post processing if needed after this line too.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants