use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class LookupService method getMatchingNodes.
/**
* @param node is the node whose children we want to find.
* @param filter is the filter to lookup by.
* @return the children of the input node matching the filter.
*/
private List<Node> getMatchingNodes(Node node, NodeFilter filter) {
log.trace("Checking for leaf nodes of node " + node.getNodeName());
List<Node> result = new ArrayList<>();
NodeIterator children = node.getChildren();
Node recurse = children.getNext(filter);
while (recurse != null) {
result.addAll(getMatchingNodes(recurse, filter));
recurse = children.getNext(filter);
}
// If we have visited this node, it must have matched the filter.
result.add(node);
return result;
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class ProviderService method getProvider.
public Provider getProvider(String deploymentName, String providerName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName);
List<Provider> matching = lookupService.getMatchingNodesOfType(filter, Provider.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());
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class ProviderService method getHasClustersProvider.
public HasClustersProvider getHasClustersProvider(String deploymentName, String providerName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName);
Provider provider = getProvider(deploymentName, providerName);
if (provider instanceof HasClustersProvider) {
return (HasClustersProvider) provider;
} else {
throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "Provider \"" + providerName + "\" does not support configuring clusters via Halyard.").build());
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class ValidateService method validateMatchingFilter.
ProblemSet validateMatchingFilter(NodeFilter filter) {
DaemonTaskHandler.newStage("Running validation");
Halconfig halconfig = parser.getHalconfig();
ConfigProblemSetBuilder psBuilder = new ConfigProblemSetBuilder(applicationContext);
recursiveValidate(psBuilder, halconfig, filter);
return psBuilder.build();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.
the class NotificationService method getNotification.
public Notification getNotification(String deploymentName, String notificationName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setNotification(notificationName);
List<Notification> matching = lookupService.getMatchingNodesOfType(filter, Notification.class);
switch(matching.size()) {
case 0:
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No notification type with name \"" + notificationName + "\" could be found").build());
case 1:
return matching.get(0);
default:
throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one notification type with name \"" + notificationName + "\" found").build());
}
}
Aggregations