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

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