Search in sources :

Example 6 with ConfigProblemBuilder

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

the class PersistentStorageService method getPersistentStore.

public PersistentStore getPersistentStore(String deploymentName, String persistentStoreType) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPersistentStore(persistentStoreType);
    List<PersistentStore> matching = lookupService.getMatchingNodesOfType(filter, PersistentStore.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Problem.Severity.FATAL, "No persistent store with name \"" + persistentStoreType + "\" could be found").setRemediation("Create a new persistent store with name \"" + persistentStoreType + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Problem.Severity.FATAL, "More than one persistent store with name \"" + persistentStoreType + "\" found").setRemediation("Manually delete or rename duplicate persistent stores with name \"" + persistentStoreType + "\" 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) OracleBMCSPersistentStore(com.netflix.spinnaker.halyard.config.model.v1.persistentStorage.OracleBMCSPersistentStore) PersistentStore(com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStore) S3PersistentStore(com.netflix.spinnaker.halyard.config.model.v1.persistentStorage.S3PersistentStore) AzsPersistentStore(com.netflix.spinnaker.halyard.config.model.v1.persistentStorage.AzsPersistentStore) GcsPersistentStore(com.netflix.spinnaker.halyard.config.model.v1.persistentStorage.GcsPersistentStore) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 7 with ConfigProblemBuilder

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

the class PubsubService method getPubsub.

public Pubsub getPubsub(String deploymentName, String pubsubName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPubsub(pubsubName);
    List<Pubsub> matching = lookupService.getMatchingNodesOfType(filter, Pubsub.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No pubsub with name \"" + pubsubName + "\" could be found").setRemediation("Create a new pubsub with name \"" + pubsubName + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one pubsub with name \"" + pubsubName + "\" found").setRemediation("Manually delete or rename duplicate pubsubs with name \"" + pubsubName + "\" in your halconfig file").build());
    }
}
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) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 8 with ConfigProblemBuilder

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

the class SubscriptionService method getAllSubscriptions.

public List<Subscription> getAllSubscriptions(String deploymentName, String pubsubName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPubsub(pubsubName).withAnySubscription();
    List<Subscription> matchingSubscriptions = lookupService.getMatchingNodesOfType(filter, Subscription.class);
    if (matchingSubscriptions.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No subscriptions could be found").build());
    } else {
        return matchingSubscriptions;
    }
}
Also used : ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) Subscription(com.netflix.spinnaker.halyard.config.model.v1.node.Subscription) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 9 with ConfigProblemBuilder

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

the class ArtifactAccountService method getAllArtifactAccounts.

public List<ArtifactAccount> getAllArtifactAccounts(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setArtifactProvider(providerName).withAnyArtifactAccount();
    List<ArtifactAccount> matchingArtifactAccounts = lookupService.getMatchingNodesOfType(filter, ArtifactAccount.class);
    if (matchingArtifactAccounts.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No accounts could be found").build());
    } else {
        return matchingArtifactAccounts;
    }
}
Also used : 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) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

Example 10 with ConfigProblemBuilder

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

the class ArtifactAccountService method deleteArtifactAccount.

public void deleteArtifactAccount(String deploymentName, String providerName, String accountName) {
    ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
    boolean removed = provider.getAccounts().removeIf(account -> ((ArtifactAccount) account).getName().equals(accountName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Artifact account \"" + accountName + "\" wasn't found").build());
    }
}
Also used : ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)

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