Search in sources :

Example 1 with ArtifactAccount

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

the class AbstractAddArtifactAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getArtifactAccountName();
    ArtifactAccount account = buildArtifactAccount(accountName);
    String providerName = getArtifactProviderName();
    String currentDeployment = getCurrentDeployment();
    new OperationHandler<Void>().setFailureMesssage("Failed to add artifact account " + accountName + " for artifact provider " + providerName + ".").setSuccessMessage("Successfully added artifact account " + accountName + " for artifact provider " + providerName + ".").setOperation(Daemon.addArtifactAccount(currentDeployment, providerName, !noValidate, account)).get();
}
Also used : ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with ArtifactAccount

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

the class GitHubAddArtifactAccountCommand method buildArtifactAccount.

@Override
protected ArtifactAccount buildArtifactAccount(String accountName) {
    GitHubArtifactAccount artifactAccount = new GitHubArtifactAccount().setName(accountName);
    artifactAccount.setUsername(username).setPassword(password).setUsernamePasswordFile(usernamePasswordFile).setToken(token).setTokenFile(tokenFile);
    return artifactAccount;
}
Also used : GitHubArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactAccount)

Example 3 with ArtifactAccount

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

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

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

the class ArtifactAccountService method getAllArtifactAccounts.

public List<ArtifactAccount> getAllArtifactAccounts(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setArtifactProvider(providerName).withAnyArtifactAccount();
    List<ArtifactAccount> matchingArtifactAccounts = lookupService.getMatchingNodesOfType(filter, ArtifactAccount.class);
    if (matchingArtifactAccounts.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No accounts could be found").build());
    } else {
        return matchingArtifactAccounts;
    }
}
Also used : ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Aggregations

ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)7 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)3 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)2 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)2 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)2 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)2 Path (java.nio.file.Path)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)1 GitHubArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactAccount)1 HttpArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactAccount)1 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1