Issue #5041 has been updated by Joshua Lifton.

Assignee deleted (Paul Berry)

This issue was assigned to a former Puppet Labs employee. Adding back to the 
pool of unreviewed issues.
----------------------------------------
Feature #5041: Disallow autoloaded files from declaring things outside the 
namespace implied by their filenames
https://projects.puppetlabs.com/issues/5041

Author: Paul Berry
Status: Accepted
Priority: Normal
Assignee: 
Category: language
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


This ticket captures and elaborates on a decision made on the developer mailing 
list in late September (see email thread "PL RFC-1: Semantics of autoloaded 
classes").

The contents of autoloaded .pp files should be restricted as follows:

1. All classes defined in the file must have a name that matches the filename, 
or is nested within the namespace implied by the filename.  So, for example, a 
file foo.pp can contain classes called "foo", "foo::bar", "foo::bar::baz", or 
"foo::baz", but not "bar".

2. In files that are in subfolders, the portions of the path are joined by "::" 
to determine what classes are allowed.  So, for example, a file foo/bar.pp can 
contain classes called "foo::bar" or "foo::bar::baz", but not "foo" or 
"foo::baz".  Exception: class foo is allowed for the sole purpose of nesting 
(this allows constructions like "class foo { class bar { ... } }").

3. Defines and nodes follow similar rules, with the understanding that node 
names are not allowed to contain "::".

4. No toplevel constructs (resources, variable assignments, include statements, 
import statements, etc) are allowed in autoloaded modules.

5. In files that are autoloaded from modules, the module name is included in 
the path, but the subdirectory "manifests" is not.  So for example, the file 
$module_path/foo/manifests/bar.pp follows the same rules as foo/bar.pp.

6. In a module's init.pp file, "init" is not included in the path.  So for 
example, the file $module_path/foo/manifests/init.pp follows the same rules as 
foo.pp.

7. All of these rules are suspended if the file is imported explicitly using an 
"import" statement rather than autoloaded.

Because of the pervasive nature of this change, we plan to implement a 
deprecation warning in one release, to warn users of the impending change, and 
defer the actual change to a later release.  This ticket is for the actual 
change.  I'll file a separate ticket for adding the warning.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to