Search in sources :

Example 16 with ConfigNotFoundException

use of com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException in project halyard by spinnaker.

the class DeploymentService method getDeploymentConfiguration.

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

Example 17 with ConfigNotFoundException

use of com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException 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)

Example 18 with ConfigNotFoundException

use of com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException in project halyard by spinnaker.

the class PubsubService method getAllPubsubs.

public List<Pubsub> getAllPubsubs(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyPubsub();
    List<Pubsub> matching = lookupService.getMatchingNodesOfType(filter, Pubsub.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No pubsubs could be found").build());
    } else {
        return matching;
    }
}
Also used : Pubsub(com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub) GooglePubsub(com.netflix.spinnaker.halyard.config.model.v1.pubsub.google.GooglePubsub) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 19 with ConfigNotFoundException

use of com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException in project halyard by spinnaker.

the class DeploymentEnvironmentValidator method validateDistributedDeployment.

private void validateDistributedDeployment(ConfigProblemSetBuilder p, DeploymentEnvironment n) {
    String accountName = n.getAccountName();
    if (StringUtils.isEmpty(accountName)) {
        p.addProblem(Problem.Severity.FATAL, "An account name must be specified when using a Distributed deployment.");
        return;
    }
    DeploymentConfiguration deploymentConfiguration = n.parentOfType(DeploymentConfiguration.class);
    Account account;
    try {
        account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), n.getAccountName());
    } catch (ConfigNotFoundException e) {
        p.addProblem(Problem.Severity.FATAL, "Account " + accountName + " not defined.");
        return;
    }
    if (account instanceof GoogleAccount) {
        p.addProblem(Problem.Severity.WARNING, "Support for distributed deployments on GCE aren't fully supported yet.");
    } else if (account instanceof KubernetesAccount) {
        kubernetesAccountValidator.ensureKubectlExists(p);
    } else {
        p.addProblem(Problem.Severity.FATAL, "Account " + accountName + " is not in a provider that supports distributed installation of Spinnaker yet");
    }
}
Also used : KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) GoogleAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount) GoogleAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Aggregations

ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)19 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)18 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)16 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)8 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)3 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 Ci (com.netflix.spinnaker.halyard.config.model.v1.node.Ci)2 Pubsub (com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub)2 GooglePubsub (com.netflix.spinnaker.halyard.config.model.v1.pubsub.google.GooglePubsub)2 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)1 AbstractCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration)1 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)1 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)1 Cluster (com.netflix.spinnaker.halyard.config.model.v1.node.Cluster)1 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)1 Notification (com.netflix.spinnaker.halyard.config.model.v1.node.Notification)1