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

Proxy ensure parameter. #556

Merged
merged 1 commit into from
Aug 5, 2015
Merged

Proxy ensure parameter. #556

merged 1 commit into from
Aug 5, 2015

Conversation

mike-callahan
Copy link

Added an ensure parameter for user control of proxy presence. Defaults to undef to resist breaking any current setup.

@daenney
Copy link

daenney commented Aug 4, 2015

I think I understand what you're trying to achieve here but could you list the use cases? The code isn't entirely obvious.

@mike-callahan
Copy link
Author

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.

@daenney
Copy link

daenney commented Aug 4, 2015

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.

@mike-callahan
Copy link
Author

Done.

@daenney
Copy link

daenney commented Aug 4, 2015

Right. All I need is a squash and we should be good to go as long as @mhaskel has no objections 😄.

@underscorgan
Copy link

I think my only comment is that we should probably validate we're getting a valid value for ensure.

@daenney
Copy link

daenney commented Aug 4, 2015

That's a good point, validate_re($proxy['ensure'], ['file', 'present', 'absent', undef] and make sure to only check that if $proxy['ensure'].

@mike-callahan
Copy link
Author

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?

@daenney
Copy link

daenney commented Aug 5, 2015

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.

@mike-callahan
Copy link
Author

Squashed and validated.

@@ -64,8 +67,9 @@
validate_hash($settings)
validate_hash($ppas)

if $proxy['host'] {
if $proxy['ensure'] or $proxy['host'] {

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.

Copy link
Author

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'),
    }
  }

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.

Copy link

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.

Copy link
Author

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'),
    }
  }

Copy link

Choose a reason for hiding this comment

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

Yes

Copy link

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,

if $proxy['host'] {
apt::setting { 'conf-proxy':
priority => '01',
content => template('apt/_conf_header.erb', 'apt/proxy.erb'),
}
}
doesn't use $_proxy but it should have.

Copy link
Author

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
@underscorgan
Copy link

👍 thanks for the work @callahm3 !

underscorgan pushed a commit that referenced this pull request Aug 5, 2015
Proxy ensure parameter.
@underscorgan underscorgan merged commit 849d000 into puppetlabs:master Aug 5, 2015
@mike-callahan
Copy link
Author

Thanks!

@daenney daenney removed the needs-work label Aug 5, 2015
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.

3 participants