-
Notifications
You must be signed in to change notification settings - Fork 284
Prevent default fromrepo
being evaluated as string 'None'
#217
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
Conversation
Bare `fromrepo:` results in `{..., 'fromrepo': 'None', ...}`
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.
@myii good analysis. this is approved. Would be great if you can update all None to '' & update pillar.example.
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.
Good finding @myii
It seems that or
comparison for non-Boolean values in Jinja are not reliable.
Although you actually fixed the issue I suggest to harden it even more and change that line:
{% set fromrepo = repo.fromrepo or name + '-pgdg' %} |
Lets use default
filter like this:
{% set fromrepo = repo.fromrepo|default(name ~ '-pgdg', true) %}
@noelmcloughlin Will do that shortly. My only concern is that
@vutny OK, will apply that to both lines 16 and 41, which are identical. |
@noelmcloughlin @vutny Commits pushed. I'll also push |
@myii. Just set update: just saw your comment. I usually set this value (in other formulas) to 0 (zero). |
@noelmcloughlin OK, added |
@noelmcloughlin Just a thought: should alternatives system be disabled by default? This won't cause regressions for users? |
Yes, it should be disabled by default - definitely. 8 out of 10 people hate linux alternatives ;-) |
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.
Thank you, this is great work!!
No problem, glad to have been of assistance. |
Discussion
@noelmcloughlin Thanks for #209; this follows-on from that.
I've been using this formula for some time with
use_upstream_repo: True
. Didn't have a value forfromrepo
in the pillar when running this formula for a new minion. Encountered an error:Initially tracked back to:
postgres-formula/postgres/codenamemap.yaml
Line 16 in 3d8d848
'None'
Then tracked back to:
postgres-formula/postgres/defaults.yaml
Line 60 in 3d8d848
defaults.postgres
to establish that the barefromrepo:
above results in{..., 'fromrepo': 'None', ...}
The proposed change in this PR allows
fromrepo
to be evaluated as intended.Further potential issues
When collecting the debug output of
defaults.postgres
, the'None'
strings present correlate with all of the bare defaults:Appears that it would be appropriate to set default values for these as well, unless there is a specific reason for using
'None'
as a string.Consideration: Add
fromrepo
topillar.example
It's probably useful to have
fromrepo
mentioned inpillar.example
. Finding an appropriate example value may be difficult. Was thinking about addingfromrepo: 'bionic-pgdg'
to this PR but that is Ubuntu-specific.