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,24 +483,20 @@ class Compiler:
|
||||||
else:
|
else:
|
||||||
fun = 0
|
fun = 0
|
||||||
if "." in state:
|
if "." in state:
|
||||||
|
# This should not happen usually since `pad_funcs`
|
||||||
|
# is run on rendered templates
|
||||||
fun += 1
|
fun += 1
|
||||||
for arg in body[state]:
|
for arg in body[state]:
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
if "." in state:
|
fun += 1
|
||||||
|
if " " in arg.strip():
|
||||||
errors.append(
|
errors.append(
|
||||||
"Argument not formed as a dictionary in state "
|
f'The function "{arg}" in state '
|
||||||
f"'{name}' in SLS '{body['__sls__']}': '{arg}'"
|
f'"{name}" in SLS "{body["__sls__"]}" has '
|
||||||
|
"whitespace, a function with whitespace is "
|
||||||
|
"not supported, perhaps this is an argument"
|
||||||
|
' that is missing a ":"'
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
fun += 1
|
|
||||||
if " " in arg.strip():
|
|
||||||
errors.append(
|
|
||||||
f'The function "{arg}" in state '
|
|
||||||
f'"{name}" in SLS "{body["__sls__"]}" has '
|
|
||||||
"whitespace, a function with whitespace is "
|
|
||||||
"not supported, perhaps this is an argument"
|
|
||||||
' that is missing a ":"'
|
|
||||||
)
|
|
||||||
elif isinstance(arg, dict):
|
elif isinstance(arg, dict):
|
||||||
# The arg is a dict, if the arg is require or
|
# The arg is a dict, if the arg is require or
|
||||||
# watch, it must be a list.
|
# watch, it must be a list.
|
||||||
|
@ -595,17 +591,22 @@ class Compiler:
|
||||||
if state == "require" or state == "watch":
|
if state == "require" or state == "watch":
|
||||||
continue
|
continue
|
||||||
errors.append(
|
errors.append(
|
||||||
"No function declared in state '{}' in SLS '{}'".format(
|
f"No function declared in state '{name}' in SLS "
|
||||||
state, body["__sls__"]
|
f"'{body['__sls__']}'"
|
||||||
)
|
|
||||||
)
|
)
|
||||||
elif fun > 1:
|
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(
|
errors.append(
|
||||||
f"Too many functions declared in state '{state}' in "
|
f"Too many functions declared in state '{name}' in "
|
||||||
f"SLS '{body['__sls__']}'. Please choose one of the following: "
|
f"SLS '{body['__sls__']}'. Please choose one of "
|
||||||
+ ", ".join(
|
"the following: " + ", ".join(funs)
|
||||||
arg for arg in body[state] if isinstance(arg, str)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
@ -1513,24 +1514,20 @@ class State:
|
||||||
else:
|
else:
|
||||||
fun = 0
|
fun = 0
|
||||||
if "." in state:
|
if "." in state:
|
||||||
|
# This should not happen usually since `_handle_state_decls`
|
||||||
|
# is run on rendered templates
|
||||||
fun += 1
|
fun += 1
|
||||||
for arg in body[state]:
|
for arg in body[state]:
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
if "." in state:
|
fun += 1
|
||||||
|
if " " in arg.strip():
|
||||||
errors.append(
|
errors.append(
|
||||||
"Argument not formed as a dictionary in state "
|
f'The function "{arg}" in state '
|
||||||
f"'{name}' in SLS '{body['__sls__']}': '{arg}'"
|
f'"{name}" in SLS "{body["__sls__"]}" has '
|
||||||
|
"whitespace, a function with whitespace is "
|
||||||
|
"not supported, perhaps this is an argument"
|
||||||
|
' that is missing a ":"'
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
fun += 1
|
|
||||||
if " " in arg.strip():
|
|
||||||
errors.append(
|
|
||||||
f'The function "{arg}" in state '
|
|
||||||
f'"{name}" in SLS "{body["__sls__"]}" has '
|
|
||||||
"whitespace, a function with whitespace is "
|
|
||||||
"not supported, perhaps this is an argument"
|
|
||||||
' that is missing a ":"'
|
|
||||||
)
|
|
||||||
|
|
||||||
elif isinstance(arg, dict):
|
elif isinstance(arg, dict):
|
||||||
# The arg is a dict, if the arg is require or
|
# The arg is a dict, if the arg is require or
|
||||||
|
@ -1624,17 +1621,16 @@ class State:
|
||||||
if state == "require" or state == "watch":
|
if state == "require" or state == "watch":
|
||||||
continue
|
continue
|
||||||
errors.append(
|
errors.append(
|
||||||
"No function declared in state '{}' in SLS '{}'".format(
|
f"No function declared in state '{name}' in SLS "
|
||||||
state, body["__sls__"]
|
f"'{body['__sls__']}'"
|
||||||
)
|
|
||||||
)
|
)
|
||||||
elif fun > 1:
|
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(
|
errors.append(
|
||||||
f"Too many functions declared in state '{state}' in "
|
f"Too many functions declared in state '{name}' in "
|
||||||
f"SLS '{body['__sls__']}'. Please choose one of the following: "
|
f"SLS '{body['__sls__']}'. Please choose one of "
|
||||||
+ ", ".join(
|
"the following: " + ", ".join(funs)
|
||||||
arg for arg in body[state] if isinstance(arg, str)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return errors
|
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",
|
"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"]}},
|
{"/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"]}},
|
{"/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