use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.
the class MasterController method addMaster.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addMaster(@PathVariable String deploymentName, @PathVariable String ciName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMaster) {
Master master = objectMapper.convertValue(rawMaster, Cis.translateMasterType(ciName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> master.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> masterService.addMaster(deploymentName, ciName, master));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> masterService.validateMaster(deploymentName, ciName, master.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Add the " + master.getName() + " master");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.
the class SecurityController method setUiSecurity.
@RequestMapping(value = "/ui/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setUiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawUiSecurity) {
UiSecurity uiSecurity = objectMapper.convertValue(rawUiSecurity, UiSecurity.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> uiSecurity.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setUiSecurity(deploymentName, uiSecurity));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateUiSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit UI security settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.
the class SecurityController method setRoleProvider.
@RequestMapping(value = "/authz/groupMembership/{roleProviderName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setRoleProvider(@PathVariable String deploymentName, @PathVariable String roleProviderName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawProvider) {
RoleProvider roleProvider = objectMapper.convertValue(rawProvider, GroupMembership.translateRoleProviderType(roleProviderName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> roleProvider.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setRoleProvider(deploymentName, roleProvider));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateRoleProvider(deploymentName, roleProviderName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + roleProviderName + " group membership settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.
the class SecurityController method setSecurity.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSecurity) {
Security security = objectMapper.convertValue(rawSecurity, Security.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> security.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setSecurity(deploymentName, security));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateSecurity(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit security settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.
the class SecurityController method setAuthnMethod.
@RequestMapping(value = "/authn/{methodName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setAuthnMethod(@PathVariable String deploymentName, @PathVariable String methodName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMethod) {
AuthnMethod method = objectMapper.convertValue(rawMethod, AuthnMethod.translateAuthnMethodName(methodName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> method.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setAuthnMethod(deploymentName, method));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateAuthnMethod(deploymentName, methodName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + methodName + " authentication settings");
}
Aggregations