From 01c2bff9264ab4feea6bdaea35eef3843f1e4e62 Mon Sep 17 00:00:00 2001 From: Daniel Duvall Date: Thu, 15 Aug 2019 05:45:11 -0700 Subject: [PATCH] Allow watching of resources in all namespaces at once (#334) The `namespace` field of a resource event source is now optional to allow for configuration that would watch for resource related events in all namespaces at once. Simply omitting the field works in this way because the k8s dynamic client used in implementation can accept a zero-length string for namespace. --- examples/event-sources/resource.yaml | 11 +++++++++++ gateways/core/resource/validate.go | 3 --- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/event-sources/resource.yaml b/examples/event-sources/resource.yaml index c667c24f05..785be862a7 100644 --- a/examples/event-sources/resource.yaml +++ b/examples/event-sources/resource.yaml @@ -82,3 +82,14 @@ data: labels: workflows.argoproj.io/completed: "true" prefix: "hello" + + # watch for completed workflows in any namespace + example-without-namespace: |- + # namespace: (omitted to match any namespace) + group: "k8s.io" + version: v1 + kind: Workflow + type: ADDED + filter: + labels: + workflows.argoproj.io/completed: "true" diff --git a/gateways/core/resource/validate.go b/gateways/core/resource/validate.go index 60a2c59253..4d4947754e 100644 --- a/gateways/core/resource/validate.go +++ b/gateways/core/resource/validate.go @@ -37,9 +37,6 @@ func validateResource(config interface{}) error { if res.Version == "" { return fmt.Errorf("resource version must be specified") } - if res.Namespace == "" { - return fmt.Errorf("resource namespace must be specified") - } if res.Kind == "" { return fmt.Errorf("resource kind must be specified") }