Skip to content

Commit

Permalink
Added ability to refer the eventSource in a different namespace. (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
elyzov-plesk authored and VaibhavPage committed Jul 26, 2019
1 parent 95ecb9b commit f54d651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ The gateway `spec` has following fields:

1. `type`: Type of the gateway. This is defined by the user.

2. `eventSource`: Refers to K8s configmap that holds the list of event sources.
2. `eventSource`: Refers to K8s configmap that holds the list of event sources. You can use `namespace/configmap-name` syntax to refer the configmap in a different namespace.

3. `processorPort`: This is a gateway server port. You can leave this to `9330` unless you really have to change it to a different port.

Expand Down
11 changes: 9 additions & 2 deletions gateways/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"github.com/argoproj/argo-events/common"
"strings"

"github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -74,12 +75,18 @@ func (gc *GatewayConfig) WatchGatewayEventSources(ctx context.Context) (cache.Co
func (gc *GatewayConfig) newConfigMapWatch(name string) *cache.ListWatch {
x := gc.Clientset.CoreV1().RESTClient()
resource := "configmaps"
namespace := gc.Namespace
if strings.Contains(name, "/") {
parts := strings.SplitN(name, "/", 2)
namespace = parts[0]
name = parts[1]
}
fieldSelector := fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", name))

listFunc := func(options metav1.ListOptions) (runtime.Object, error) {
options.FieldSelector = fieldSelector.String()
req := x.Get().
Namespace(gc.Namespace).
Namespace(namespace).
Resource(resource).
VersionedParams(&options, metav1.ParameterCodec)
return req.Do().Get()
Expand All @@ -88,7 +95,7 @@ func (gc *GatewayConfig) newConfigMapWatch(name string) *cache.ListWatch {
options.Watch = true
options.FieldSelector = fieldSelector.String()
req := x.Get().
Namespace(gc.Namespace).
Namespace(namespace).
Resource(resource).
VersionedParams(&options, metav1.ParameterCodec)
return req.Watch()
Expand Down

0 comments on commit f54d651

Please sign in to comment.