mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Remove new err msg again. Report state ID, not module
This commit is contained in:
parent
a35e60dd72
commit
f79cee6075
3 changed files with 41 additions and 45 deletions
|
@ -483,15 +483,11 @@ class Compiler:
|
|||
else:
|
||||
fun = 0
|
||||
if "." in state:
|
||||
# This should not happen usually since `pad_funcs`
|
||||
# is run on rendered templates
|
||||
fun += 1
|
||||
for arg in body[state]:
|
||||
if isinstance(arg, str):
|
||||
if "." in state:
|
||||
errors.append(
|
||||
"Argument not formed as a dictionary in state "
|
||||
f"'{name}' in SLS '{body['__sls__']}': '{arg}'"
|
||||
)
|
||||
else:
|
||||
fun += 1
|
||||
if " " in arg.strip():
|
||||
errors.append(
|
||||
|
@ -595,17 +591,22 @@ class Compiler:
|
|||
if state == "require" or state == "watch":
|
||||
continue
|
||||
errors.append(
|
||||
"No function declared in state '{}' in SLS '{}'".format(
|
||||
state, body["__sls__"]
|
||||
)
|
||||
f"No function declared in state '{name}' in SLS "
|
||||
f"'{body['__sls__']}'"
|
||||
)
|
||||
elif fun > 1:
|
||||
errors.append(
|
||||
f"Too many functions declared in state '{state}' in "
|
||||
f"SLS '{body['__sls__']}'. Please choose one of the following: "
|
||||
+ ", ".join(
|
||||
funs = (
|
||||
[state.split(".", maxsplit=1)[1]]
|
||||
if "." in state
|
||||
else []
|
||||
)
|
||||
funs.extend(
|
||||
arg for arg in body[state] if isinstance(arg, str)
|
||||
)
|
||||
errors.append(
|
||||
f"Too many functions declared in state '{name}' in "
|
||||
f"SLS '{body['__sls__']}'. Please choose one of "
|
||||
"the following: " + ", ".join(funs)
|
||||
)
|
||||
return errors
|
||||
|
||||
|
@ -1513,15 +1514,11 @@ class State:
|
|||
else:
|
||||
fun = 0
|
||||
if "." in state:
|
||||
# This should not happen usually since `_handle_state_decls`
|
||||
# is run on rendered templates
|
||||
fun += 1
|
||||
for arg in body[state]:
|
||||
if isinstance(arg, str):
|
||||
if "." in state:
|
||||
errors.append(
|
||||
"Argument not formed as a dictionary in state "
|
||||
f"'{name}' in SLS '{body['__sls__']}': '{arg}'"
|
||||
)
|
||||
else:
|
||||
fun += 1
|
||||
if " " in arg.strip():
|
||||
errors.append(
|
||||
|
@ -1624,17 +1621,16 @@ class State:
|
|||
if state == "require" or state == "watch":
|
||||
continue
|
||||
errors.append(
|
||||
"No function declared in state '{}' in SLS '{}'".format(
|
||||
state, body["__sls__"]
|
||||
)
|
||||
f"No function declared in state '{name}' in SLS "
|
||||
f"'{body['__sls__']}'"
|
||||
)
|
||||
elif fun > 1:
|
||||
funs = [state.split(".", maxsplit=1)[1]] if "." in state else []
|
||||
funs.extend(arg for arg in body[state] if isinstance(arg, str))
|
||||
errors.append(
|
||||
f"Too many functions declared in state '{state}' in "
|
||||
f"SLS '{body['__sls__']}'. Please choose one of the following: "
|
||||
+ ", ".join(
|
||||
arg for arg in body[state] if isinstance(arg, str)
|
||||
)
|
||||
f"Too many functions declared in state '{name}' in "
|
||||
f"SLS '{body['__sls__']}'. Please choose one of "
|
||||
"the following: " + ", ".join(funs)
|
||||
)
|
||||
return errors
|
||||
|
||||
|
|
|
@ -416,7 +416,7 @@ def test_compiler_verify_high_short_sls(minion_opts, tmp_path, high, exp):
|
|||
},
|
||||
[
|
||||
"The require statement in state 'add_test_2' in SLS '/srv/reactor/start.sls' needs to be formed as a list",
|
||||
"Argument not formed as a dictionary in state 'add_test_2' in SLS '/srv/reactor/start.sls': 'cmd.run'",
|
||||
"Too many functions declared in state 'add_test_2' in SLS '/srv/reactor/start.sls'. Please choose one of the following: cmd.run, cmd.run",
|
||||
],
|
||||
),
|
||||
(
|
||||
|
|
|
@ -1107,11 +1107,11 @@ def test_verify_onlyif_cmd_opts_exclude(minion_opts):
|
|||
(
|
||||
(
|
||||
{"/some/file": {"file.managed": ["source:salt://bla"]}},
|
||||
"Argument not formed as a dictionary",
|
||||
"Too many functions declared in state '/some/file' in SLS 'sls'. Please choose one of the following: managed, source:salt://bla",
|
||||
),
|
||||
(
|
||||
{"/some/file": {"file": ["managed", "source:salt://bla"]}},
|
||||
"Please choose one of the following: managed, source:salt",
|
||||
"Too many functions declared in state '/some/file' in SLS 'sls'. Please choose one of the following: managed, source:salt://bla",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue