Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't complain about system prop and env config keys #2999

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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