Search in sources :

Example 1 with Account

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

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

the class GoogleProviderUtils method defaultServiceAccount.

static String defaultServiceAccount(AccountDeploymentDetails<GoogleAccount> details) {
    GoogleAccount account = details.getAccount();
    String project = account.getProject();
    Compute compute = getCompute(details);
    try {
        return compute.projects().get(project).execute().getDefaultServiceAccount();
    } catch (IOException e) {
        throw new HalException(FATAL, "Unable to get default compute service account");
    }
}
Also used : GoogleAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount) Compute(com.google.api.services.compute.Compute) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) IOException(java.io.IOException)

Example 3 with Account

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

the class DCOSEditAccountCommand method editAccount.

@Override
protected Account editAccount(DCOSAccount account) {
    if (!removeCredential.isEmpty()) {
        account.removeCredential(removeCredential.get(0), removeCredential.get(1));
    }
    if (!updateUserCredential.isEmpty()) {
        validateCredential(updateUserCredential);
        final String clusterName = updateUserCredential.get(0);
        final String uid = updateUserCredential.get(1);
        final String password = updateUserCredential.get(2);
        account.removeCredential(clusterName, uid);
        final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, password, null);
        account.getClusters().add(credential);
    }
    if (!updateServiceCredential.isEmpty()) {
        validateCredential(updateServiceCredential);
        final String clusterName = updateServiceCredential.get(0);
        final String uid = updateServiceCredential.get(1);
        final String serviceKeyFile = updateServiceCredential.get(2);
        account.removeCredential(clusterName, uid);
        final DCOSAccount.ClusterCredential credential = new DCOSAccount.ClusterCredential(clusterName, uid, null, serviceKeyFile);
        account.getClusters().add(credential);
    }
    try {
        List<String> oldRegistries = account.getDockerRegistries().stream().map(DockerRegistryReference::getAccountName).collect(Collectors.toList());
        List<DockerRegistryReference> newRegistries = updateStringList(oldRegistries, dockerRegistries, addDockerRegistry, removeDockerRegistry).stream().map(s -> new DockerRegistryReference().setAccountName(s)).collect(Collectors.toList());
        account.setDockerRegistries(newRegistries);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Set either --docker-registries or --[add/remove]-docker-registry");
    }
    return account;
}
Also used : DockerRegistryReference(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.DockerRegistryReference) DockerRegistryReference(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.DockerRegistryReference) Parameters(com.beust.jcommander.Parameters) DCOSAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSAccount) List(java.util.List) Parameter(com.beust.jcommander.Parameter) AbstractEditAccountCommand(com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractEditAccountCommand) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DCOSAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSAccount)

Example 4 with Account

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

the class AbstractEditCanaryAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getAccountName();
    String serviceIntegration = getServiceIntegration();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    AbstractCanaryAccount account = new OperationHandler<AbstractCanaryAccount>().setFailureMesssage("Failed to get canary account " + accountName + " for service integration " + serviceIntegration + ".").setOperation(Daemon.getCanaryAccount(currentDeployment, serviceIntegration.toLowerCase(), accountName, false)).get();
    int originaHash = account.hashCode();
    account = editAccount((T) account);
    if (originaHash == account.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit canary account " + accountName + " for service integration " + serviceIntegration + ".").setSuccessMessage("Successfully edited canary account " + accountName + " for service integration " + serviceIntegration + ".").setOperation(Daemon.setCanaryAccount(currentDeployment, serviceIntegration.toLowerCase(), accountName, !noValidate, account)).get();
}
Also used : AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 5 with Account

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

the class KubernetesAddAccountCommand method buildAccount.

@Override
protected Account buildAccount(String accountName) {
    KubernetesAccount account = (KubernetesAccount) new KubernetesAccount().setName(accountName);
    account.setContext(context);
    account.setKubeconfigFile(kubeconfigFile);
    account.setNamespaces(namespaces);
    account.setOmitNamespaces(omitNamespaces);
    account.setKinds(namespaces);
    account.setOmitKinds(omitKinds);
    account.setConfigureImagePullSecrets(configureImagePullSecrets);
    account.setServiceAccount(serviceAccount);
    dockerRegistries.forEach(registryName -> account.getDockerRegistries().add(new DockerRegistryReference().setAccountName(registryName)));
    account.setOAuthServiceAccount(oAuthServiceAccount);
    account.setOAuthScopes(oAuthScopes);
    account.setNamingStrategy(namingStrategy);
    account.setSkin(skin);
    return account;
}
Also used : DockerRegistryReference(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.DockerRegistryReference) KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)

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