Skip to content

Commit

Permalink
Support any K8s spec as trigger source (#259)
Browse files Browse the repository at this point in the history
* feature(): adding support backoff feature

* feature(): update backoff policy feature and add example

* feature(): adding support to directly specify any K8s resource spec as trigger source
  • Loading branch information
VaibhavPage authored and spk83 committed Apr 8, 2019
1 parent 2a5f965 commit 9122d50
Show file tree
Hide file tree
Showing 20 changed files with 408 additions and 1,043 deletions.
61 changes: 33 additions & 28 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ coverage:
clean:
-rm -rf ${CURRENT_DIR}/dist

.PHONY: protogen
protogen:
./hack/generate-proto.sh

.PHONY: clientgen
clientgen:
./hack/update-codegen.sh
Expand All @@ -296,7 +292,7 @@ openapi-gen:
./hack/update-openapigen.sh

.PHONY: codegen
codegen: clientgen openapigen protogen
codegen: clientgen openapigen

.PHONY: e2e
e2e:
Expand Down
2 changes: 1 addition & 1 deletion controllers/common/informer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getInformerFactory(clientset kubernetes.Interface, queue workqueue.RateLimi
OwnerGroupVersionKind: schema.GroupVersionKind{Version: "v1", Kind: "Pod"},
OwnerInformer: ownerInformer,
SharedInformerFactory: informerFactory,
Queue: queue,
Queue: queue,
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/gateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c *GatewayController) Run(ctx context.Context, gwThreads, eventThreads int
OwnerGroupVersionKind: v1alpha1.SchemaGroupVersionKind,
OwnerInformer: c.informer,
SharedInformerFactory: informers.NewFilteredSharedInformerFactory(c.kubeClientset, gatewayResourceResyncPeriod, c.Config.Namespace, listOptionsFunc),
Queue: c.queue,
Queue: c.queue,
}

c.podInformer = factory.NewPodInformer()
Expand Down
2 changes: 1 addition & 1 deletion controllers/sensor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (c *SensorController) Run(ctx context.Context, ssThreads, eventThreads int)
OwnerGroupVersionKind: v1alpha1.SchemaGroupVersionKind,
OwnerInformer: c.informer,
SharedInformerFactory: informers.NewFilteredSharedInformerFactory(c.kubeClientset, sensorResourceResyncPeriod, c.Config.Namespace, listOptionsFunc),
Queue: c.queue,
Queue: c.queue,
}

c.podInformer = factory.NewPodInformer()
Expand Down
54 changes: 54 additions & 0 deletions examples/sensors/trigger-resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: trigger-resource-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
containers:
- name: "sensor"
image: "argoproj/sensor"
imagePullPolicy: Always
serviceAccountName: argo-events-sa
dependencies:
- name: "webhook-gateway-http:foo"
eventProtocol:
type: "HTTP"
http:
port: "9300"
triggers:
- template:
name: trigger1
group: argoproj.io
version: v1alpha1
kind: Workflow
source:
# resource is generic template for K8s resource
# This is similar to `inline` trigger but useful if you are using kustomize and want to parameterize the trigger
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: webhook-
spec:
entrypoint: whalesay
arguments:
parameters:
- name: message
# this is the value that should be overridden
value: hello world
templates:
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
resourceParameters:
- src:
event: "webhook-gateway-http:foo"
dest: spec.arguments.parameters.0.value
4 changes: 2 additions & 2 deletions gateways/community/gitlab/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (rc *RouteConfig) PostStart() error {
formattedUrl := gwcommon.GenerateFormattedURL(rc.ges.Hook)

opt := &gitlab.AddProjectHookOptions{
URL: &formattedUrl,
Token: &c.token,
URL: &formattedUrl,
Token: &c.token,
EnableSSLVerification: &rc.ges.EnableSSLVerification,
}

Expand Down
2 changes: 1 addition & 1 deletion gateways/core/resource/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestFilter(t *testing.T) {
Namespace: "fake",
Labels: map[string]string{
"workflows.argoproj.io/phase": "Succeeded",
"name": "my-workflow",
"name": "my-workflow",
},
},
}
Expand Down
44 changes: 0 additions & 44 deletions hack/generate-proto.sh

This file was deleted.

Loading

0 comments on commit 9122d50

Please sign in to comment.