Skip to content

Commit

Permalink
add feature toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaeng72 committed Dec 19, 2024
1 parent 390d975 commit 8f8aeab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ingest-app/src/cmr/ingest/api/collections.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions ingest-app/src/cmr/ingest/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 8f8aeab

Please sign in to comment.