Skip to content

Commit

Permalink
Update deps (#370)
Browse files Browse the repository at this point in the history
* feat(): added group,version,resource to sensor trigger and updated kubernetes client

* chore(): updated lock file
  • Loading branch information
VaibhavPage authored Oct 9, 2019
1 parent 3b9f64e commit 9877177
Show file tree
Hide file tree
Showing 41 changed files with 1,352 additions and 1,288 deletions.
474 changes: 333 additions & 141 deletions Gopkg.lock

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
required = [
"k8s.io/code-generator/cmd/client-gen",
"k8s.io/code-generator/cmd/deepcopy-gen",
"k8s.io/code-generator/cmd/informer-gen",
"k8s.io/code-generator/cmd/lister-gen",
"k8s.io/code-generator/cmd/defaulter-gen",
"k8s.io/code-generator/cmd/openapi-gen",
"k8s.io/code-generator/cmd/go-to-protobuf",
"k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo",
"k8s.io/kube-openapi/cmd/openapi-gen",
"k8s.io/gengo/examples/deepcopy-gen",
"github.com/golang/protobuf/protoc-gen-go",
"github.com/gogo/protobuf/protoc-gen-gofast",
"github.com/gogo/protobuf/protoc-gen-gogofast",
"gopkg.in/src-d/go-git.v4"
]

[[constraint]]
[[override]]
name = "k8s.io/kube-openapi"
branch = "master"

[[override]]
name = "k8s.io/code-generator"
branch = "release-1.10"
branch = "release-1.15"

[[constraint]]
name = "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -44,7 +42,7 @@ required = [

[[constraint]]
name = "google.golang.org/grpc"
version = "v1.17.0"
version = "v1.24.0"

[[constraint]]
name = "github.com/golang/protobuf"
Expand Down Expand Up @@ -76,11 +74,11 @@ required = [

[[constraint]]
name = "github.com/argoproj/argo"
version = "v2.2.0"
version = "v2.3.0"

[[constraint]]
name = "github.com/Shopify/sarama"
version = "v1.20.0"
version = "v1.23.0"

[[constraint]]
name = "github.com/stretchr/testify"
Expand All @@ -103,15 +101,15 @@ required = [
version = "5.3.0"

[[override]]
branch = "release-1.10"
branch = "release-1.15"
name = "k8s.io/api"

[[override]]
branch = "release-1.10"
branch = "release-1.15"
name = "k8s.io/apimachinery"

[[override]]
branch = "release-7.0"
branch = "release-12.0"
name = "k8s.io/client-go"

[prune]
Expand Down
2 changes: 1 addition & 1 deletion controllers/sensor/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func validateTriggerTemplate(template *v1alpha1.TriggerTemplate) error {
if template.Source == nil {
return fmt.Errorf("trigger '%s' does not contain an absolute action", template.Name)
}
if template.GroupVersionKind == nil {
if template.GroupVersionResource == nil {
return fmt.Errorf("must provide group, version and kind for the resource")
}
if template.When != nil && template.When.All != nil && template.When.Any != nil {
Expand Down
30 changes: 8 additions & 22 deletions examples/event-sources/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ data:
# resource version
version: "v1alpha1"
# resource kind
kind: "Workflow"
resource: "workflows"
# type of event
# possible values are ADDED, DELETED, MODIFIED, ERROR
# if not provided, listen to all events
# possible values are ADD, DELETE, UPDATE
# Optional
type: ADDED
type: ADD
# Filters to apply on watched object
# Optional
filter:
Expand All @@ -36,35 +35,24 @@ data:
namespace: argo-events
group: ""
version: "v1"
kind: "Namespace"
resource: "namespaces"
# create event if workflow with prefix "my-workflow" gets modified
example-with-prefix-filter: |-
namespace: argo-events
group: argoproj.io
version: v1alpha1
kind: Workflow
resource: workflows
type: MODIFIED
filter:
prefix: "my-workflow"
# create event if pod with specified annotation gets deleted
example-with-annotations-filter: |-
namespace: argo-events
group: ""
version: v1
kind: Pod
type: DELETED
filter:
annotations:
gateways.argoproj.io/resource-spec-hash: "2978318157"
# create event when a pod is created before 2019-03-27T010:52:32Z
example-with-created-by-filter: |-
namespace: argo-events
group: argoproj.io
version: v1alpha1
kind: Workflow
resource: workflows
type: ADDED
filter:
createdBy: "2019-04-06T12:52:11Z"
Expand All @@ -73,12 +61,10 @@ data:
namespace: argo-events
group: ""
version: v1
kind: Pod
resource: pods
type: ADDED
filter:
createdBy: "2019-04-06T12:52:11Z"
annotations:
workflows.argoproj.io/node-name: hello-world-6j292
labels:
workflows.argoproj.io/completed: "true"
prefix: "hello"
Expand All @@ -88,7 +74,7 @@ data:
# namespace: (omitted to match any namespace)
group: "k8s.io"
version: v1
kind: Workflow
resource: workflows
type: ADDED
filter:
labels:
Expand Down
23 changes: 19 additions & 4 deletions gateways/core/resource/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@ import (
"github.com/ghodss/yaml"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)

const ArgoEventsEventSourceVersion = "v0.10"

type EventType string

const (
ADD EventType = "ADD"
UPDATE EventType = "UPDATE"
DELETE EventType = "DELETE"
)

// InformerEvent holds event generated from resource state change
type InformerEvent struct {
Obj interface{}
OldObj interface{}
Type EventType
}

// ResourceEventSourceExecutor implements Eventing
type ResourceEventSourceExecutor struct {
Log *logrus.Logger
Expand All @@ -40,17 +54,18 @@ type resource struct {
// Filter is applied on the metadata of the resource
Filter *ResourceFilter `json:"filter,omitempty"`
// Group of the resource
metav1.GroupVersionKind `json:",inline"`
// Type is the event type. Refer https://github.com/kubernetes/apimachinery/blob/dcb391cde5ca0298013d43336817d20b74650702/pkg/watch/watch.go#L43
metav1.GroupVersionResource `json:",inline"`
// Type is the event type.
// If not provided, the gateway will watch all events for a resource.
Type watch.EventType `json:"type,omitempty"`
Type EventType `json:"type,omitempty"`
}

// ResourceFilter contains K8 ObjectMeta information to further filter resource event objects
type ResourceFilter struct {
Prefix string `json:"prefix,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Fields map[string]string `json:"fields,omitempty"`
CreatedBy metav1.Time `json:"createdBy,omitempty"`
}

Expand Down
8 changes: 4 additions & 4 deletions gateways/core/resource/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ var es = `
namespace: "argo-events"
group: ""
version: "v1"
kind: "Pod"
resource: "pods"
filter:
labels:
workflows.argoproj.io/phase: Succeeded
name: "my-workflow"
workflows.argoproj.io/phase: Succeeded
name: "my-workflow"
`

func TestParseConfig(t *testing.T) {
Expand All @@ -44,6 +44,6 @@ func TestParseConfig(t *testing.T) {

convey.So(resource.Group, convey.ShouldEqual, "")
convey.So(resource.Version, convey.ShouldEqual, "v1")
convey.So(resource.Kind, convey.ShouldEqual, "Pod")
convey.So(resource.Resource, convey.ShouldEqual, "pods")
})
}
Loading

0 comments on commit 9877177

Please sign in to comment.