Jira (PUP-10642) Uppercase Default value in conditional documentation a typo?

21 views
Skip to first unread message

Michael Krause (Jira)

unread,
Aug 25, 2020, 3:51:04 AM8/25/20
to puppe...@googlegroups.com
Michael Krause created an issue
 
Puppet / Bug PUP-10642
Uppercase Default value in conditional documentation a typo?
Issue Type: Bug Bug
Affects Versions: PUP 6.y
Assignee: Unassigned
Components: Docs
Created: 2020/08/25 12:50 AM
Priority: Major Major
Reporter: Michael Krause

Puppet Version: 6.17
**
**

Starting with 6.x it seems the documentation for case conditionals}}{{{{ shows an uppercase `Default` as catch-call value. Since this doesn't work and would also be inconsistent to the selector statement I'm carefully assuming it's a (grave) typo?}}

This test seems to confirm:

class test {

  case $facts['os']['name'] {
{{    Default: { notify

{'uppercase default':}

}}}

{{  }}}

  case $facts['os']['name'] {
{{    default: { notify

{'lowercase default':}

}}}
{{  }}}

}

include test

 

And the log:

 

{{root@host :~# puppet apply test.pp }}
Notice: Compiled catalog for host in environment production in 0.02 seconds
Notice: lowercase default
Notice: /Stage[main]/Test/Notify[lowercase default]/message: defined 'message' as 'lowercase default'
Notice: Applied catalog in 0.06 seconds

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Michael Krause (Jira)

unread,
Aug 25, 2020, 3:52:02 AM8/25/20
to puppe...@googlegroups.com
Michael Krause updated an issue
Change By: Michael Krause
*Puppet Version: 6.17*
**
**

{{Starting with 6.x it seems the [documentation for case conditionals
}}{{ |https://puppet.com/docs/puppet/6.17/lang_conditional.html]}} {{ shows an uppercase `Default` as catch-call value. Since this doesn't work and would also be inconsistent to the selector statement I'm carefully assuming it's a (grave) typo? }}

{{This test seems to confirm:}}

{{class test {}}

{{
  case $facts['os']['name'] {}}
{{    Default: \{ notify {'uppercase default':} }}}

{{
  }}}

{{   case $facts['os']['name'] {}}
{{    default: \{ notify {'lowercase default':} }}}
{{
  }}}

{{}}}

{{include test}}

 

{{
And the log:}}

 


{{root@host :~# puppet apply test.pp }}
{{
{{ Notice: Compiled catalog for host in environment production in 0.02 seconds}} }}
{{
{{ Notice: lowercase default}} }}
{{
{{ Notice: /Stage[main]/Test/Notify[lowercase default]/message: defined 'message' as 'lowercase default'}} }}
{{
{{ Notice: Applied catalog in 0.06 seconds}} }}

Michael Krause (Jira)

unread,
Aug 25, 2020, 3:54:03 AM8/25/20
to puppe...@googlegroups.com
Michael Krause updated an issue
*Puppet Version: 6.17*



{{Starting with 6.x it seems the [documentation for case conditionals|https://puppet.com/docs/puppet/6.17/lang_conditional.html]}} shows an uppercase `Default` as catch-call value. Since this doesn't work and would also be inconsistent to the selector statement I'm carefully assuming it's a (grave) typo?

{{This test seems to confirm:}}

 
{code:java}
class test {
  case $facts['os']['name'] {
    Default:  { notify {'uppercase default':} }
  }
  case $facts['os']['name'] {
    default:  { notify {'lowercase default':} }
  }
}
include test
{code}
 

 

{{And the log:}}

{ { noformat}
root@host :~# puppet apply test.pp }}
{{ {{

Notice: Compiled catalog for host in environment production in 0.02 seconds }}}}
{{ {{ Notice: lowercase default }}}}
{{ {{ Notice: /Stage[main]/Test/Notify[lowercase default]/message: defined 'message' as 'lowercase default' }}}}
{{ {{ Notice: Applied catalog in 0.06 seconds

{noformat
} }}}

Henrik Lindberg (Jira)

unread,
Aug 25, 2020, 7:21:03 AM8/25/20
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-10642
 
Re: Uppercase Default value in conditional documentation a typo?

An uppercase bare word like Default is a reference to a datatype. There happens to be a datatype named Default and it matches the value that results when you type default. So - the example will either match a literal default (with the Default entry), or a missing value (the default entry).

While not wrong per se. if that is what the documentation is trying to show it should say so, otherwise it is just cryptic.

Josh Cooper (Jira)

unread,
Aug 25, 2020, 3:10:03 PM8/25/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10642

I think this is accidental in this case. We'll take a look, thanks for letting us know.

Claire Cadman (Jira)

unread,
Sep 2, 2020, 12:18:03 PM9/2/20
to puppe...@googlegroups.com

Josh Cooper just to confirm, `Default` should have a lower case `d`? Thanks!

Henrik Lindberg (Jira)

unread,
Sep 2, 2020, 2:23:03 PM9/2/20
to puppe...@googlegroups.com

The docs shows two examples; one with uppercase and one with lower case. Only the lower case is explained, and the other is quite advanced. Simply remove the example with the upper case Default to at least not make it confusing, but why the example outputs that it is using a "lowercase" default is a mystery. Would make sense if the first option was an os name in upper case, for example "Debian", with a notice "this is a debian", and the "default" says "this is not debian" - or something like that....

Claire Cadman (Jira)

unread,
Sep 11, 2020, 6:26:03 AM9/11/20
to puppe...@googlegroups.com

Henrik Lindberg, so would you remove the entire case statement example:

A case statement evaluates a list of cases against a control expression, and executes the first code block where the case value matches the control expression. This example declares a role class on a node, but which role class it declares depends on what operating system the node runs:

{{}}

case $facts['os']['name'] {
    'Solaris': { 
         include role::solaris 
    }
    'RedHat', 'CentOS':  {
         include role::redhat
    }
    /^(Debian|Ubuntu)$/:  {
         include role::debian  
    }
    Default:  {
         include role::generic 
    }
}

{{}}

Henrik Lindberg (Jira)

unread,
Sep 11, 2020, 6:14:04 PM9/11/20
to puppe...@googlegroups.com

The intention was probably to have this (with a lower case default:

case $facts['os']['name'] {
    'Solaris': { 
         include role::solaris 
    }
    'RedHat', 'CentOS':  {
         include role::redhat
    }
    /^(Debian|Ubuntu)$/:  {
         include role::debian  
    }
    default:  {
         include role::generic 
    }
}

Because while an upper case Default as the last case option is not illegal it means something completely different. The lower case default means "take this option if none of the other matches", and the upper case Default means "take this option if the fact "os.name" is set to an instance of the Default data type" - and that does not make sense as the name of the os will never be an instance of that data type. The only way to hit such an option is to do something like this:

$x = default  # yes, default is a value that can be assigned
case $x {
  "some string": { notice("it is the string 'some string') }
  Default:  { notice("it is a literal default") }
  default: { notice("it is something else") }
}

So... just change it to a lower case default to make the example make sense.

That you can do matching of values against data types is a valuable feature but it is not what the example in the doc is about.

Hope that helps...

Henrik Lindberg (Jira)

unread,
Sep 11, 2020, 6:22:03 PM9/11/20
to puppe...@googlegroups.com

There should be more examples showing those other types of matches.

 case $x {
   Integer: { ... }              # x is an Integer value
  String[10]: { ...}            # x is a string 10 or more chars long
  String: { ... }                 # x is a string short than 10 (since option above took the longer ones}case [$x, $y] {  [String, Integer]: { ... } # x is String and y is an Integer  [10, "hello"]: { ... }       # x is the integer 10, and y the string "hello"  [1, default]: { ... }        # x is the integer 1, and y can be any value (could also have been written Any)}

if that is not already in the documentation, it should be.

 

Claire Cadman (Jira)

unread,
Sep 14, 2020, 5:41:04 AM9/14/20
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Sep 14, 2020, 5:42:04 AM9/14/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages