use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class ArtifactProviderController method setEnabled.
@RequestMapping(value = "/{providerName:.+}/enabled", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> providerService.setEnabled(deploymentName, providerName, enabled));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> providerService.validateArtifactProvider(deploymentName, providerName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + providerName + " provider");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class BakeryController method setBakeryDefaults.
@RequestMapping(value = "/defaults/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setBakeryDefaults(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawBakeryDefaults) {
BakeryDefaults bakeryDefaults = objectMapper.convertValue(rawBakeryDefaults, Providers.translateBakeryDefaultsType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> bakeryDefaults.stageLocalFiles(configPath));
builder.setUpdate(() -> bakeryService.setBakeryDefaults(deploymentName, providerName, bakeryDefaults));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> bakeryService.validateBakeryDefaults(deploymentName, providerName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + providerName + " bakery defaults");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class BakeryController method setBaseImage.
@RequestMapping(value = "/defaults/baseImage/{baseImageId:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setBaseImage(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String baseImageId, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawBaseImage) {
BaseImage baseImage = objectMapper.convertValue(rawBaseImage, Providers.translateBaseImageType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> baseImage.stageLocalFiles(configPath));
builder.setUpdate(() -> bakeryService.setBaseImage(deploymentName, providerName, baseImageId, baseImage));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> bakeryService.validateBaseImage(deploymentName, providerName, baseImage.getBaseImage().getId());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + baseImageId + " base image");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class CiController method setEnabled.
@RequestMapping(value = "/{ciName:.+}/enabled", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @PathVariable String ciName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> ciService.setEnabled(deploymentName, ciName, enabled));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> ciService.validateCi(deploymentName, ciName);
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit " + ciName + " settings");
}
use of com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder in project halyard by spinnaker.
the class DeploymentController method deploymentConfiguration.
@RequestMapping(value = "/{deploymentName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> deploymentConfiguration(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawDeployment) {
DeploymentConfiguration deploymentConfiguration = objectMapper.convertValue(rawDeployment, DeploymentConfiguration.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> deploymentConfiguration.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> deploymentService.setDeploymentConfiguration(deploymentName, deploymentConfiguration));
if (validate) {
builder.setValidate(() -> deploymentService.validateDeployment(deploymentName));
} else {
builder.setValidate(ProblemSet::new);
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit deployment configuration");
}
Aggregations