Search in sources :

Example 16 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class ArtifactAccountController method setArtifactAccount.

@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactAccount(@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, @RequestBody Object rawArtifactAccount) {
    ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> account.stageLocalFiles(configPath));
    builder.setUpdate(() -> accountService.setArtifactAccount(deploymentName, providerName, accountName, account));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " artifact 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) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class ArtifactAccountController method addArtifactAccount.

@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactAccount) {
    ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> account.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> accountService.addArtifactAccount(deploymentName, providerName, account));
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Add the " + account.getName() + " artifact 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) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class CanaryController method setCanaryAccount.

@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawCanaryAccount) {
    AbstractCanaryAccount canaryAccount = objectMapper.convertValue(rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> canaryAccount.stageLocalFiles(configPath));
    builder.setUpdate(() -> canaryAccountService.setAccount(deploymentName, serviceIntegrationName, accountName, canaryAccount));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> canaryService.validateCanary(deploymentName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " canary account");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class CanaryController method addCanaryAccount.

@RequestMapping(value = "/{serviceIntegrationName:.+}/accounts/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addCanaryAccount(@PathVariable String deploymentName, @PathVariable String serviceIntegrationName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawCanaryAccount) {
    AbstractCanaryAccount canaryAccount = objectMapper.convertValue(rawCanaryAccount, Canary.translateCanaryAccountType(serviceIntegrationName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> canaryAccount.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> canaryAccountService.addAccount(deploymentName, serviceIntegrationName, canaryAccount));
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> canaryService.validateCanary(deploymentName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Add the " + canaryAccount.getName() + " canary account to " + serviceIntegrationName + " service integration");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with Halconfig

use of com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig in project halyard by spinnaker.

the class CanaryController method setCanary.

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setCanary(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawCanary) {
    Canary canary = objectMapper.convertValue(rawCanary, Canary.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> canary.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> canaryService.setCanary(deploymentName, canary));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> canaryService.validateCanary(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit canary analysis settings");
}
Also used : Path(java.nio.file.Path) Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) 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

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)36 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)35 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)33 Path (java.nio.file.Path)33 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)11 Halconfig (com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)9 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)7 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)6 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)5 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)5 IOException (java.io.IOException)5 Node (com.netflix.spinnaker.halyard.config.model.v1.node.Node)4 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)3 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)3 List (java.util.List)3 ParseConfigException (com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2