Blob Blame History Raw
From 663ae08a2374df76e93d007551fa5e143425d064 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcritten@redhat.com>
Date: Thu, 28 Apr 2022 08:33:35 -0400
Subject: Validate that a known output-type has been selected

A user may pass an unknown value in via the configuration file.

https://bugzilla.redhat.com/show_bug.cgi?id=2079698

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
---
 src/ipahealthcheck/core/constants.py | 2 --
 src/ipahealthcheck/core/core.py      | 5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/ipahealthcheck/core/constants.py b/src/ipahealthcheck/core/constants.py
index b6ee029..806bd46 100644
--- a/src/ipahealthcheck/core/constants.py
+++ b/src/ipahealthcheck/core/constants.py
@@ -2,8 +2,6 @@
 # Copyright (C) 2019 FreeIPA Contributors see COPYING for license
 #
 
-DEFAULT_OUTPUT = 'json'
-
 # Error reporting result
 SUCCESS = 0
 WARNING = 10
diff --git a/src/ipahealthcheck/core/core.py b/src/ipahealthcheck/core/core.py
index 092bab9..84aa8a4 100644
--- a/src/ipahealthcheck/core/core.py
+++ b/src/ipahealthcheck/core/core.py
@@ -256,7 +256,7 @@ class RunChecks:
     def run_healthcheck(self):
         framework = object()
         plugins = []
-        output = constants.DEFAULT_OUTPUT
+        output = None
 
         logger.setLevel(logging.WARNING)
 
@@ -334,6 +334,9 @@ class RunChecks:
             if out.__name__.lower() == options.output_type:
                 output = out(options)
                 break
+        if output is None:
+            print(f"Unknown output-type '{options.output_type}'")
+            return 1
 
         if options.list_sources:
             return list_sources(plugins)
-- 
2.31.1