Search in sources :

Example 46 with Account

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

the class AbstractListAccountsCommand method executeThis.

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

Example 47 with Account

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

the class AppengineAddAccountCommand method buildAccount.

@Override
protected Account buildAccount(String accountName) {
    AppengineAccount account = (AppengineAccount) new AppengineAccount().setName(accountName);
    account.setProject(project).setJsonPath(jsonPath);
    account.setLocalRepositoryDirectory(localRepositoryDirectory).setGitHttpsUsername(gitHttpsUsername).setGitHttpsPassword(gitHttpsPassword).setGithubOAuthAccessToken(githubOAuthAccessToken).setSshPrivateKeyFilePath(sshPrivateKeyFilePath).setSshPrivateKeyPassphrase(sshPrivateKeyPassphrase).setSshKnownHostsFilePath(sshKnownHostsFilePath).setSshTrustUnknownHosts(sshTrustUnknownHosts).setGcloudReleaseTrack(gcloudReleaseTrack);
    return account;
}
Also used : AppengineAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineAccount)

Example 48 with Account

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

the class DockerRegistryAddAccountCommand method buildAccount.

@Override
protected Account buildAccount(String accountName) {
    DockerRegistryAccount account = (DockerRegistryAccount) new DockerRegistryAccount().setName(accountName);
    account.setAddress(address).setRepositories(repositories).setPassword(password).setPasswordFile(passwordFile).setUsername(username).setEmail(email).setCacheIntervalSeconds(cacheIntervalSeconds).setClientTimeoutMillis(clientTimeoutMillis).setCacheThreads(cacheThreads).setPaginateSize(paginateSize).setSortTagsByDate(sortTagsByDate).setTrackDigests(trackDigests).setInsecureRegistry(insecureRegistry);
    return account;
}
Also used : DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount)

Example 49 with Account

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

the class ClouddriverProfileFactory method removeBootstrapOnlyAccount.

@SuppressWarnings("unchecked")
private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) {
    Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
    Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent());
    bootstrapProvider.getAccounts().remove(bootstrapAccount);
    if (bootstrapProvider.getAccounts().isEmpty()) {
        bootstrapProvider.setEnabled(false);
        if (bootstrapAccount instanceof ContainerAccount) {
            ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
            DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers);
            containerAccount.getDockerRegistries().forEach(reg -> {
                Set<Account> dependentAccounts = revIndex.get(reg.getAccountName());
                if (dependentAccounts == null || dependentAccounts.isEmpty()) {
                    DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName());
                    ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct);
                }
            });
            if (providers.getDockerRegistry().getAccounts().isEmpty()) {
                providers.getDockerRegistry().setEnabled(false);
            }
        }
    }
}
Also used : ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider)

Example 50 with Account

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

the class ClouddriverBootstrapProfileFactory method setProfile.

@Override
@SuppressWarnings("unchecked")
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    super.setProfile(profile, deploymentConfiguration, endpoints);
    DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
    if (deploymentEnvironment.getType() != DeploymentEnvironment.DeploymentType.Distributed) {
        throw new IllegalStateException("There is no need to produce a bootstrapping clouddriver for a non-remote deployment of Spinnaker. This is a bug.");
    }
    // We need to make modifications to this deployment configuration, but can't use helpful objects
    // like the accountService on a clone. Therefore, we'll make the modifications in place and
    // restore to the original state when the modifications are written out.
    Providers originalProviders = deploymentConfiguration.getProviders().cloneNode(Providers.class);
    Providers modifiedProviders = deploymentConfiguration.getProviders();
    String deploymentName = deploymentConfiguration.getName();
    String bootstrapAccountName = deploymentEnvironment.getAccountName();
    Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
    bootstrapAccount.makeBootstrappingAccount(artifactSourcesConfig);
    Provider bootstrapProvider = (Provider) bootstrapAccount.getParent();
    disableAllProviders(modifiedProviders);
    bootstrapProvider.setEnabled(true);
    bootstrapProvider.setAccounts(Collections.singletonList(bootstrapAccount));
    if (bootstrapAccount instanceof ContainerAccount) {
        ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
        List<DockerRegistryAccount> bootstrapRegistries = containerAccount.getDockerRegistries().stream().map(ref -> (DockerRegistryAccount) accountService.getProviderAccount(deploymentName, DOCKER_REGISTRY, ref.getAccountName())).collect(Collectors.toList());
        DockerRegistryProvider dockerProvider = modifiedProviders.getDockerRegistry();
        dockerProvider.setEnabled(true);
        dockerProvider.setAccounts(bootstrapRegistries);
    }
    if (bootstrapAccount instanceof SupportsConsul) {
        SupportsConsul consulAccount = (SupportsConsul) bootstrapAccount;
        ConsulConfig config = consulAccount.getConsul();
        if (config == null) {
            config = new ConsulConfig();
            consulAccount.setConsul(config);
        }
        consulAccount.getConsul().setEnabled(true);
    } else {
        log.warn("Attempting to perform a distributed deployment to account \"" + bootstrapAccount.getName() + "\" without a discovery mechanism");
    }
    List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName());
    profile.appendContents(yamlToString(modifiedProviders)).appendContents("services.fiat.enabled: false").appendContents(profile.getBaseContents()).setRequiredFiles(files);
    deploymentConfiguration.setProviders(originalProviders);
}
Also used : ArtifactSourcesConfig(com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeIterator(com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator) Autowired(org.springframework.beans.factory.annotation.Autowired) SpinnakerArtifact(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) ProviderService(com.netflix.spinnaker.halyard.config.services.v1.ProviderService) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) Providers(com.netflix.spinnaker.halyard.config.model.v1.node.Providers) ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) ConsulConfig(com.netflix.spinnaker.halyard.config.model.v1.providers.consul.ConsulConfig) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) Collectors(java.util.stream.Collectors) SupportsConsul(com.netflix.spinnaker.halyard.config.model.v1.providers.consul.SupportsConsul) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) Slf4j(lombok.extern.slf4j.Slf4j) Component(org.springframework.stereotype.Component) List(java.util.List) AccountService(com.netflix.spinnaker.halyard.config.services.v1.AccountService) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) Optional(java.util.Optional) Collections(java.util.Collections) ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) ConsulConfig(com.netflix.spinnaker.halyard.config.model.v1.providers.consul.ConsulConfig) Providers(com.netflix.spinnaker.halyard.config.model.v1.node.Providers) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) SupportsConsul(com.netflix.spinnaker.halyard.config.model.v1.providers.consul.SupportsConsul) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)

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