rebase to 4.20

This commit is contained in:
Pearl Dsilva 2026-01-14 14:54:53 -05:00
parent 5c1f9315ce
commit 7707ca5776
2 changed files with 27 additions and 3 deletions

View File

@ -118,7 +118,7 @@ public interface QueryService {
ConfigKey<String> UserVMReadOnlyDetails = new ConfigKey<>(String.class, ConfigKey<String> UserVMReadOnlyDetails = new ConfigKey<>(String.class,
"user.vm.readonly.details", "Advanced", "dataDiskController, rootDiskController", "user.vm.readonly.details", "Advanced", "dataDiskController, rootDiskController",
"List of read-only VM settings/details as comma separated string", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null); "List of read-only VM settings/details as comma separated string", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null, "");
ConfigKey<Boolean> SortKeyAscending = new ConfigKey<>("Advanced", Boolean.class, "sortkey.algorithm", "true", ConfigKey<Boolean> SortKeyAscending = new ConfigKey<>("Advanced", Boolean.class, "sortkey.algorithm", "true",
"Sort algorithm - ascending or descending - to use. For entities that use sort key(template, disk offering, service offering, " + "Sort algorithm - ascending or descending - to use. For entities that use sort key(template, disk offering, service offering, " +

View File

@ -120,10 +120,18 @@ public class ConfigKey<T> {
static ConfigDepotImpl s_depot = null; static ConfigDepotImpl s_depot = null;
static public void init(ConfigDepotImpl depot) { private String _defaultValueIfEmpty = null;
public static void init(ConfigDepotImpl depot) {
s_depot = depot; s_depot = depot;
} }
public ConfigKey(Class<T> type, String name, String category, String defaultValue, String description, boolean isDynamic, Scope scope, T multiplier,
String displayText, String parent, Ternary<String, String, Long> group, Pair<String, Long> subGroup, Kind kind, String options, String defaultValueIfEmpty) {
this(type, name, category, defaultValue, description, isDynamic, scope, multiplier, displayText, parent, group, subGroup, kind, options);
this._defaultValueIfEmpty = defaultValueIfEmpty;
}
public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, Scope scope) { public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, Scope scope) {
this(type, name, category, defaultValue, description, isDynamic, scope, null); this(type, name, category, defaultValue, description, isDynamic, scope, null);
} }
@ -216,7 +224,19 @@ public class ConfigKey<T> {
public T value() { public T value() {
if (_value == null || isDynamic()) { if (_value == null || isDynamic()) {
String value = s_depot != null ? s_depot.getConfigStringValue(_name, Scope.Global, null) : null; String value = s_depot != null ? s_depot.getConfigStringValue(_name, Scope.Global, null) : null;
_value = valueOf((value == null) ? defaultValue() : value);
String effective;
if (value != null) {
if (value.isEmpty() && _defaultValueIfEmpty != null) {
effective = _defaultValueIfEmpty;
} else {
effective = value;
}
} else {
effective = _defaultValueIfEmpty != null ? _defaultValueIfEmpty : defaultValue();
}
_value = valueOf(effective);
} }
return _value; return _value;
@ -231,6 +251,10 @@ public class ConfigKey<T> {
if (value == null) { if (value == null) {
return value(); return value();
} }
if (value.isEmpty() && _defaultValueIfEmpty != null) {
return valueOf(_defaultValueIfEmpty);
}
return valueOf(value); return valueOf(value);
} }