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

Fail defined types if nginx class was not declared before #1070

Merged
merged 1 commit into from
Sep 18, 2017
Merged

Fail defined types if nginx class was not declared before #1070

merged 1 commit into from
Sep 18, 2017

Conversation

vinzent
Copy link
Contributor

@vinzent vinzent commented Apr 11, 2017

Because the ngnix::resource:* types access ::ngnix class
parameters the nginx class needs to be declared before calling
the defined type.

include ::nginx inside the defined type is not enough because
params are evaluated before include is parsed.

Two of the defined types only access params inside. The include
way would work there - but for consistency I also added the fail.

Closes #983

Because the `ngnix::resource:*` types access ::ngnix class
parameters the nginx class needs to be declared before calling
the defined type.

`include ::nginx` inside the defined type is not enough because
params are evaluated before include is parsed.

Two of the defined types only access params inside. The include
way would work there - but for consistency I also added the fail.

Closes #983
@vinzent
Copy link
Contributor Author

vinzent commented Apr 11, 2017

@law @timatooth @triforce you might be interested in reviewing because of your interest in #983

@vinzent vinzent added bug Something isn't working and removed bug Something isn't working labels Apr 11, 2017
@vinzent
Copy link
Contributor Author

vinzent commented Apr 11, 2017

probably needs proper tests? :-)

Copy link
Collaborator

@wyardley wyardley left a comment

Choose a reason for hiding this comment

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

This makes sense to me, but I'd like to see input from someone who's been working more actively on the Puppet 4 stuff to just doublecheck that this is a good way to implement it. Maybe ask on Slack or IRC in #voxpupuli or wait for someone to chime in here?

In many other parts of the module's namespace, we're already explicitly making these private, but I think these are intended to be referenced directly.

And yes, tests.

@@ -63,6 +63,10 @@
Optional[Boolean] $proxy_recursive = undef
) {

if ! defined(Class['nginx']) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is fine and probably goes with the style of the module as a whole... that said, I think some people would say that 'unless' is more idiomatic, and probably lines up better with https://docs.puppet.com/puppet/4.9/lang_conditional.html ? I like 'if not' better than 'if !' but IIRC, it may not work in the DSL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If or unless is IMHO very opinionated. I for myself prefer if over unless in most situations. But I'll change to unless if requested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mostly just don't like if ! vs if not but I don't have a strong opinion, and it's used all throughout the code, so I don't see any reason to change it.

@vinzent
Copy link
Contributor Author

vinzent commented Apr 12, 2017

@wyardley this isn't related at all with puppet4. The very same parse order problem exists with puppet since forever. This fail if not defined behaviour here is the very same as puppetlabs/apache uses for apache::vhost

@vinzent
Copy link
Contributor Author

vinzent commented Apr 12, 2017

@wyardley I havent checked if any of the defined types are just private-style types. If there sre some it might make sense to make to mark them private in addition. In addition to even ensure with internal use the class gets included before.

@wyardley
Copy link
Collaborator

this isn't related at all with puppet4

Sorry, I just meant that there might be a different way to test for this with some of the features that are being added now that we're dropping Puppet 3 support.

I havent checked if any of the defined types are just private-style types.

I think most of these are intended to be called directly via

nginx::resource::foo { 'something':

as described in the docs, so something along these lines is probably the right approach.

@wyardley
Copy link
Collaborator

@vinzent gentle bump

@wyardley wyardley merged commit fc36311 into voxpupuli:master Sep 18, 2017
@wyardley
Copy link
Collaborator

Ran this by @bastelfreak and decided we should merge this in even without tests

cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this pull request Sep 13, 2019
…efined

Fail defined types if nginx class was not declared before
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this pull request Oct 19, 2020
…efined

Fail defined types if nginx class was not declared before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants