use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class CanaryController method setEnabled.
@RequestMapping(value = "/enabled/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setEnabled(@PathVariable String deploymentName, @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(() -> canaryService.setCanaryEnabled(deploymentName, enabled));
builder.setSeverity(severity);
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> canaryService.validateCanary(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit canary settings");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class ClusterController method setCluster.
@RequestMapping(value = "/cluster/{clusterName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setCluster(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String clusterName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Problem.Severity severity, @RequestBody Object rawCluster) {
Cluster cluster = objectMapper.convertValue(rawCluster, Providers.translateClusterType(providerName));
DaemonResponse.UpdateRequestBuilder builder = new DaemonResponse.UpdateRequestBuilder();
builder.setUpdate(() -> clusterService.setCluster(deploymentName, providerName, clusterName, cluster));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> clusterService.validateCluster(deploymentName, providerName, cluster.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + clusterName + " cluster");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class ClusterController method addCluster.
@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addCluster(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Problem.Severity severity, @RequestBody Object rawCluster) {
Cluster cluster = objectMapper.convertValue(rawCluster, Providers.translateClusterType(providerName));
DaemonResponse.UpdateRequestBuilder builder = new DaemonResponse.UpdateRequestBuilder();
builder.setSeverity(severity);
builder.setUpdate(() -> clusterService.addCluster(deploymentName, providerName, cluster));
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> clusterService.validateCluster(deploymentName, providerName, cluster.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Add the " + cluster.getName() + " cluster");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class SubscriptionController method setSubscription.
@RequestMapping(value = "/subscription/{subscriptionName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSubscription(@PathVariable String deploymentName, @PathVariable String pubsubName, @PathVariable String subscriptionName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSubscription) {
Subscription subscription = objectMapper.convertValue(rawSubscription, Pubsubs.translateSubscriptionType(pubsubName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
builder.setUpdate(() -> subscriptionService.setSubscription(deploymentName, pubsubName, subscriptionName, subscription));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> subscriptionService.validateSubscription(deploymentName, pubsubName, subscription.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + subscriptionName + " subscription");
}
use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.
the class MasterController method setMaster.
@RequestMapping(value = "/{masterName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMaster(@PathVariable String deploymentName, @PathVariable String ciName, @PathVariable String masterName, @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.setUpdate(() -> masterService.setMaster(deploymentName, ciName, masterName, master));
builder.setSeverity(severity);
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, "Edit the " + masterName + " master");
}
Aggregations