Skip to content

Commit

Permalink
Merge pull request #2999 from CSCfi/fix-unrecognized-keys
Browse files Browse the repository at this point in the history
fix: don't complain about system prop and env config keys
  • Loading branch information
Macroz committed Sep 8, 2022
2 parents f33e9e3 + 74224db commit f7048c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ have notable changes.

### Fixes
- License, create/edit license and create/edit catalogue item administrator views have been updated to display localized fields the same way other administrator views do. (#1334)
- Don't needlessly complain about the config keys that are passed automatically from system properties and the environment. (#2935)

Changes since v2.28

Expand Down
15 changes: 12 additions & 3 deletions src/clj/rems/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@
:email-retry-period "P20d"
:disable-commands ["application.command/close" "application.command/reject"]}))))

(def known-config-keys
(defn known-config-keys []
(set (keys (load-config :resource "config-defaults.edn"))))

(defn env-config-keys []
(set (keys (source/from-env))))

(defn system-properties-keys []
(set (keys (source/from-system-props))))

;; if we start doing more thorough validation, could use a schema instead
(defn- validate-config [config]
(when-let [url (:public-url config)]
Expand All @@ -74,8 +80,11 @@
":"
(pr-str invalid-events))
(log/warn "Supported event types:" (pr-str events/event-types))))
(when-let [invalid-keys (seq (remove known-config-keys (keys config)))]
(log/warn "Unrecognized config keys: " (pr-str invalid-keys)))
(when-let [unrecognized-keys (seq (->> (keys config)
(remove (known-config-keys))
(remove (system-properties-keys)) ; don't complain about system properties
(remove (env-config-keys))))] ; don't complain about environment
(log/warn "Unrecognized config keys: " (pr-str unrecognized-keys)))
config)

(defstate env :start (-> (load-config :resource "config-defaults.edn"
Expand Down

0 comments on commit f7048c6

Please sign in to comment.