Search in sources :

Example 6 with ArtifactAccount

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

Example 7 with ArtifactAccount

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

the class AbstractArtifactEditAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getArtifactAccountName();
    String providerName = getArtifactProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    ArtifactAccount account = new OperationHandler<ArtifactAccount>().setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.getArtifactAccount(currentDeployment, providerName, accountName, false)).get();
    int originaHash = account.hashCode();
    account = editArtifactAccount((T) account);
    if (originaHash == account.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit artifact account " + accountName + " for artifact provider " + providerName + ".").setSuccessMessage("Successfully edited artifact account " + accountName + " for artifact provider " + providerName + ".").setOperation(Daemon.setArtifactAccount(currentDeployment, providerName, accountName, !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 8 with ArtifactAccount

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

the class AbstractListArtifactAccountsCommand method executeThis.

@Override
protected void executeThis() {
    ArtifactProvider provider = getArtifactProvider();
    List<ArtifactAccount> accounts = provider.getAccounts();
    if (accounts.isEmpty()) {
        AnsiUi.success("No configured artifact accounts for " + getArtifactProviderName() + ".");
    } else {
        AnsiUi.success("Artifact accounts for " + getArtifactProviderName() + ":");
        accounts.forEach(account -> AnsiUi.listItem(account.getName()));
    }
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Example 9 with ArtifactAccount

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

the class HttpAddArtifactAccountCommand method buildArtifactAccount.

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

Example 10 with ArtifactAccount

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

the class ArtifactAccountService method addArtifactAccount.

public void addArtifactAccount(String deploymentName, String providerName, ArtifactAccount newArtifactAccount) {
    ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
    provider.getAccounts().add(newArtifactAccount);
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)

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