use of com.enonic.kubernetes.operator.ingress.Mapping in project xp-operator by enonic.
the class AdmissionApi method ingress.
private void ingress(AdmissionReview admissionReview) {
AdmissionOperation op = getOperation(admissionReview);
if (op == AdmissionOperation.DELETE) {
return;
}
Ingress newIngress = (Ingress) admissionReview.getRequest().getObject();
if (matchAnnotationPrefix(cfgStr("operator.charts.values.annotationKeys.vhostMapping")).negate().test(newIngress)) {
return;
}
Set<Mapping> mappings = getAnnotationMappings(newIngress);
Preconditions.checkArgument(!mappings.isEmpty(), "malformed 'enonic.cloud/xp7.vhost.mapping' annotations");
for (Mapping m : mappings) {
List<String> paths = newIngress.getSpec().getRules().stream().map(r -> r.getHttp().getPaths().stream().filter(p -> p.getBackend().getService().getPort().getNumber() == 8080).map(HTTPIngressPath::getPath).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());
Preconditions.checkArgument(paths.contains(m.source()), String.format("source '%s' in 'enonic.cloud/xp7.vhost.mapping' annotation not defined in ingress rules on host %s, port 8080", m.source(), m.host()));
}
}
Aggregations