diff --git a/salt/manager/tools/sbin/so-yaml.py b/salt/manager/tools/sbin/so-yaml.py index 3558e57d8..598948119 100755 --- a/salt/manager/tools/sbin/so-yaml.py +++ b/salt/manager/tools/sbin/so-yaml.py @@ -346,7 +346,9 @@ def get(args): print(f"Key '{key}' not found by so-yaml.py", file=sys.stderr) return 2 - if isinstance(output, (dict, list)): + if isinstance(output, bool): + print(str(output).lower()) + elif isinstance(output, (dict, list)): print(yaml.safe_dump(output).strip()) else: print(output) diff --git a/salt/manager/tools/sbin/so-yaml_test.py b/salt/manager/tools/sbin/so-yaml_test.py index d48136bf4..b829108a0 100644 --- a/salt/manager/tools/sbin/so-yaml_test.py +++ b/salt/manager/tools/sbin/so-yaml_test.py @@ -406,6 +406,17 @@ class TestRemove(unittest.TestCase): self.assertEqual(result, 0) self.assertEqual("hello\n", mock_stdout.getvalue()) + def test_get_bool(self): + with patch('sys.stdout', new=StringIO()) as mock_stdout: + filename = "/tmp/so-yaml_test-get.yaml" + file = open(filename, "w") + file.write("{key1: { child1: 123, child2: { deep1: 45 } }, key2: false, key3: [e,f,g]}") + file.close() + + result = soyaml.get([filename, "key2"]) + self.assertEqual(result, 0) + self.assertEqual("false\n", mock_stdout.getvalue()) + def test_get_list(self): with patch('sys.stdout', new=StringIO()) as mock_stdout: filename = "/tmp/so-yaml_test-get.yaml"