File tree Expand file tree Collapse file tree 1 file changed +32
-3
lines changed
Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Original file line number Diff line number Diff line change 1+ import yaml
2+
3+ # Load the YAML file
4+ ingress_yaml = """
15apiVersion: networking.k8s.io/v1
26kind: Ingress
37metadata:
2125 port:
2226 number: 5900
2327 rules:
24- - host: {{ fqdn }}
28+ - host: " {{ fqdn }}"
2529 http:
2630 paths:
2731 - path: /backend(/|$)(.*)
4044 number: 5900
4145 tls:
4246 - hosts:
43- - {{ fqdn }}
44- secretName: secret-kmgs
47+ - "{{ fqdn }}"
48+ secretName: secret-kmgs
49+ """
50+
51+ # Function to validate the required fields
52+ def validate_ingress(ingress):
53+ required_fields = {
54+ 'fqdn': ingress['spec']['rules'][0]['host'],
55+ 'cert-manager.io/cluster-issuer': ingress['metadata']['annotations'].get('cert-manager.io/cluster-issuer'),
56+ 'ingressClassName': ingress['spec'].get('ingressClassName'),
57+ 'frontapp-service': ingress['spec']['defaultBackend']['service']['name'],
58+ 'aiservice-service': ingress['spec']['rules'][0]['http']['paths'][0]['backend']['service']['name'],
59+ 'tls-secret-name': ingress['spec']['tls'][0].get('secretName')
60+ }
61+
62+ # Check each required field
63+ for field, value in required_fields.items():
64+ if value in [None, '', '{{ fqdn }}']:
65+ print(f"ERROR: The field '{field}' is missing or empty.")
66+ else:
67+ print(f"Field '{field}' is valid: {value}")
68+
69+ # Load YAML data
70+ ingress_data = yaml.safe_load(ingress_yaml)
71+
72+ # Validate
73+ validate_ingress(ingress_data)
You can’t perform that action at this time.
0 commit comments