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

setting index files to undef doesn't work as expected #1128

Closed
wyardley opened this issue Sep 30, 2017 · 4 comments
Closed

setting index files to undef doesn't work as expected #1128

wyardley opened this issue Sep 30, 2017 · 4 comments

Comments

@wyardley
Copy link
Collaborator

wyardley commented Sep 30, 2017

For some reason, this works to suppress the index directive:

nginx::resource::server { 'www.puppetlabs.com':
  index_files          => [],  
  use_default_location => false,
}
nginx::resource::location { "/":
  index_files => [],
}

But this doesn't:

nginx::resource::server { 'www.puppetlabs.com':
  index_files          => undef,
  use_default_location => false,
}
nginx::resource::location { "/":
  index_files => undef,
}
@wyardley
Copy link
Collaborator Author

wyardley commented Oct 2, 2017

@wyardley
Copy link
Collaborator Author

wyardley commented Oct 2, 2017

@walkamongus so it turns out this isn't actually valid

passing in

nginx::resource::server { 'foo':
  index_files => undef,
}

gets the default behavior, vs. suppressing it.

So this creates unexpected behavior. Also, the tests don't work as expected. So I'll probably more or less revert #1094 in #1129, as well as updating the tests.

@walkamongus
Copy link

@wyardley yep -- that looks to be correct. I found some discussion of this at https://tickets.puppetlabs.com/browse/PUP-5295. It looks like there is a desire to make the distinction between 'default value' and undef easier, but it hasn't been done due to backwards incompatibility issues.

Interestingly enough, after looking at https://docs.puppet.com/puppet/5.2/lang_data_default.html#anywhere-else and knocking up a test case, setting the param to default instead of undef resulted in the expected behavior of "ignoring" the default value:

~$ cat test.pp
class testclass (
  Variant[Undef,Default,Array] $files = ['one', 'two', 'three']
) {
  if $files { notify { $files: } }
}

class {'testclass':
  files => undef,
}
~$ puppet apply test.pp
Notice: Compiled catalog for localhost.localdomain in environment production in 0.10 seconds
Notice: one
Notice: /Stage[main]/Testclass/Notify[one]/message: defined 'message' as 'one'
Notice: two
Notice: /Stage[main]/Testclass/Notify[two]/message: defined 'message' as 'two'
Notice: three
Notice: /Stage[main]/Testclass/Notify[three]/message: defined 'message' as 'three'
Notice: Applied catalog in 0.02 seconds


~$ cat test.pp
class testclass (
  Variant[Undef,Default,Array] $files = ['one', 'two', 'three']
) {
  if $files { notify { $files: } }
}
 
class {'testclass':
  files => default,
}
~$ puppet apply test.pp
Notice: Compiled catalog for localhost.localdomain in environment production in 0.07 seconds
Notice: Applied catalog in 0.05 seconds

wyardley added a commit that referenced this issue Oct 3, 2017
@wyardley
Copy link
Collaborator Author

Closed via #1129

cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants