diff --git a/docs/eventlisteners.md b/docs/eventlisteners.md index 49f3679909..e863540576 100644 --- a/docs/eventlisteners.md +++ b/docs/eventlisteners.md @@ -421,7 +421,7 @@ spec: ### Bitbucket Interceptors Bitbucket Interceptors contain logic to validate and filter webhooks that come from -Bitbucket server or cloud. Supported features include validating webhooks actually came from Bitbucket as well as +Bitbucket server and not the Bitbucket cloud. Supported features include validating webhooks actually come from Bitbucket server as well as filtering incoming events. To use this Interceptor as a validator, create a secret string using the method diff --git a/pkg/apis/triggers/v1alpha1/event_listener_types.go b/pkg/apis/triggers/v1alpha1/event_listener_types.go index d091edc078..950a8f618c 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_types.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_types.go @@ -85,7 +85,7 @@ type EventInterceptor struct { GitHub *GitHubInterceptor `json:"github,omitempty"` GitLab *GitLabInterceptor `json:"gitlab,omitempty"` CEL *CELInterceptor `json:"cel,omitempty"` - Bitbucket *BitBucketInterceptor `json:"bitbucket,omitempty"` + Bitbucket *BitbucketInterceptor `json:"bitbucket,omitempty"` } // WebhookInterceptor provides a webhook to intercept and pre-process events @@ -100,8 +100,8 @@ type WebhookInterceptor struct { Header []v1beta1.Param `json:"header,omitempty"` } -// BitBucketInterceptor provides a webhook to intercept and pre-process events -type BitBucketInterceptor struct { +// BitbucketInterceptor provides a webhook to intercept and pre-process events +type BitbucketInterceptor struct { SecretRef *SecretRef `json:"secretRef,omitempty"` EventTypes []string `json:"eventTypes,omitempty"` } diff --git a/pkg/apis/triggers/v1alpha1/event_listener_validation_test.go b/pkg/apis/triggers/v1alpha1/event_listener_validation_test.go index 05f1b4f814..14c5d0e421 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_validation_test.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_validation_test.go @@ -349,7 +349,7 @@ func TestEventListenerValidate_error(t *testing.T) { Interceptors: []*v1alpha1.EventInterceptor{{ GitHub: &v1alpha1.GitHubInterceptor{}, GitLab: &v1alpha1.GitLabInterceptor{}, - Bitbucket: &v1alpha1.BitBucketInterceptor{}, + Bitbucket: &v1alpha1.BitbucketInterceptor{}, }}, }}, }, diff --git a/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go index 09a021b907..6762118de5 100644 --- a/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go @@ -27,7 +27,7 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BitBucketInterceptor) DeepCopyInto(out *BitBucketInterceptor) { +func (in *BitbucketInterceptor) DeepCopyInto(out *BitbucketInterceptor) { *out = *in if in.SecretRef != nil { in, out := &in.SecretRef, &out.SecretRef @@ -42,12 +42,12 @@ func (in *BitBucketInterceptor) DeepCopyInto(out *BitBucketInterceptor) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BitBucketInterceptor. -func (in *BitBucketInterceptor) DeepCopy() *BitBucketInterceptor { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BitbucketInterceptor. +func (in *BitbucketInterceptor) DeepCopy() *BitbucketInterceptor { if in == nil { return nil } - out := new(BitBucketInterceptor) + out := new(BitbucketInterceptor) in.DeepCopyInto(out) return out } @@ -175,7 +175,7 @@ func (in *EventInterceptor) DeepCopyInto(out *EventInterceptor) { } if in.Bitbucket != nil { in, out := &in.Bitbucket, &out.Bitbucket - *out = new(BitBucketInterceptor) + *out = new(BitbucketInterceptor) (*in).DeepCopyInto(*out) } return diff --git a/pkg/interceptors/bitbucket/bitbucket.go b/pkg/interceptors/bitbucket/bitbucket.go index ed7995ea64..1007ae8dc8 100644 --- a/pkg/interceptors/bitbucket/bitbucket.go +++ b/pkg/interceptors/bitbucket/bitbucket.go @@ -33,11 +33,11 @@ import ( type Interceptor struct { KubeClientSet kubernetes.Interface Logger *zap.SugaredLogger - Bitbucket *triggersv1.BitBucketInterceptor + Bitbucket *triggersv1.BitbucketInterceptor EventListenerNamespace string } -func NewInterceptor(bh *triggersv1.BitBucketInterceptor, k kubernetes.Interface, ns string, l *zap.SugaredLogger) interceptors.Interceptor { +func NewInterceptor(bh *triggersv1.BitbucketInterceptor, k kubernetes.Interface, ns string, l *zap.SugaredLogger) interceptors.Interceptor { return &Interceptor{ Logger: l, Bitbucket: bh, diff --git a/pkg/interceptors/bitbucket/bitbucket_test.go b/pkg/interceptors/bitbucket/bitbucket_test.go index 8dafe97b49..c32c28dbdb 100644 --- a/pkg/interceptors/bitbucket/bitbucket_test.go +++ b/pkg/interceptors/bitbucket/bitbucket_test.go @@ -42,14 +42,14 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { } tests := []struct { name string - Bitbucket *triggersv1.BitBucketInterceptor + Bitbucket *triggersv1.BitbucketInterceptor args args want []byte wantErr bool }{ { name: "no secret", - Bitbucket: &triggersv1.BitBucketInterceptor{}, + Bitbucket: &triggersv1.BitbucketInterceptor{}, args: args{ payload: ioutil.NopCloser(bytes.NewBufferString("somepayload")), signature: "foo", @@ -59,7 +59,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "invalid header for secret", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretName: "mysecret", SecretKey: "token", @@ -81,7 +81,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "valid header for secret", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretName: "mysecret", SecretKey: "token", @@ -106,7 +106,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "matching event", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ EventTypes: []string{"pr:opened", "repo:refs_changed"}, }, args: args{ @@ -118,7 +118,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "no matching event", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ EventTypes: []string{"pr:opened", "repo:refs_changed"}, }, args: args{ @@ -129,7 +129,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "valid header for secret and matching event", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretName: "mysecret", SecretKey: "token", @@ -156,7 +156,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "valid header for secret, but no matching event", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretName: "mysecret", SecretKey: "token", @@ -182,7 +182,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { }, { name: "invalid header for secret, but matching event", - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretName: "mysecret", SecretKey: "token", @@ -205,7 +205,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) { wantErr: true, }, { name: "nil body does not panic", - Bitbucket: &triggersv1.BitBucketInterceptor{}, + Bitbucket: &triggersv1.BitbucketInterceptor{}, args: args{ payload: nil, signature: "foo", diff --git a/pkg/sink/sink_test.go b/pkg/sink/sink_test.go index b1550d41a2..81e043b101 100644 --- a/pkg/sink/sink_test.go +++ b/pkg/sink/sink_test.go @@ -898,7 +898,7 @@ func TestHandleEventWithInterceptorsAndTriggerAuth(t *testing.T) { } -func TestHandleEventWithBitBucketInterceptors(t *testing.T) { +func TestHandleEventWithBitbucketInterceptors(t *testing.T) { eventBody := json.RawMessage(`{"repository": {"links": {"clone": [{"href": "testurl", "name": "ssh"}, {"href": "testurl", "name": "http"}]}}, "changes": [{"ref": {"displayId": "test-branch"}}]}`) tb, tt := getResources(t, "$(body.repository.links.clone[1].href)") @@ -924,7 +924,7 @@ func TestHandleEventWithBitBucketInterceptors(t *testing.T) { Bindings: []*triggersv1.EventListenerBinding{{Name: "tb", Kind: "TriggerBinding"}}, Template: triggersv1.EventListenerTemplate{Name: "tt"}, Interceptors: []*triggersv1.EventInterceptor{{ - Bitbucket: &triggersv1.BitBucketInterceptor{ + Bitbucket: &triggersv1.BitbucketInterceptor{ SecretRef: &triggersv1.SecretRef{ SecretKey: "secretKey", SecretName: "secret",