use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class SecurityController method setApacheSSl.
@RequestMapping(value = "/ui/ssl/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApacheSSl(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApacheSsl) {
ApacheSsl apacheSsl = objectMapper.convertValue(rawApacheSsl, ApacheSsl.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> apacheSsl.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setApacheSsl(deploymentName, apacheSsl));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateApacheSsl(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit UI SSL settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class SecurityController method setApiSecurity.
@RequestMapping(value = "/api/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApiSecurity) {
ApiSecurity apiSecurity = objectMapper.convertValue(rawApiSecurity, ApiSecurity.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> apiSecurity.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setApiSecurity(deploymentName, apiSecurity));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateApiSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit API security settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity in project halyard by spinnaker.
the class ResponseUnwrapper method formatProblemSet.
private static void formatProblemSet(ProblemSet problemSet) {
if (problemSet == null || problemSet.isEmpty()) {
return;
}
AnsiSnippet snippet = new AnsiSnippet("\r").setErase(AnsiErase.ERASE_LINE);
AnsiPrinter.err.print(snippet.toString());
Map<String, List<Problem>> locationGroup = problemSet.groupByLocation();
for (Entry<String, List<Problem>> entry : locationGroup.entrySet()) {
AnsiUi.problemLocation(entry.getKey());
for (Problem problem : entry.getValue()) {
Severity severity = problem.getSeverity();
String message = problem.getMessage();
String remediation = problem.getRemediation();
List<String> options = problem.getOptions();
switch(severity) {
case FATAL:
case ERROR:
AnsiUi.error(message);
break;
case WARNING:
AnsiUi.warning(message);
break;
default:
throw new RuntimeException("Unknown severity level " + severity);
}
if (remediation != null && !remediation.isEmpty()) {
AnsiUi.remediation(remediation);
}
if (options != null && !options.isEmpty()) {
AnsiUi.remediation("Options include: ");
options.forEach(AnsiUi::listRemediation);
}
// Newline between errors
AnsiUi.raw("");
}
}
}
Aggregations