From 6a042ae84d1b93a6cc5998bea058c3450de604d6 Mon Sep 17 00:00:00 2001 From: Gaston Festari Date: Fri, 13 Nov 2026 16:37:12 -0300 Subject: [PATCH] feat: update support for api-url in env and flag --- README.md | 20 ++++++++++++++++++-- deploy/manifests/deploy.yaml | 9 --------- main.go | 11 +++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2105185..815b061 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,25 @@ The following environment variables are supported: | Variable | Required | Description | | --- | --- | --- | -| `EXTERNAL_API_URL` | **Yes** | Target HTTP/HTTPS endpoint that receives `POST` JSON payloads. | +| `EXTERNAL_API_URL` | No* | Target HTTP/HTTPS endpoint that receives `POST` JSON payloads. | | `EXTERNAL_API_TOKEN` | No | Optional Bearer token sent in the `Authorization: Bearer ` header. | -These should be mounted from a Secret source on the namespace. +> **NOTE**: one of `--api-url` flag or `EXTERNAL_API_URL` environment variable +> are required. + +These should be mounted from a Secret source on the namespace, e.g.: + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: prober-config + namespace: prober-system +type: Opaque +stringData: + EXTERNAL_API_TOKEN: 'my-secret-token' + EXTERNAL_API_URL: 'https://webhooks.example.com' +``` ### CLI Flags @@ -30,6 +45,7 @@ The following CLI flags can be passed to the binary: | Flag | Default | Description | | --- | --- | --- | +| `--api-url` | `""` | External endpoint URL to deliver payloads to. | | `--leader-elect` | `false` | Enable leader election for high-availability multi-replica deployments. | | `--metrics-bind-address` | `:8080` | Address the Prometheus metrics endpoint binds to. | | `--health-probe-bind-address` | `:8081` | Address the `/healthz` and `/readyz` endpoints bind to. | diff --git a/deploy/manifests/deploy.yaml b/deploy/manifests/deploy.yaml index f85f048..a32bac2 100644 --- a/deploy/manifests/deploy.yaml +++ b/deploy/manifests/deploy.yaml @@ -126,12 +126,3 @@ spec: readOnlyRootFilesystem: true capabilities: drop: ['ALL'] ---- -apiVersion: v1 -kind: Secret -metadata: - name: prober-config - namespace: prober-system -type: Opaque -stringData: - EXTERNAL_API_TOKEN: 'my-secret-token' diff --git a/main.go b/main.go index b42e13f..1ebf908 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,16 @@ func main() { } ctrl.SetLogger(zap.New(zap.UseDevMode(true))) + + if apiURL == "" { + apiURL = os.Getenv("EXTERNAL_API_URL") + } + if apiURL == "" { + setupLog.Error(nil, "missing required --api-url flag or EXTERNAL_API_URL environment variable") + flag.Usage() + os.Exit(2) + } + setupLog.Info("initializing the controller", "version", version) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ @@ -66,6 +76,7 @@ func main() { } apiToken := os.Getenv("EXTERNAL_API_TOKEN") + // Register the HTTPRouteWatcher reconciler if err = (&controllers.HTTPRouteWatcher{ Client: mgr.GetClient(),