-
Notifications
You must be signed in to change notification settings - Fork 461
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
Proxy ensure parameter. #556
Conversation
I think I understand what you're trying to achieve here but could you list the use cases? The code isn't entirely obvious. |
Currently, once a proxy is set through the module it can't be removed. This will allow a user to remove a proxy they no longer want set. |
Thanks. Unfortunately this is lacking tests right now for the new behaviours so if you could have a look at https://github.com/puppetlabs/puppetlabs-apt/blob/master/spec/classes/apt_spec.rb and add to them we can move forward. |
Done. |
Right. All I need is a squash and we should be good to go as long as @mhaskel has no objections 😄. |
I think my only comment is that we should probably validate we're getting a valid value for ensure. |
That's a good point, |
I didn't validate because it is already being validated at a lower level under apt::setting. I can still add if you'd like. By squash do you mean combining my commits? |
Mmm that's true but validating it here allows us to give a slightly more descriptive error message since the user is not necessarily aware that it's being passed on to another type and as such might be confused about a resource suddenly throwing an error it has no idea about. Yes, squash is turning your commits into 1. We prefer 1 feature to map to 1 commit and tests are included as part of accepting a new feature. It keeps the history clean and facilitates things like writing chaneglogs. |
Squashed and validated. |
@@ -64,8 +67,9 @@ | |||
validate_hash($settings) | |||
validate_hash($ppas) | |||
|
|||
if $proxy['host'] { | |||
if $proxy['ensure'] or $proxy['host'] { |
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.
I don't think this is going to behave the way you want it to. You'll end up with a weird proxy file if you have ensure != absent and the proxy host isn't specified.
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.
How about:
if $proxy['ensure'] == 'absent' or $proxy['host'] {
apt::setting { 'conf-proxy':
ensure => $_proxy['ensure'],
priority => '01',
content => template('apt/_conf_header.erb', 'apt/proxy.erb'),
}
}
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.
I think we'd need to use $_proxy['ensure']
instead of $proxy['ensure']
to make sure it doesn't break strict variables, but otherwise yes, I think that should work.
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.
Yap, need to use $_proxy[]
for consistency.
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.
Do you mean like this?
if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
apt::setting { 'conf-proxy':
ensure => $_proxy['ensure'],
priority => '01',
content => template('apt/_conf_header.erb', 'apt/proxy.erb'),
}
}
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.
Yes
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.
It's actually a bug on our side right now,
puppetlabs-apt/manifests/init.pp
Lines 67 to 72 in cd37fc3
if $proxy['host'] { | |
apt::setting { 'conf-proxy': | |
priority => '01', | |
content => template('apt/_conf_header.erb', 'apt/proxy.erb'), | |
} | |
} |
$_proxy
but it should have.
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.
Ok should be all set
…s to undef to resist breaking any current setup. added spec entry Added validation fixed ensure hash
👍 thanks for the work @callahm3 ! |
Thanks! |
Added an ensure parameter for user control of proxy presence. Defaults to undef to resist breaking any current setup.