Skip to content

Change the value parameter of the updateConfiguration API to be required #10790

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class UpdateCfgCmd extends BaseCmd {
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the configuration")
private String cfgName;

@Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, description = "the value of the configuration", length = 4096)
@Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, required = true, description = "the value of the configuration", length = 4096)
private String value;

@Parameter(name = ApiConstants.ZONE_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,6 @@ public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidP
throw new CloudRuntimeException("Only Root Admin is allowed to edit this configuration.");
}

if (value == null) {
return _configDao.findByName(name);
}

String scope = null;
Long id = null;
int paramCountCheck = 0;
Expand Down
19 changes: 19 additions & 0 deletions ui/src/views/setting/ConfigurationValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ export default {
if (configrecord.type === 'WhitespaceSeparatedListWithOptions') {
newValue = newValue.join(' ')
}

// The updateConfiguration API expects a blank string to clean up the configuration value
if (
(['CSV', 'Order', 'WhitespaceSeparatedListWithOptions', 'String'].includes(configrecord.type) && newValue.length === 0)
) {
newValue = ' '
}

const params = {
[this.scopeKey]: this.$route.params?.id,
name: configrecord.name,
Expand Down Expand Up @@ -362,6 +370,17 @@ export default {
}
return 0
}

if (configrecord.value?.trim().length === 0) {
if (['CSV', 'Order', 'WhitespaceSeparatedListWithOptions'].includes(configrecord.type)) {
return []
}

if (configrecord.type === 'String') {
return ''
}
}

if (['Order', 'CSV'].includes(configrecord.type)) {
if (configrecord.value && configrecord.value.length > 0) {
return String(configrecord.value).split(',')
Expand Down
Loading