Merge pull request #85 from pjfoley/hotfix/init_edge_case
Hotfix/init edge case for puppet snippets.
This commit is contained in:
commit
e2ef47623e
@ -14,21 +14,19 @@ def get_module_namespace_and_basename():
|
|||||||
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
|
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
|
||||||
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
|
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
|
||||||
"""
|
"""
|
||||||
|
first_time = True
|
||||||
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
|
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
|
||||||
if not current_file_path_without_ext:
|
if not current_file_path_without_ext:
|
||||||
return "name"
|
return "name"
|
||||||
parts = os.path.split(current_file_path_without_ext)
|
parts = os.path.split(current_file_path_without_ext)
|
||||||
namespace = ''
|
namespace = ''
|
||||||
while parts[0] and parts[0] != '/':
|
while parts[0] and parts[0] != '/':
|
||||||
# Skip the init.pp files because they don't create a deeper namespace
|
if parts[1] == 'init' and first_time and not namespace:
|
||||||
# and are special. Note this might break things like
|
first_time = False
|
||||||
# modules/collectd/init/test.pp. But I am not even sure if puppet will
|
|
||||||
# work for those.
|
|
||||||
if parts[1] == 'init':
|
|
||||||
parts = os.path.split(parts[0])
|
parts = os.path.split(parts[0])
|
||||||
continue
|
continue
|
||||||
if parts[1] == 'manifests':
|
if parts[1] == 'manifests':
|
||||||
return os.path.split(parts[0])[1] + '::' + namespace.rstrip(':')
|
return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':')
|
||||||
else:
|
else:
|
||||||
namespace = parts[1] + '::' + namespace
|
namespace = parts[1] + '::' + namespace
|
||||||
parts = os.path.split(parts[0])
|
parts = os.path.split(parts[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user