From 8f8aeab690293a4ffdc0c7516ec6b501a85fe42e Mon Sep 17 00:00:00 2001 From: jmaeng72 <44305062+jmaeng72@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:54:01 -0500 Subject: [PATCH] add feature toggle --- ingest-app/src/cmr/ingest/api/collections.clj | 15 ++++++++++++--- ingest-app/src/cmr/ingest/config.clj | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ingest-app/src/cmr/ingest/api/collections.clj b/ingest-app/src/cmr/ingest/api/collections.clj index f1cab60af3..e4e0a75bd3 100644 --- a/ingest-app/src/cmr/ingest/api/collections.clj +++ b/ingest-app/src/cmr/ingest/api/collections.clj @@ -7,18 +7,27 @@ [cmr.common.log :refer [info]] [cmr.common.util :as util] [cmr.ingest.api.core :as api-core] + [cmr.ingest.config :as ingest-config] [cmr.ingest.services.ingest-service :as ingest])) (def VALIDATE_KEYWORDS_HEADER "cmr-validate-keywords") (def ENABLE_UMM_C_VALIDATION_HEADER "cmr-validate-umm-c") (def TESTING_EXISTING_ERRORS_HEADER "cmr-test-existing-errors") +(def validate-keywords-default-true-enabled? + "Checks to see if the feature toggle for validate-keywords-default-true is enabled." + (ingest-config/validate-keywords-default-true-enabled)) + (defn get-validation-options "Returns a map of validation options with boolean values" [headers] - {:validate-keywords? (if (= "false" (get headers VALIDATE_KEYWORDS_HEADER)) false true) - :validate-umm? (= "true" (get headers ENABLE_UMM_C_VALIDATION_HEADER)) - :test-existing-errors? (= "true" (get headers TESTING_EXISTING_ERRORS_HEADER))}) + (let [_ (println "validate-keywords-default-true-enabled = " validate-keywords-default-true-enabled?) + validate-keywords-value (if validate-keywords-default-true-enabled? + (if (= "false" (get headers VALIDATE_KEYWORDS_HEADER)) false true) + (= "true" (get headers VALIDATE_KEYWORDS_HEADER)))] + {:validate-keywords? validate-keywords-value + :validate-umm? (= "true" (get headers ENABLE_UMM_C_VALIDATION_HEADER)) + :test-existing-errors? (= "true" (get headers TESTING_EXISTING_ERRORS_HEADER))})) (defn validate-collection [provider-id native-id request] diff --git a/ingest-app/src/cmr/ingest/config.clj b/ingest-app/src/cmr/ingest/config.clj index 632e1cd795..471c8f42cb 100644 --- a/ingest-app/src/cmr/ingest/config.clj +++ b/ingest-app/src/cmr/ingest/config.clj @@ -7,6 +7,10 @@ [cmr.oracle.config :as oracle-config] [cmr.oracle.connection :as conn])) +(defconfig validate-keywords-default-true-enabled + "Flag for whether or not cmr-validate-keywords value is defaulted to true or false in backend when missing in ingest api headers" + {:default true :type Boolean}) + (defconfig progressive-update-enabled "Flag for whether or not collection progressive update is enabled." {:default true :type Boolean})