travisghansen / kubernetes-pfsense-controller

Integrate Kubernetes and pfSense
Apache License 2.0
197 stars 22 forks source link

Fix php warning on ingress without host #23

Closed valtzu closed 1 year ago

valtzu commented 1 year ago

First of all, thanks for a great project!


Ingress resources don't necessarily have host defined, f.e. I have this (manually created) ingress resource with only path defined:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-app
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: demo-app
            port:
              name: http
        path: /demo-app
        pathType: Prefix

But it produces php warnings:

PHP Warning:  Undefined array key "host" in phar:///usr/local/bin/kubernetes-pfsense-controller/src/KubernetesPfSenseController/Plugin/HAProxyIngressProxy.php on line 233
PHP Warning:  Undefined array key "host" in phar:///usr/local/bin/kubernetes-pfsense-controller/src/KubernetesPfSenseController/Plugin/HAProxyIngressProxy.php on line 428

I noticed there is also a check for empty($host) so we only need to address missing array key here, which I've done here.

travisghansen commented 1 year ago

Does it currently create a rule when a host is not present?

valtzu commented 1 year ago

Does it currently create a rule when a host is not present?

It does, just without host acl.

image

travisghansen commented 1 year ago

Thanks!