Search in sources :

Example 6 with Providers

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

the class IgorProfileFactory method setProfile.

@Override
public void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    super.setProfile(profile, deploymentConfiguration, endpoints);
    Providers providers = deploymentConfiguration.getProviders();
    if (providers.getDockerRegistry().isEnabled()) {
        profile.appendContents("dockerRegistry.enabled: true");
    }
    Cis cis = deploymentConfiguration.getCi();
    List<String> files = backupRequiredFiles(cis, deploymentConfiguration.getName());
    profile.appendContents(yamlToString(cis)).appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
Also used : Providers(com.netflix.spinnaker.halyard.config.model.v1.node.Providers) Cis(com.netflix.spinnaker.halyard.config.model.v1.node.Cis)

Example 7 with Providers

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

Example 8 with Providers

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

the class RoscoProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    super.setProfile(profile, deploymentConfiguration, endpoints);
    Providers providers = deploymentConfiguration.getProviders();
    Providers otherProviders = getImageProviders(profile.getVersion());
    NodeIterator iterator = providers.getChildren();
    Provider child = (Provider) iterator.getNext();
    while (child != null) {
        if (child instanceof HasImageProvider) {
            NodeIterator otherIterator = otherProviders.getChildren();
            NodeFilter providerFilter = new NodeFilter().setProvider(child.getNodeName());
            HasImageProvider otherChild = (HasImageProvider) otherIterator.getNext(providerFilter);
            if (otherChild == null) {
                log.warn("images.yml has no images stored for " + child.getNodeName());
            } else {
                log.info("Adding default images for " + child.getNodeName());
                ((HasImageProvider) child).getBakeryDefaults().addDefaultImages(otherChild.getBakeryDefaults().getBaseImages());
            }
        }
        child = (Provider) iterator.getNext();
    }
    List<String> files = backupRequiredFiles(providers, deploymentConfiguration.getName());
    profile.appendContents(yamlToString(providers)).appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
Also used : NodeIterator(com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator) Providers(com.netflix.spinnaker.halyard.config.model.v1.node.Providers) HasImageProvider(com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) HasImageProvider(com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 9 with Providers

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

the class ArtifactProviderService method getArtifactProvider.

public ArtifactProvider getArtifactProvider(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setArtifactProvider(providerName);
    List<ArtifactProvider> matching = lookupService.getMatchingNodesOfType(filter, ArtifactProvider.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No provider with name \"" + providerName + "\" could be found").setRemediation("Create a new provider with name \"" + providerName + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one provider with name \"" + providerName + "\" found").setRemediation("Manually delete or rename duplicate providers with name \"" + providerName + "\" in your halconfig file").build());
    }
}
Also used : GitHubArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider) ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) HttpArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider) GcsArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Aggregations

ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)4 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)4 Providers (com.netflix.spinnaker.halyard.config.model.v1.node.Providers)4 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)4 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)4 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)3 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)3 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)2 GcsArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider)2 GitHubArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider)2 HttpArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider)2 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)2 ContainerAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount)2 DockerRegistryAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount)2 ArtifactSourcesConfig (com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig)1 Artifacts (com.netflix.spinnaker.halyard.config.model.v1.node.Artifacts)1 Cis (com.netflix.spinnaker.halyard.config.model.v1.node.Cis)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1