Skip to content

Commit

Permalink
Use ingress validator with dataclient
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <[email protected]>
  • Loading branch information
MustafaSaber committed Nov 28, 2023
1 parent f55a20a commit 04347f1
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dataclients/kubernetes/ingressv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ func (ing *ingress) ingressV1Route(
}
logger := newLogger("Ingress", i.Metadata.Namespace, i.Metadata.Name, loggingEnabled)

ingressValidator := &definitions.IngressV1Validator{}
if err := ingressValidator.Validate(i); err != nil {
logger.Errorf("Ingress validation failed: %v", err)
return nil, nil // Drop the resource without failing LoadAll
}

redirect.initCurrent(i.Metadata)
ic := &ingressContext{
state: state,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ingress validation failed: invalid \\\"zalando\.org\/skipper-routes\\\" annotation: invalid predicate count arg
kind=Ingress name=qux ns=foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: foo
name: qux
annotations:
zalando.org/skipper-routes: |
r1: Header("test") && Path("/login") -> status(200) -> "http://foo.test"
spec:
defaultBackend:
service:
name: bar
port:
number: 1234
rules:
- host: www.example.org
http:
paths:
- path: "/"
pathType: ImplementationSpecific
backend:
service:
name: bar
port:
name: baz
- host: www.example.org
http:
paths:
- path: "/"
pathType: ImplementationSpecific
backend:
service:
name: bar
port:
name: baz
---
apiVersion: v1
kind: Service
metadata:
namespace: foo
name: bar
spec:
clusterIP: 10.3.190.97
ports:
- name: baz
port: 8181
protocol: TCP
targetPort: 8080
- name: qux
port: 1234
protocol: TCP
targetPort: 2134
selector:
application: myapp
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
application: myapp
namespace: foo
name: bar
subsets:
- addresses:
- ip: 10.2.9.103
- ip: 10.2.9.104
ports:
- name: baz
port: 8080
protocol: TCP
- name: qux
port: 2134
protocol: TCP

0 comments on commit 04347f1

Please sign in to comment.