saltstack-formulas / nginx-formula

Nginx Salt Formula
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
163 stars 421 forks source link

Ignore missing servers or snippets when removing from map #275

Closed anderbubble closed 3 years ago

anderbubble commented 3 years ago

nginx.servers_config wants a lightened copy of the nginx map to render as json; but, when it was trying to remove the servers and snippets keys from the map it assumed their presence, causing a KeyError if they were not present by its use of .pop().

While wrapping these in an "if" clause would likely be more correct, along with replacing .pop() with del (if jinja even supports that) the simplest change here is to just specify a default value for .pop(), which obviates the KeyError.

Fixes #274

PR progress checklist (to be filled in by reviewers)


What type of PR is this?

Primary type

Secondary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

Pillar / config required to test the proposed changes

Debug log showing how the proposed changes work

Documentation checklist

Testing checklist

Additional context

javierbertoli commented 3 years ago

@anderbubble ping?

anderbubble commented 3 years ago

I'm here; just busy. I expect I can perform the additional changes you suggested; it just might take me a bit to get to it.

edit: I've put it on my agenda for Friday.

javierbertoli commented 3 years ago

@anderbubble wonderful! I'll wait for your changes to merge this.

myii commented 3 years ago
1. Add a similar fix in the [snippets.sls](https://github.com/saltstack-formulas/nginx-formula/blob/master/nginx/snippets.sls#L11-L12) file

3. Amend the commit message to something like `fix(config): ignore missing servers or snippets` so our automated versioning does not complain (check [here](https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst#relationship-between-commit-type-and-version-bump) for more details)

Updated this PR to complete the above steps requested by @javierbertoli. Includes resolving this review comment:

javierbertoli commented 3 years ago

Thanks you @anderbubble & @myii for this!

saltstack-formulas-travis commented 3 years ago

:tada: This PR is included in version 2.7.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: