use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigUpdateCommandTest method shouldRaiseErrorWhenUpdatingNonExistentSecretConfig.
@Test
public void shouldRaiseErrorWhenUpdatingNonExistentSecretConfig() throws Exception {
cruiseConfig.getSecretConfigs().clear();
SecretConfig secretConfig = new SecretConfig("foo", "docker");
SecretConfigUpdateCommand command = new SecretConfigUpdateCommand(null, secretConfig, null, null, new HttpLocalizedOperationResult(), null, null);
Assertions.assertThrows(RecordNotFoundException.class, () -> command.update(cruiseConfig));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigsControllerV3 method show.
public String show(Request request, Response response) throws IOException {
SecretConfig secretConfig = fetchEntityFromConfig(request.params(CONFIG_ID_PARAM));
if (isGetOrHeadRequestFresh(request, secretConfig)) {
return notModified(response);
}
setEtagHeader(response, etagFor(secretConfig));
return writerForTopLevelObject(request, response, writer -> SecretConfigRepresenter.toJSON(writer, secretConfig));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigsControllerV3 method destroy.
public String destroy(Request request, Response response) throws IOException {
SecretConfig secretConfigToBeDeleted = fetchEntityFromConfig(request.params(CONFIG_ID_PARAM));
final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
configService.delete(currentUsername(), secretConfigToBeDeleted, operationResult);
return renderHTTPOperationResult(operationResult, request, response);
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigRepresenter method fromJSON.
public static SecretConfig fromJSON(JsonReader jsonReader) {
SecretConfig secretConfig = new SecretConfig(jsonReader.getString("id"), jsonReader.getString("plugin_id"));
jsonReader.optString("description").ifPresent(description -> secretConfig.setDescription(description));
secretConfig.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "properties"));
jsonReader.readArrayIfPresent("rules", array -> {
secretConfig.setRules(RulesRepresenter.fromJSON(array));
});
return secretConfig;
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigUpdateCommand method update.
@Override
public void update(CruiseConfig preprocessedConfig) {
SecretConfig existingSecretConfig = findExistingProfile(preprocessedConfig);
SecretConfigs secretConfigs = getPluginProfiles(preprocessedConfig);
secretConfigs.set(secretConfigs.indexOf(existingSecretConfig), profile);
}
Aggregations