use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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());
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class MetricStoresService method getMetricStore.
public MetricStore getMetricStore(String deploymentName, String metricStoreType) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores().setMetricStore(metricStoreType);
List<MetricStore> matching = lookupService.getMatchingNodesOfType(filter, MetricStore.class);
try {
switch(matching.size()) {
case 0:
MetricStore metricStores = MetricStores.translateMetricStoreType(metricStoreType).newInstance();
setMetricStore(deploymentName, metricStores);
return metricStores;
case 1:
return matching.get(0);
default:
throw new RuntimeException("It shouldn't be possible to have multiple metricStore nodes of the same type. This is a bug.");
}
} catch (InstantiationException | IllegalAccessException e) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Can't create an empty metric store node " + "for metricStore type \"" + metricStoreType + "\"").build());
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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());
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class AccountService method deleteAccount.
public void deleteAccount(String deploymentName, String providerName, String accountName) {
Provider provider = providerService.getProvider(deploymentName, providerName);
boolean removed = provider.getAccounts().removeIf(account -> ((Account) account).getName().equals(accountName));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Account \"" + accountName + "\" wasn't found").build());
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder 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());
}
}
Aggregations