Bug #4428

resource titles should allow "::" without requiring quoting for parameterized class declaration

Added by Stefan Schimanski almost 2 years ago. Updated 10 months ago.

Status:Accepted Start date:07/31/2010
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:parser
Target version:2.7.x
Affected Puppet version: Branch:
Keywords:parameterized classes
namespaces
parser
parameterized_classes
Votes: 1

Description

Consider a namespace with a parameterized class:

class bla {
  class foo {
  }
  class bar ($x=42) {
    notify { "x = $x": }
  }
}

To include the nested class into a node one would write:

node default {
  include bla::foo
  class { bla::bar: x => 42 }
}

which does not work as bla::bar is not a allowed symbol by the parser. You have to quote it:

node default {
  include bla::foo
  class { "bla::bar": x => 42 }
}

IMHO, Using the title attribute is very strange with this odd syntax as a consequence. Why isn’t there something like:

include bla::foo { x => 42 }

?

History

Updated by Jesse Wolfe almost 2 years ago

  • Status changed from Unreviewed to In Topic Branch Pending Review
  • Assignee set to Jesse Wolfe
  • Target version set to 2.6.1

This is probbly fixed – can you test when we release the next RC please.

Updated by Jesse Wolfe almost 2 years ago

  • Status changed from In Topic Branch Pending Review to Needs Decision
  • Target version changed from 2.6.1 to 52

(is that last comment really from me? I don’t think I wrote that.)

There’s currently a parser limitation that unquoted resource titles cannot have colons.
This is counter-intuitive, in the case of namespaced class names as titles in the class instantiation syntax.
Actually, I might expect string-quoted class names to be fully qualified, while unquoted classes might be looked up in the current namespace.
I see room for debate about this, so I’m marking it “needs design decision”

Updated by Paul Berry over 1 year ago

  • Keywords changed from parameterized classes namespaces parser to parameterized classes namespaces parser parameterized_classes

Updated by James Turnbull about 1 year ago

  • Assignee changed from Jesse Wolfe to Nigel Kersten

Updated by James Turnbull about 1 year ago

  • Target version deleted (52)

Updated by Chad Metcalf about 1 year ago

This bit me today. At a minimum the docs should probably reflect this as it strikes me as a pretty common case and a non intuitive answer.

A nice to have would be a better error msg.

Could not parse for environment production: Syntax error at 'some::client::params'; expected '}' 

Is pretty generic and sends me looking for missing : or , just because its what I’m used to.

Updated by Nigel Kersten about 1 year ago

  • Status changed from Needs Decision to Accepted
  • Assignee deleted (Nigel Kersten)
  • Target version set to 2.7.1

We should be allowing “::” in the title name.

Updated by Nigel Kersten about 1 year ago

  • Subject changed from Parameterized classes in namespaces result in strange syntax in nodes to resource titles should allow "::" without requiring quoting for parameterized class declaration

Updated by Michael Stahnke 10 months ago

  • Target version changed from 2.7.1 to 2.7.x

Also available in: Atom PDF