Blame SOURCES/0027-Validate-that-a-known-output-type-has-been-selected.patch

70e617
From 663ae08a2374df76e93d007551fa5e143425d064 Mon Sep 17 00:00:00 2001
70e617
From: Rob Crittenden <rcritten@redhat.com>
70e617
Date: Thu, 28 Apr 2022 08:33:35 -0400
70e617
Subject: Validate that a known output-type has been selected
70e617
70e617
A user may pass an unknown value in via the configuration file.
70e617
70e617
https://bugzilla.redhat.com/show_bug.cgi?id=2079698
70e617
70e617
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
70e617
---
70e617
 src/ipahealthcheck/core/constants.py | 2 --
70e617
 src/ipahealthcheck/core/core.py      | 5 ++++-
70e617
 2 files changed, 4 insertions(+), 3 deletions(-)
70e617
70e617
diff --git a/src/ipahealthcheck/core/constants.py b/src/ipahealthcheck/core/constants.py
70e617
index b6ee029..806bd46 100644
70e617
--- a/src/ipahealthcheck/core/constants.py
70e617
+++ b/src/ipahealthcheck/core/constants.py
70e617
@@ -2,8 +2,6 @@
70e617
 # Copyright (C) 2019 FreeIPA Contributors see COPYING for license
70e617
 #
70e617
 
70e617
-DEFAULT_OUTPUT = 'json'
70e617
-
70e617
 # Error reporting result
70e617
 SUCCESS = 0
70e617
 WARNING = 10
70e617
diff --git a/src/ipahealthcheck/core/core.py b/src/ipahealthcheck/core/core.py
70e617
index 092bab9..84aa8a4 100644
70e617
--- a/src/ipahealthcheck/core/core.py
70e617
+++ b/src/ipahealthcheck/core/core.py
70e617
@@ -256,7 +256,7 @@ class RunChecks:
70e617
     def run_healthcheck(self):
70e617
         framework = object()
70e617
         plugins = []
70e617
-        output = constants.DEFAULT_OUTPUT
70e617
+        output = None
70e617
 
70e617
         logger.setLevel(logging.WARNING)
70e617
 
70e617
@@ -334,6 +334,9 @@ class RunChecks:
70e617
             if out.__name__.lower() == options.output_type:
70e617
                 output = out(options)
70e617
                 break
70e617
+        if output is None:
70e617
+            print(f"Unknown output-type '{options.output_type}'")
70e617
+            return 1
70e617
 
70e617
         if options.list_sources:
70e617
             return list_sources(plugins)
70e617
-- 
70e617
2.31.1
70e617