Skip to content

Commit

Permalink
add json for all salt modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mchugh19 committed Apr 18, 2020
1 parent cddb31e commit 972116b
Show file tree
Hide file tree
Showing 151 changed files with 5,167 additions and 625 deletions.
16 changes: 5 additions & 11 deletions generate_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,18 @@ def _add_all_snippets(states):
print("All states present in package.json")

local = salt.client.Caller()

states = local.cmd('sys.list_state_modules')
state_functions = local.cmd('sys.list_state_functions')
state_info = local.cmd('baredoc.list_states', names_only=True)
function_blacklist = ['mod_watch']

any_updates = False

for state in states:
for state in state_info:

# Build list of functions for state
current_functions = []
state_path = os.path.join('snippets', state + '.json')
for function in state_functions:
if function.startswith('{}.'.format(state)):
for blacklist in function_blacklist:
# Don't include mod_watch functions as these aren't used in state files
if '{}.{}'.format(state, blacklist) not in function:
current_functions.append(function[len('{}.'.format(state)):])
# Don't include mod_watch functions as these aren't used in state files
current_functions = list(set(state_info[state]) - set(function_blacklist))
snippets = _gen_snippet(state, current_functions)

if not os.path.exists(state_path):
Expand All @@ -102,4 +96,4 @@ def _add_all_snippets(states):

if not any_updates:
print('No changes made to snippet files')
_add_all_snippets(states)
_add_all_snippets(sorted(state_info.keys()))
Loading

0 comments on commit 972116b

Please sign in to comment.