github.com/argoproj/argo-events@v1.9.1/eventsources/sources/bitbucket/validate.go (about) 1 /* 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package bitbucket 17 18 import ( 19 "context" 20 "fmt" 21 22 "github.com/argoproj/argo-events/common" 23 "github.com/argoproj/argo-events/eventsources/common/webhook" 24 "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" 25 ) 26 27 // ValidateEventSource validates bitbucketserver event source 28 func (el *EventListener) ValidateEventSource(ctx context.Context) error { 29 return validate(&el.BitbucketEventSource) 30 } 31 32 func validate(eventSource *v1alpha1.BitbucketEventSource) error { 33 if eventSource == nil { 34 return common.ErrNilEventSource 35 } 36 if eventSource.GetBitbucketRepositories() == nil { 37 return fmt.Errorf("at least one repository is required") 38 } 39 if eventSource.ShouldCreateWebhooks() && len(eventSource.Events) == 0 { 40 return fmt.Errorf("events must be defined to create a bitbucket webhooks") 41 } 42 return webhook.ValidateWebhookContext(eventSource.Webhook) 43 }