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