Search in sources :

Example 1 with HasImageProvider

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

the class BakeryService method getBakeryDefaults.

public BakeryDefaults getBakeryDefaults(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName).setBakeryDefaults();
    List<BakeryDefaults> matching = lookupService.getMatchingNodesOfType(filter, BakeryDefaults.class);
    switch(matching.size()) {
        case 0:
            HasImageProvider provider = providerService.getHasImageProvider(deploymentName, providerName);
            BakeryDefaults bakeryDefaults = provider.emptyBakeryDefaults();
            setBakeryDefaults(deploymentName, providerName, bakeryDefaults);
            return bakeryDefaults;
        case 1:
            return matching.get(0);
        default:
            throw new RuntimeException("It shouldn't be possible to have multiple bakeryDefaults nodes. This is a bug.");
    }
}
Also used : BakeryDefaults(com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter) HasImageProvider(com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider)

Example 2 with HasImageProvider

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

the class BakeryService method setBakeryDefaults.

public void setBakeryDefaults(String deploymentName, String providerName, BakeryDefaults newBakeryDefaults) {
    HasImageProvider provider = providerService.getHasImageProvider(deploymentName, providerName);
    provider.setBakeryDefaults(newBakeryDefaults);
}
Also used : HasImageProvider(com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider)

Example 3 with HasImageProvider

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

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

the class ProviderService method getHasImageProvider.

public HasImageProvider getHasImageProvider(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName);
    Provider provider = getProvider(deploymentName, providerName);
    if (provider instanceof HasImageProvider) {
        return (HasImageProvider) provider;
    } else {
        throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "Provider \"" + providerName + "\" does not support configuring images via Halyard.").build());
    }
}
Also used : ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) GoogleProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider) AzureProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider) AwsProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider) AppengineProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) OracleBMCSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.oraclebmcs.OracleBMCSProvider) OpenstackProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider) DCOSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider) KubernetesProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)

Aggregations

HasImageProvider (com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider)3 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)1 BakeryDefaults (com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults)1 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)1 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)1 Providers (com.netflix.spinnaker.halyard.config.model.v1.node.Providers)1 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)1 AwsProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider)1 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)1 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)1 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)1 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)1 KubernetesProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)1 OpenstackProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider)1 OracleBMCSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.oraclebmcs.OracleBMCSProvider)1 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)1