forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): add feature gates functionality for the first time IQ…
- Loading branch information
1 parent
861b93c
commit f5862e3
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/edu/harvard/iq/dataverse/settings/FeatureGates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package edu.harvard.iq.dataverse.settings; | ||
|
||
/** | ||
* <p>This enum holds so-called "feature gates" aka "feature flags". It can be used throughout the application | ||
* to avoid activating or using experimental functionality or feature previews that are opt-in.</p> | ||
* | ||
* <p>The current implementation reuses {@link JvmSettings} to interpret any | ||
* <a href="https://download.eclipse.org/microprofile/microprofile-config-3.0/microprofile-config-spec-3.0.html#_built_in_converters">boolean values</a> | ||
* (true == case-insensitive one of "true", "1", "YES", "Y", "ON") and hook into the usual settings system | ||
* (any MicroProfile Config Source available).</p> | ||
* | ||
* If you add any new gates, please add a setting in JvmSettings, think of a default status, add some Javadocs | ||
* about the gated feature and add a "@since" tag to make it easier to identify when a gate has been introduced. | ||
* | ||
*/ | ||
public enum FeatureGates { | ||
|
||
/** | ||
* Enabling will unblock access to the API with an OIDC access token in addition to other available methods. | ||
* @apiNote Open gate by setting "dataverse.feature.api-oidc-access" | ||
* @since Dataverse 5.13 | ||
* @see JvmSettings#GATE_API_OIDC_ACCESS | ||
*/ | ||
API_OIDC_ACCESS(JvmSettings.GATE_API_OIDC_ACCESS, false), | ||
|
||
; | ||
|
||
final JvmSettings setting; | ||
final boolean defaultStatus; | ||
|
||
FeatureGates(JvmSettings setting, boolean defaultStatus) { | ||
this.setting = setting; | ||
this.defaultStatus = defaultStatus; | ||
} | ||
|
||
public boolean enabled() { | ||
return setting.lookupOptional(Boolean.class).orElse(defaultStatus); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters