Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update TestTriggers - Support watching Custom Resource using dynamic informers #163

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/executor/v1/zz_generated.deepcopy.go

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

20 changes: 20 additions & 0 deletions apis/tests/v3/zz_generated.deepcopy.go

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

20 changes: 20 additions & 0 deletions apis/testsuite/v2/zz_generated.deepcopy.go

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

21 changes: 21 additions & 0 deletions apis/testsuite/v3/zz_generated.deepcopy.go

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

28 changes: 18 additions & 10 deletions apis/testtriggers/v1/testtrigger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ type TestTriggerSpec struct {
// For which Resource do we monitor Event which triggers an Action on certain conditions
Resource TestTriggerResource `json:"resource"`
// ResourceSelector identifies which Kubernetes Objects should be watched
ResourceSelector TestTriggerSelector `json:"resourceSelector"`
ResourceSelector TestTriggerSelector `json:"resourceSelector"`
CustomResource TestTriggerCRGroupVersionResource `json:"customResource,omitempty"`
// On which Event for a Resource should an Action be triggered
Event TestTriggerEvent `json:"event"`
// What resource conditions should be matched
Expand All @@ -63,20 +64,27 @@ type TestTriggerSpec struct {
Delay *metav1.Duration `json:"delay,omitempty"`
}

type TestTriggerCRGroupVersionResource struct {
Group string `json:"group"`
Version string `json:"version"`
Resource string `json:"resource"`
}

// TestTriggerResource defines resource for test triggers
// +kubebuilder:validation:Enum=pod;deployment;statefulset;daemonset;service;ingress;event;configmap
// +kubebuilder:validation:Enum=pod;deployment;statefulset;daemonset;service;ingress;event;configmap;custom-resource
type TestTriggerResource string

// List of TestTriggerResources
const (
TestTriggerResourcePod TestTriggerResource = "pod"
TestTriggerResourceDeployment TestTriggerResource = "deployment"
TestTriggerResourceStatefulSet TestTriggerResource = "statefulset"
TestTriggerResourceDaemonSet TestTriggerResource = "daemonset"
TestTriggerResourceService TestTriggerResource = "service"
TestTriggerResourceIngress TestTriggerResource = "ingress"
TestTriggerResourceEvent TestTriggerResource = "event"
TestTriggerResourceConfigMap TestTriggerResource = "configmap"
TestTriggerResourcePod TestTriggerResource = "pod"
TestTriggerResourceDeployment TestTriggerResource = "deployment"
TestTriggerResourceStatefulSet TestTriggerResource = "statefulset"
TestTriggerResourceDaemonSet TestTriggerResource = "daemonset"
TestTriggerResourceService TestTriggerResource = "service"
TestTriggerResourceCustomResource TestTriggerResource = "custom-resource"
TestTriggerResourceIngress TestTriggerResource = "ingress"
TestTriggerResourceEvent TestTriggerResource = "event"
TestTriggerResourceConfigMap TestTriggerResource = "configmap"
)

// TestTriggerEvent defines event for test triggers
Expand Down
16 changes: 16 additions & 0 deletions apis/testtriggers/v1/zz_generated.deepcopy.go

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

2 changes: 0 additions & 2 deletions config/crd/bases/executor.testkube.io_executors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ spec:
enum:
- string
- file-uri
# Deprecated: use git instead
- git-file
# Deprecated: use git instead
- git-dir
- git
type: string
Expand Down
18 changes: 18 additions & 0 deletions config/crd/bases/tests.testkube.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ spec:
name:
description: object name
type: string
namespace:
description: object kubernetes namespace
type: string
required:
- key
- name
Expand All @@ -408,6 +411,9 @@ spec:
name:
description: object name
type: string
namespace:
description: object kubernetes namespace
type: string
required:
- key
- name
Expand Down Expand Up @@ -593,6 +599,18 @@ spec:
description: script to run before test execution (not supported
for container executors)
type: string
runningContext:
description: running context for test or test suite execution
properties:
context:
description: Context value depending from its type
type: string
type:
description: One of possible context types
type: string
required:
- type
type: object
scraperTemplate:
description: scraper template extensions
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/tests.testkube.io_testsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ spec:
name:
description: object name
type: string
namespace:
description: object kubernetes namespace
type: string
required:
- key
- name
Expand All @@ -90,6 +93,9 @@ spec:
name:
description: object name
type: string
namespace:
description: object kubernetes namespace
type: string
required:
- key
- name
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/tests.testkube.io_testsuites.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ spec:
description: test kubernetes namespace (\"testkube\" when not
set)
type: string
runningContext:
description: running context for test or test suite execution
properties:
context:
description: Context value depending from its type
type: string
type:
description: One of possible context types
type: string
required:
- type
type: object
secretUUID:
description: secret uuid
type: string
Expand Down Expand Up @@ -641,6 +653,18 @@ spec:
description: test kubernetes namespace (\"testkube\" when not
set)
type: string
runningContext:
description: running context for test or test suite execution
properties:
context:
description: Context value depending from its type
type: string
type:
description: One of possible context types
type: string
required:
- type
type: object
secretUUID:
description: secret uuid
type: string
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/tests.testkube.io_testtriggers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ spec:
format: int32
type: integer
type: object
customResource:
properties:
group:
type: string
resource:
type: string
version:
type: string
required:
- group
- resource
- version
type: object
delay:
description: Delay is a duration string which specifies how long should
the test be delayed after a trigger is matched
Expand Down Expand Up @@ -176,6 +189,7 @@ spec:
- ingress
- event
- configmap
- custom-resource
type: string
resourceSelector:
description: ResourceSelector identifies which Kubernetes Objects
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobuffalo/flect v0.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -46,9 +48,12 @@ require (
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -59,16 +64,19 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/tools v0.4.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
Expand All @@ -81,6 +89,7 @@ require (
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20230109183929-3758b55a6596 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/controller-tools v0.4.1 // indirect
sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading