Fixed edge case in function for base class name

In the instance of calling the class snippet within a puppet file
located in /home/pjfoley/puppet/modules/profile/manifests/init.pp

I would expect the return value to be "profile", it currently returns
"profile::"

The extra "::" is a bug and puppet compilation fails with the message
"Syntax error at ':'
This commit is contained in:
Peter Foley 2013-06-29 16:54:05 +10:00
parent bd18cd76d7
commit 5263affdde

View File

@ -28,6 +28,9 @@ def get_module_namespace_and_basename():
parts = os.path.split(parts[0])
continue
if parts[1] == 'manifests':
if not namespace:
return os.path.split(parts[0])[1]
else:
return os.path.split(parts[0])[1] + '::' + namespace.rstrip(':')
else:
namespace = parts[1] + '::' + namespace