Search in sources :

Example 16 with ConfigProblemBuilder

use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.

the class CanaryAccountService method deleteAccount.

public void deleteAccount(String deploymentName, String serviceIntegrationName, String accountName) {
    AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName);
    boolean removed = serviceIntegration.getAccounts().removeIf(account -> ((AbstractCanaryAccount) account).getName().equals(accountName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build());
    }
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)

Example 17 with ConfigProblemBuilder

use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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 18 with ConfigProblemBuilder

use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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 19 with ConfigProblemBuilder

use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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 20 with ConfigProblemBuilder

use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.

the class MasterService method deleteMaster.

public void deleteMaster(String deploymentName, String ciName, String masterName) {
    Ci ci = ciService.getCi(deploymentName, ciName);
    boolean removed = ci.getMasters().removeIf(master -> ((Master) master).getName().equals(masterName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Master \"" + masterName + "\" wasn't found").build());
    }
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) Ci(com.netflix.spinnaker.halyard.config.model.v1.node.Ci) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Aggregations

ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)39 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)18 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)17 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)16 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)4 Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)4 IOException (java.io.IOException)4 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)3 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)3 Ci (com.netflix.spinnaker.halyard.config.model.v1.node.Ci)3 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)3 Pubsub (com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub)3 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)3 AwsProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider)3 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)3 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)3 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)3 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)3 KubernetesProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)3