mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #56598 from leifliddy/master
correct formatting issue with highstate output module
This commit is contained in:
commit
62458e4e7e
2 changed files with 28 additions and 6 deletions
|
@ -186,13 +186,18 @@ def _format_host(host, data, indent_level=1):
|
|||
nchanges = 0
|
||||
strip_colors = __opts__.get("strip_colors", True)
|
||||
|
||||
if isinstance(data, int) or isinstance(data, six.string_types):
|
||||
# Data in this format is from saltmod.function,
|
||||
# so it is always a 'change'
|
||||
if isinstance(data, int):
|
||||
nchanges = 1
|
||||
hstrs.append(("{0} {1}{2[ENDC]}".format(hcolor, data, colors)))
|
||||
hcolor = colors["CYAN"] # Print the minion name in cyan
|
||||
if isinstance(data, list):
|
||||
elif isinstance(data, six.string_types):
|
||||
# Data in this format is from saltmod.function,
|
||||
# so it is always a 'change'
|
||||
nchanges = 1
|
||||
for data in data.splitlines():
|
||||
hstrs.append(("{0} {1}{2[ENDC]}".format(hcolor, data, colors)))
|
||||
hcolor = colors["CYAN"] # Print the minion name in cyan
|
||||
elif isinstance(data, list):
|
||||
# Errors have been detected, list them in RED!
|
||||
hcolor = colors["LIGHT_RED"]
|
||||
hstrs.append((" {0}Data failed to compile:{1[ENDC]}".format(hcolor, colors)))
|
||||
|
@ -202,7 +207,7 @@ def _format_host(host, data, indent_level=1):
|
|||
hstrs.append(
|
||||
("{0}----------\n {1}{2[ENDC]}".format(hcolor, err, colors))
|
||||
)
|
||||
if isinstance(data, dict):
|
||||
elif isinstance(data, dict):
|
||||
# Verify that the needed data is present
|
||||
data_tmp = {}
|
||||
for tname, info in six.iteritems(data):
|
||||
|
|
|
@ -80,7 +80,22 @@ class JsonTestCase(TestCase, LoaderModuleMockMixin):
|
|||
"name": "call_sleep_state",
|
||||
"result": True,
|
||||
"start_time": "15:35:29.762657",
|
||||
}
|
||||
},
|
||||
"salt_|-cmd_run_example_|-cmd.run_|-function": {
|
||||
"__id__": "cmd_run_example",
|
||||
"__jid__": "20200411195112288850",
|
||||
"__run_num__": 1,
|
||||
"__sls__": "orch.simple",
|
||||
"changes": {
|
||||
"out": "highstate",
|
||||
"ret": {"minion": "file1\nfile2\nfile3"},
|
||||
},
|
||||
"comment": "Function ran successfully. Function cmd.run ran on minion.",
|
||||
"duration": 412.397,
|
||||
"name": "cmd.run",
|
||||
"result": True,
|
||||
"start_time": "21:51:12.185868",
|
||||
},
|
||||
}
|
||||
},
|
||||
"outputter": "highstate",
|
||||
|
@ -93,6 +108,7 @@ class JsonTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self.assertIn("Succeeded: 1 (changed=1)", ret)
|
||||
self.assertIn("Failed: 0", ret)
|
||||
self.assertIn("Total states run: 1", ret)
|
||||
self.assertIn(" file2", ret)
|
||||
|
||||
def test_output_comment_is_not_unicode(self):
|
||||
entry = None
|
||||
|
@ -117,6 +133,7 @@ class JsonTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self.assertIn("Succeeded: 1 (changed=1)", ret)
|
||||
self.assertIn("Failed: 0", ret)
|
||||
self.assertIn("Total states run: 1", ret)
|
||||
self.assertIn(" file2", ret)
|
||||
|
||||
|
||||
# this should all pass the above tests
|
||||
|
|
Loading…
Add table
Reference in a new issue