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

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