Search in sources :

Example 11 with ConfigNotFoundException

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

the class CanaryAccountService method getCanaryAccount.

public AbstractCanaryAccount getCanaryAccount(String deploymentName, String serviceIntegrationName, String accountName) {
    AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName);
    List<AbstractCanaryAccount> matchingAccounts = (List<AbstractCanaryAccount>) serviceIntegration.getAccounts().stream().filter(a -> (((AbstractCanaryAccount) a).getName().equals(accountName))).collect(Collectors.toList());
    switch(matchingAccounts.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No account with name \"" + accountName + "\" was found").setRemediation("Check if this account was defined in another service integration, or create a new one").build());
        case 1:
            return matchingAccounts.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one account named \"" + accountName + "\" was found").setRemediation("Manually delete/rename duplicate canary accounts with name \"" + accountName + "\" in your halconfig file").build());
    }
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) List(java.util.List) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)

Example 12 with ConfigNotFoundException

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

the class CiService method getAllCis.

public List<Ci> getAllCis(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyCi();
    List<Ci> matching = lookupService.getMatchingNodesOfType(filter, Ci.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No cis could be found").build());
    } else {
        return matching;
    }
}
Also used : Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) 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 13 with ConfigNotFoundException

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

the class CiService method getCi.

public Ci getCi(String deploymentName, String ciName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCi(ciName);
    List<Ci> matching = lookupService.getMatchingNodesOfType(filter, Ci.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No Continuous Integration service with name \"" + ciName + "\" could be found").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one CI with name \"" + ciName + "\" found").build());
    }
}
Also used : Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) 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 14 with ConfigNotFoundException

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

the class MasterService method getAllMasters.

public List<Master> getAllMasters(String deploymentName, String ciName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCi(ciName).withAnyMaster();
    List<Master> matchingMasters = lookupService.getMatchingNodesOfType(filter, Master.class);
    if (matchingMasters.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No masters could be found").build());
    } else {
        return matchingMasters;
    }
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) 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 15 with ConfigNotFoundException

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

the class DeploymentService method getAllDeploymentConfigurations.

public List<DeploymentConfiguration> getAllDeploymentConfigurations() {
    NodeFilter filter = new NodeFilter().withAnyDeployment();
    List<DeploymentConfiguration> matching = lookupService.getMatchingNodesOfType(filter, DeploymentConfiguration.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No deployments could be found in your currently loaded halconfig").build());
    } else {
        return matching;
    }
}
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) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

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