Search in sources :

Example 31 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class AccountController method deleteAccount.

@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.DELETE)
DaemonTask<Halconfig, Void> deleteAccount(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity) {
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    builder.setUpdate(() -> accountService.deleteAccount(deploymentName, providerName, accountName));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> accountService.validateAllAccounts(deploymentName, providerName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Delete the " + accountName + " account");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class ArtifactProviderController method setArtifactProvider.

@RequestMapping(value = "/{providerName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactProvider(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactProvider) {
    ArtifactProvider provider = objectMapper.convertValue(rawArtifactProvider, Artifacts.translateArtifactProviderType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> provider.stageLocalFiles(configPath));
    builder.setUpdate(() -> providerService.setArtifactProvider(deploymentName, provider));
    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());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + providerName + " provider");
}
Also used : Path(java.nio.file.Path) ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class BakeryController method addBaseImage.

@RequestMapping(value = "/defaults/baseImage/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addBaseImage(@PathVariable String deploymentName, @PathVariable String providerName, @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.setSeverity(severity);
    // TODO(lwander): Would be good to indicate when an added base image id conflicts with an existing base image id.
    builder.setUpdate(() -> bakeryService.addBaseImage(deploymentName, providerName, baseImage));
    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, "Add " + baseImage.getNodeName() + " base image");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) BaseImage(com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 34 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class BakeryController method deleteBaseImage.

@RequestMapping(value = "/defaults/baseImage/{baseImageId:.+}", method = RequestMethod.DELETE)
DaemonTask<Halconfig, Void> deleteBaseImage(@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) {
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    builder.setUpdate(() -> bakeryService.deleteBaseImage(deploymentName, providerName, baseImageId));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> bakeryService.validateAllBaseImages(deploymentName, providerName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Delete " + baseImageId + " base image");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class DeploymentController method setVersion.

@RequestMapping(value = "/{deploymentName:.+}/version/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setVersion(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Versions.Version version) {
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    builder.setUpdate(() -> deploymentService.setVersion(deploymentName, version.getVersion()));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> deploymentService.validateDeploymentShallow(deploymentName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    return DaemonTaskHandler.submitTask(builder::build, "Edit Spinnaker version");
}
Also used : UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)54 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)52 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)50 Path (java.nio.file.Path)37 DaemonResponse (com.netflix.spinnaker.halyard.core.DaemonResponse)3 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)2 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2 Cluster (com.netflix.spinnaker.halyard.config.model.v1.node.Cluster)2 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)2 Subscription (com.netflix.spinnaker.halyard.config.model.v1.node.Subscription)2 ApiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity)2 UiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)1 BakeryDefaults (com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1