use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter 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.model.v1.node.NodeFilter in project halyard by spinnaker.
the class DeploymentService method validateDeployment.
public ProblemSet validateDeployment(String deploymentName) {
PersistentStorage storage = storageService.getPersistentStorage(deploymentName);
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyProvider().withAnyAccount().setFeatures().setSecurity();
if (storage.getPersistentStoreType() != null) {
filter.setPersistentStore(storage.getPersistentStoreType().getId());
}
return validateService.validateMatchingFilter(filter);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class MetricStoresService method getMetricStores.
public MetricStores getMetricStores(String deploymentName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores();
List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class);
switch(matching.size()) {
case 0:
MetricStores metricStores = new MetricStores();
setMetricStores(deploymentName, metricStores);
return metricStores;
case 1:
return matching.get(0);
default:
throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug.");
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter 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.model.v1.node.NodeFilter in project halyard by spinnaker.
the class OptionsService method options.
public <T extends Node> FieldOptions options(NodeFilter filter, Class<T> nodeClass, String field) {
ConfigProblemSetBuilder problemSetBuilder = new ConfigProblemSetBuilder(applicationContext);
List<T> nodes = lookupService.getMatchingNodesOfType(filter, nodeClass);
List<String> options = nodes.stream().map(n -> {
problemSetBuilder.setNode(n);
return n.fieldOptions(problemSetBuilder, field);
}).reduce(new ArrayList<>(), (a, b) -> {
a.addAll(b);
return a;
});
return new FieldOptions().setOptions(options).setProblemSet(problemSetBuilder.build());
}
Aggregations