Search in sources :

Example 16 with Account

use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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 17 with Account

use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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 18 with Account

use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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 19 with Account

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

the class AccountController method newAccountOptions.

@RequestMapping(value = "/options", method = RequestMethod.POST)
DaemonTask<Halconfig, List<String>> newAccountOptions(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody DaemonOptions rawAccountOptions) {
    String fieldName = rawAccountOptions.getField();
    Account account = objectMapper.convertValue(rawAccountOptions.getResource(), Providers.translateAccountType(providerName));
    DaemonResponse.UpdateOptionsRequestBuilder builder = new DaemonResponse.UpdateOptionsRequestBuilder();
    String accountName = account.getName();
    builder.setUpdate(() -> accountService.addAccount(deploymentName, providerName, account));
    builder.setFieldOptionsResponse(() -> accountService.getAccountOptions(deploymentName, providerName, accountName, fieldName));
    builder.setSeverity(severity);
    return DaemonTaskHandler.submitTask(builder::build, "Get " + fieldName + " options");
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DaemonResponse(com.netflix.spinnaker.halyard.core.DaemonResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with Account

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

the class ArtifactAccountService method deleteArtifactAccount.

public void deleteArtifactAccount(String deploymentName, String providerName, String accountName) {
    ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
    boolean removed = provider.getAccounts().removeIf(account -> ((ArtifactAccount) account).getName().equals(accountName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Artifact account \"" + accountName + "\" wasn't found").build());
    }
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Aggregations

Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)19 List (java.util.List)13 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)11 KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)11 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)11 Collectors (java.util.stream.Collectors)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)9 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)8 ArrayList (java.util.ArrayList)8 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)7 Path (java.nio.file.Path)7 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)6 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)6 DockerRegistryReference (com.netflix.spinnaker.halyard.config.model.v1.providers.containers.DockerRegistryReference)6 GoogleAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount)6 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)6 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)6 IOException (java.io.IOException)5 Collections (java.util.Collections)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5