From supported runtimes back to hidden

This commit is contained in:
andreaTP 2022-06-27 18:57:08 +01:00 committed by Bruno Oliveira da Silva
parent 006aea300d
commit e3ece8244f
9 changed files with 24 additions and 41 deletions

View file

@ -9,13 +9,13 @@ public class DatabaseOptions {
public static final Option<String> DB_DIALECT = new OptionBuilder<>("db-dialect", String.class)
.category(OptionCategory.DATABASE)
.runtimes(Option.Runtime.OPERATOR)
.hidden()
.buildTime(true)
.build();
public static final Option<String> DB_DRIVER = new OptionBuilder<>("db-driver", String.class)
.category(OptionCategory.DATABASE)
.runtimes(Option.Runtime.OPERATOR)
.hidden()
.defaultValue(Database.getDriver("dev-file", true).get())
.build();

View file

@ -24,7 +24,7 @@ public class HostnameOptions {
public static final Option HOSTNAME_STRICT_HTTPS = new OptionBuilder<>("hostname-strict-https", Boolean.class)
.category(OptionCategory.HOSTNAME)
.description("Forces URLs to use HTTPS. Only needed if proxy does not properly set the X-Forwarded-Proto header.")
.runtimes(Option.Runtime.OPERATOR)
.hidden()
.defaultValue(Boolean.TRUE)
.build();

View file

@ -80,12 +80,12 @@ public class LoggingOptions {
public static final Option<Boolean> LOG_CONSOLE_ENABLED = new OptionBuilder<>("log-console-enabled", Boolean.class)
.category(OptionCategory.LOGGING)
.runtimes(Collections.emptySet())
.hidden()
.build();
public static final Option LOG_FILE_ENABLED = new OptionBuilder<>("log-file-enabled", Boolean.class)
.category(OptionCategory.LOGGING)
.runtimes(Collections.emptySet())
.hidden()
.build();
public static final Option<File> LOG_FILE = new OptionBuilder<>("log-file", File.class)

View file

@ -8,8 +8,8 @@ public class MultiOption<T> extends Option<T> {
private final Class auxiliaryType;
public MultiOption(Class type, Class auxiliaryType, String key, OptionCategory category, Set supportedRuntimes, boolean buildTime, String description, Optional defaultValue, List expectedValues) {
super(type, key, category, supportedRuntimes, buildTime, description, defaultValue, expectedValues);
public MultiOption(Class type, Class auxiliaryType, String key, OptionCategory category, boolean hidden, boolean buildTime, String description, Optional defaultValue, List expectedValues) {
super(type, key, category, hidden, buildTime, description, defaultValue, expectedValues);
this.auxiliaryType = auxiliaryType;
}

View file

@ -6,26 +6,20 @@ import java.util.Set;
public class Option<T> {
public enum Runtime {
QUARKUS,
DOCS,
OPERATOR;
}
private final Class<T> type;
private final String key;
private final OptionCategory category;
private final Set<Runtime> supportedRuntimes;
private final boolean hidden;
private final boolean buildTime;
private final String description;
private final Optional<T> defaultValue;
private final List<String> expectedValues;
public Option(Class<T> type, String key, OptionCategory category, Set<Runtime> supportedRuntimes, boolean buildTime, String description, Optional<T> defaultValue, List<String> expectedValues) {
public Option(Class<T> type, String key, OptionCategory category, boolean hidden, boolean buildTime, String description, Optional<T> defaultValue, List<String> expectedValues) {
this.type = type;
this.key = key;
this.category = category;
this.supportedRuntimes = supportedRuntimes;
this.hidden = hidden;
this.buildTime = buildTime;
this.description = description;
this.defaultValue = defaultValue;
@ -36,9 +30,7 @@ public class Option<T> {
return type;
}
public Set<Runtime> getSupportedRuntimes() {
return supportedRuntimes;
}
public boolean isHidden() { return hidden; }
public boolean isBuildTime() {
return buildTime;
@ -67,7 +59,7 @@ public class Option<T> {
this.type,
this.key,
this.category,
this.supportedRuntimes,
this.hidden,
this.buildTime,
this.description,
Optional.ofNullable(defaultValue),

View file

@ -12,7 +12,7 @@ public class OptionBuilder<T> {
private final Class<T> auxiliaryType;
private final String key;
private OptionCategory category;
private Set<Option.Runtime> supportedRuntimes;
private boolean hidden;
private boolean build;
private String description;
private Optional<T> defaultValue;
@ -23,7 +23,7 @@ public class OptionBuilder<T> {
this.auxiliaryType = null;
this.key = key;
category = OptionCategory.GENERAL;
supportedRuntimes = Arrays.stream(Option.Runtime.values()).collect(Collectors.toSet());
hidden = false;
build = false;
description = null;
defaultValue = Boolean.class.equals(type) ? Optional.of((T) Boolean.FALSE) : Optional.empty();
@ -38,7 +38,7 @@ public class OptionBuilder<T> {
this.auxiliaryType = auxiliaryType;
this.key = key;
category = OptionCategory.GENERAL;
supportedRuntimes = Arrays.stream(Option.Runtime.values()).collect(Collectors.toSet());
hidden = false;
build = false;
description = null;
defaultValue = Boolean.class.equals(type) ? Optional.of((T) Boolean.FALSE) : Optional.empty();
@ -53,15 +53,8 @@ public class OptionBuilder<T> {
return this;
}
public OptionBuilder<T> runtimes(Option.Runtime ... runtimes) {
this.supportedRuntimes.clear();
this.supportedRuntimes.addAll(Arrays.asList(runtimes));
return this;
}
public OptionBuilder<T> runtimes(Set<Option.Runtime> runtimes) {
this.supportedRuntimes.clear();
this.supportedRuntimes.addAll(runtimes);
public OptionBuilder<T> hidden() {
this.hidden = true;
return this;
}
@ -112,9 +105,9 @@ public class OptionBuilder<T> {
public Option<T> build() {
if (auxiliaryType != null) {
return new MultiOption<T>(type, auxiliaryType, key, category, supportedRuntimes, build, description, defaultValue, expectedValues);
return new MultiOption<T>(type, auxiliaryType, key, category, hidden, build, description, defaultValue, expectedValues);
} else {
return new Option<T>(type, key, category, supportedRuntimes, build, description, defaultValue, expectedValues);
return new Option<T>(type, key, category, hidden, build, description, defaultValue, expectedValues);
}
}

View file

@ -22,7 +22,7 @@ public class StorageOptions {
public static final Option<Boolean> DEFAULT_PERSISTENCE_UNIT_ENABLED = new OptionBuilder<>("storage-default-persistence-unit-enabled", Boolean.class)
.category(OptionCategory.STORAGE)
.defaultValue(true)
.runtimes(Option.Runtime.OPERATOR)
.hidden()
.buildTime(true)
.build();

View file

@ -27,21 +27,21 @@ public class VaultOptions {
public static final Option VAULT_UNMAPPED = new OptionBuilder<>("vault-", String.class)
.category(OptionCategory.VAULT)
.description("Maps any vault option to their corresponding properties in quarkus-vault extension.")
.runtimes()
.hidden()
.buildTime(true)
.build();
public static final Option VAULT_URL = new OptionBuilder<>("vault-url", String.class)
.category(OptionCategory.VAULT)
.description("The vault server url.")
.runtimes()
.hidden()
.buildTime(true)
.build();
public static final Option VAULT_KV_PATHS = new OptionBuilder("vault-kv-paths", Map.class, String.class)
.category(OptionCategory.VAULT)
.description("A set of one or more key/value paths that should be used when looking up secrets.")
.runtimes()
.hidden()
.build();
public static final List<Option<?>> ALL_OPTIONS = new ArrayList<>();

View file

@ -163,9 +163,7 @@ public class PropertyMapper<T> {
return this.option.getCategory();
}
public boolean isHidden() {
return !this.option.getSupportedRuntimes().contains(Option.Runtime.QUARKUS);
}
public boolean isHidden() { return this.option.isHidden(); }
public boolean isBuildTime() {
return this.option.isBuildTime();