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

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