Skip to content

Commit

Permalink
Add listType annotations to prevent some OpenAPI rules violations
Browse files Browse the repository at this point in the history
This is part of #1271 - `names_match` violations still need to be dealt with.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
  • Loading branch information
abayer authored and tekton-robot committed Jan 20, 2022
1 parent 7fbff3b commit 91a821e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 28 deletions.
16 changes: 10 additions & 6 deletions pkg/apis/triggers/v1alpha1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ var _ kmeta.OwnerRefable = (*EventListener)(nil)
// EventListenerSpec defines the desired state of the EventListener, represented
// by a list of Triggers.
type EventListenerSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Triggers []EventListenerTrigger `json:"triggers"`
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
Resources Resources `json:"resources,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// +listType=atomic
Triggers []EventListenerTrigger `json:"triggers"`
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
Resources Resources `json:"resources,omitempty"`
}

type Resources struct {
Expand All @@ -85,11 +86,13 @@ type KubernetesResource struct {
// TriggerTemplate to then create resources from. TriggerRef can also be
// provided instead of TriggerBinding, Interceptors and TriggerTemplate
type EventListenerTrigger struct {
// +listType=atomic
Bindings []*EventListenerBinding `json:"bindings,omitempty"`
Template *EventListenerTemplate `json:"template,omitempty"`
TriggerRef string `json:"triggerRef,omitempty"`
// +optional
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
// +listType=atomic
Interceptors []*EventInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// more granular authorization for
Expand Down Expand Up @@ -154,6 +157,7 @@ type EventListenerConfig struct {
// +k8s:openapi-gen=true
type NamespaceSelector struct {
// List of namespace names.
// +listType=atomic
MatchNames []string `json:"matchNames,omitempty"`
}

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/triggers/v1alpha1/trigger_binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (tb *TriggerBinding) Copy() TriggerBindingInterface {
// TriggerBindingSpec defines the desired state of the TriggerBinding.
type TriggerBindingSpec struct {
// Params defines the parameter mapping from the given input event.
// +listType=atomic
Params []Param `json:"params,omitempty"`
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/triggers/v1alpha1/trigger_template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var _ apis.Defaultable = (*TriggerTemplate)(nil)

// TriggerTemplateSpec holds the desired state of TriggerTemplate
type TriggerTemplateSpec struct {
Params []ParamSpec `json:"params,omitempty"`
// +listType=atomic
Params []ParamSpec `json:"params,omitempty"`
// +listType=atomic
ResourceTemplates []TriggerResourceTemplate `json:"resourcetemplates,omitempty"`
}

Expand Down
24 changes: 16 additions & 8 deletions pkg/apis/triggers/v1alpha1/trigger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ import (
// and TriggerSpecTemplate; TriggerSpecBinding provides extracted values for
// TriggerSpecTemplate to then create resources from.
type TriggerSpec struct {
// +listType=atomic
Bindings []*TriggerSpecBinding `json:"bindings"`
Template TriggerSpecTemplate `json:"template"`
// +optional
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
// +listType=atomic
Interceptors []*TriggerInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// Unlike EventListeners, this should be scoped to the same namespace
Expand Down Expand Up @@ -92,6 +94,7 @@ type TriggerInterceptor struct {
// Ref refers to the Interceptor to use
Ref InterceptorRef `json:"ref"`
// Params are the params to send to the interceptor
// +listType=atomic
Params []InterceptorParams `json:"params,omitempty"`

// WebhookInterceptor refers to an old style webhook interceptor service
Expand Down Expand Up @@ -239,30 +242,35 @@ type WebhookInterceptor struct {
// Header is a group of key-value pairs that can be appended to the
// interceptor request headers. This allows the interceptor to make
// decisions specific to an EventListenerTrigger.
// +listType=atomic
Header []v1beta1.Param `json:"header,omitempty"`
}

// BitbucketInterceptor provides a webhook to intercept and pre-process events
type BitbucketInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// GitHubInterceptor provides a webhook to intercept and pre-process events
type GitHubInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// GitLabInterceptor provides a webhook to intercept and pre-process events
type GitLabInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// CELInterceptor provides a webhook to intercept and pre-process events
type CELInterceptor struct {
Filter string `json:"filter,omitempty"`
Filter string `json:"filter,omitempty"`
// +listType=atomic
Overlays []CELOverlay `json:"overlays,omitempty"`
}

Expand Down
15 changes: 11 additions & 4 deletions pkg/apis/triggers/v1beta1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ var _ kmeta.OwnerRefable = (*EventListener)(nil)
// EventListenerSpec defines the desired state of the EventListener, represented
// by a list of Triggers.
type EventListenerSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Triggers []EventListenerTrigger `json:"triggers,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// +listType=atomic
Triggers []EventListenerTrigger `json:"triggers,omitempty"`
// Trigger groups allow for centralized processing of an interceptor chain
// +listType=atomic
TriggerGroups []EventListenerTriggerGroup `json:"triggerGroups,omitempty"`
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
Expand All @@ -84,6 +86,7 @@ type KubernetesResource struct {
type PodTemplate struct {
// If specified, the pod's tolerations.
// +optional
// +listType=atomic
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
Expand All @@ -98,11 +101,13 @@ type PodTemplate struct {
// TriggerTemplate to then create resources from. TriggerRef can also be
// provided instead of TriggerBinding, Interceptors and TriggerTemplate
type EventListenerTrigger struct {
// +listType=atomic
Bindings []*EventListenerBinding `json:"bindings,omitempty"`
Template *EventListenerTemplate `json:"template,omitempty"`
TriggerRef string `json:"triggerRef,omitempty"`
// +optional
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
// +listType=atomic
Interceptors []*EventInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// more granular authorization for
Expand All @@ -116,7 +121,8 @@ type EventListenerTrigger struct {

// EventListenerTriggerGroup defines a group of Triggers that share a common set of interceptors
type EventListenerTriggerGroup struct {
Name string `json:"name"`
Name string `json:"name"`
// +listType=atomic
Interceptors []*TriggerInterceptor `json:"interceptors"`
TriggerSelector EventListenerTriggerSelector `json:"triggerSelector"`
}
Expand Down Expand Up @@ -180,6 +186,7 @@ type EventListenerConfig struct {
// +k8s:openapi-gen=true
type NamespaceSelector struct {
// List of namespace names.
// +listType=atomic
MatchNames []string `json:"matchNames,omitempty"`
}

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/triggers/v1beta1/trigger_binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (tb *TriggerBinding) Copy() TriggerBindingInterface {
// TriggerBindingSpec defines the desired state of the TriggerBinding.
type TriggerBindingSpec struct {
// Params defines the parameter mapping from the given input event.
// +listType=atomic
Params []Param `json:"params,omitempty"`
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/triggers/v1beta1/trigger_template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var _ apis.Defaultable = (*TriggerTemplate)(nil)

// TriggerTemplateSpec holds the desired state of TriggerTemplate
type TriggerTemplateSpec struct {
Params []ParamSpec `json:"params,omitempty"`
// +listType=atomic
Params []ParamSpec `json:"params,omitempty"`
// +listType=atomic
ResourceTemplates []TriggerResourceTemplate `json:"resourcetemplates,omitempty"`
}

Expand Down
24 changes: 16 additions & 8 deletions pkg/apis/triggers/v1beta1/trigger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import (
// and TriggerSpecTemplate; TriggerSpecBinding provides extracted values for
// TriggerSpecTemplate to then create resources from.
type TriggerSpec struct {
// +listType=atomic
Bindings []*TriggerSpecBinding `json:"bindings"`
Template TriggerSpecTemplate `json:"template"`
// +optional
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
// +listType=atomic
Interceptors []*TriggerInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// Unlike EventListeners, this should be scoped to the same namespace
Expand Down Expand Up @@ -89,6 +91,7 @@ type TriggerInterceptor struct {
// Ref refers to the Interceptor to use
Ref InterceptorRef `json:"ref"`
// Params are the params to send to the interceptor
// +listType=atomic
Params []InterceptorParams `json:"params,omitempty"`

// WebhookInterceptor refers to an old style webhook interceptor service
Expand Down Expand Up @@ -148,30 +151,35 @@ type WebhookInterceptor struct {
// Header is a group of key-value pairs that can be appended to the
// interceptor request headers. This allows the interceptor to make
// decisions specific to an EventListenerTrigger.
// +listType=atomic
Header []v1beta1.Param `json:"header,omitempty"`
}

// BitbucketInterceptor provides a webhook to intercept and pre-process events
type BitbucketInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// GitHubInterceptor provides a webhook to intercept and pre-process events
type GitHubInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// GitLabInterceptor provides a webhook to intercept and pre-process events
type GitLabInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
SecretRef *SecretRef `json:"secretRef,omitempty"`
// +listType=atomic
EventTypes []string `json:"eventTypes,omitempty"`
}

// CELInterceptor provides a webhook to intercept and pre-process events
type CELInterceptor struct {
Filter string `json:"filter,omitempty"`
Filter string `json:"filter,omitempty"`
// +listType=atomic
Overlays []CELOverlay `json:"overlays,omitempty"`
}

Expand Down

0 comments on commit 91a821e

Please sign in to comment.