Fixed edge case with multiple init directories
In the instance of calling the class snippet within a puppet file located in /home/pjfoley/puppet/modules/profile/manifests/server/init/init.pp I would expect the return value to be "profile::server::init", it currently returns "profile::server" which is missing a module path layer.
This commit is contained in:
parent
c5af015eb2
commit
fe4f784720
@ -14,17 +14,15 @@ def get_module_namespace_and_basename():
|
||||
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
|
||||
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
|
||||
"""
|
||||
first_time = True
|
||||
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
|
||||
if not current_file_path_without_ext:
|
||||
return "name"
|
||||
parts = os.path.split(current_file_path_without_ext)
|
||||
namespace = ''
|
||||
while parts[0] and parts[0] != '/':
|
||||
# Skip the init.pp files because they don't create a deeper namespace
|
||||
# and are special. Note this might break things like
|
||||
# modules/collectd/init/test.pp. But I am not even sure if puppet will
|
||||
# work for those.
|
||||
if parts[1] == 'init':
|
||||
if parts[1] == 'init' and first_time and not namespace:
|
||||
first_time = False
|
||||
parts = os.path.split(parts[0])
|
||||
continue
|
||||
if parts[1] == 'manifests':
|
||||
|
Loading…
x
Reference in New Issue
Block a user