github.com/argoproj/argo-events@v1.9.1/pkg/apis/common/common.go (about) 1 /* 2 Copyright 2018 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 17 package common 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 ) 22 23 // EventSourceType is the type of event source 24 type EventSourceType string 25 26 // possible event source types 27 var ( 28 MinioEvent EventSourceType = "minio" 29 CalendarEvent EventSourceType = "calendar" 30 FileEvent EventSourceType = "file" 31 SFTPEvent EventSourceType = "sftp" 32 ResourceEvent EventSourceType = "resource" 33 WebhookEvent EventSourceType = "webhook" 34 AMQPEvent EventSourceType = "amqp" 35 KafkaEvent EventSourceType = "kafka" 36 MQTTEvent EventSourceType = "mqtt" 37 NATSEvent EventSourceType = "nats" 38 SNSEvent EventSourceType = "sns" 39 SQSEvent EventSourceType = "sqs" 40 PubSubEvent EventSourceType = "pubsub" 41 GerritEvent EventSourceType = "gerrit" 42 GithubEvent EventSourceType = "github" 43 GitlabEvent EventSourceType = "gitlab" 44 HDFSEvent EventSourceType = "hdfs" 45 SlackEvent EventSourceType = "slack" 46 StorageGridEvent EventSourceType = "storagegrid" 47 AzureEventsHub EventSourceType = "azureEventsHub" 48 AzureQueueStorage EventSourceType = "azureQueueStorage" 49 AzureServiceBus EventSourceType = "azureServiceBus" 50 StripeEvent EventSourceType = "stripe" 51 EmitterEvent EventSourceType = "emitter" 52 RedisEvent EventSourceType = "redis" 53 RedisStreamEvent EventSourceType = "redisStream" 54 NSQEvent EventSourceType = "nsq" 55 PulsarEvent EventSourceType = "pulsar" 56 GenericEvent EventSourceType = "generic" 57 BitbucketServerEvent EventSourceType = "bitbucketserver" 58 BitbucketEvent EventSourceType = "bitbucket" 59 ) 60 61 var ( 62 // RecreateStrategyEventSources refers to the list of event source types 63 // that need to use Recreate strategy for its Deployment 64 RecreateStrategyEventSources = []EventSourceType{ 65 AMQPEvent, 66 CalendarEvent, 67 KafkaEvent, 68 PubSubEvent, 69 AzureEventsHub, 70 AzureServiceBus, 71 NATSEvent, 72 MQTTEvent, 73 MinioEvent, 74 EmitterEvent, 75 NSQEvent, 76 PulsarEvent, 77 RedisEvent, 78 RedisStreamEvent, 79 ResourceEvent, 80 HDFSEvent, 81 FileEvent, 82 SFTPEvent, 83 GenericEvent, 84 } 85 ) 86 87 // TriggerType is the type of trigger 88 type TriggerType string 89 90 // possible trigger types 91 var ( 92 OpenWhiskTrigger TriggerType = "OpenWhisk" 93 ArgoWorkflowTrigger TriggerType = "ArgoWorkflow" 94 LambdaTrigger TriggerType = "Lambda" 95 CustomTrigger TriggerType = "Custom" 96 HTTPTrigger TriggerType = "HTTP" 97 KafkaTrigger TriggerType = "Kafka" 98 PulsarTrigger TriggerType = "Pulsar" 99 LogTrigger TriggerType = "Log" 100 NATSTrigger TriggerType = "NATS" 101 SlackTrigger TriggerType = "Slack" 102 K8sTrigger TriggerType = "Kubernetes" 103 AzureEventHubsTrigger TriggerType = "AzureEventHubs" 104 AzureServiceBusTrigger TriggerType = "AzureServiceBus" 105 EmailTrigger TriggerType = "Email" 106 ) 107 108 // EventBusType is the type of event bus 109 type EventBusType string 110 111 // possible event bus types 112 var ( 113 EventBusNATS EventBusType = "nats" 114 EventBusJetStream EventBusType = "jetstream" 115 EventBusKafka EventBusType = "kafka" 116 ) 117 118 // BasicAuth contains the reference to K8s secrets that holds the username and password 119 type BasicAuth struct { 120 // Username refers to the Kubernetes secret that holds the username required for basic auth. 121 Username *corev1.SecretKeySelector `json:"username,omitempty" protobuf:"bytes,1,opt,name=username"` 122 // Password refers to the Kubernetes secret that holds the password required for basic auth. 123 Password *corev1.SecretKeySelector `json:"password,omitempty" protobuf:"bytes,2,opt,name=password"` 124 } 125 126 // SecureHeader refers to HTTP Headers with auth tokens as values 127 type SecureHeader struct { 128 Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` 129 // Values can be read from either secrets or configmaps 130 ValueFrom *ValueFromSource `json:"valueFrom,omitempty" protobuf:"bytes,2,opt,name=valueFrom"` 131 } 132 133 // ValueFromSource allows you to reference keys from either a Configmap or Secret 134 type ValueFromSource struct { 135 SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef,omitempty" protobuf:"bytes,1,opt,name=secretKeyRef"` 136 ConfigMapKeyRef *corev1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,2,opt,name=configMapKeyRef"` 137 } 138 139 // TLSConfig refers to TLS configuration for a client. 140 type TLSConfig struct { 141 // CACertSecret refers to the secret that contains the CA cert 142 CACertSecret *corev1.SecretKeySelector `json:"caCertSecret,omitempty" protobuf:"bytes,1,opt,name=caCertSecret"` 143 // ClientCertSecret refers to the secret that contains the client cert 144 ClientCertSecret *corev1.SecretKeySelector `json:"clientCertSecret,omitempty" protobuf:"bytes,2,opt,name=clientCertSecret"` 145 // ClientKeySecret refers to the secret that contains the client key 146 ClientKeySecret *corev1.SecretKeySelector `json:"clientKeySecret,omitempty" protobuf:"bytes,3,opt,name=clientKeySecret"` 147 // If true, skips creation of TLSConfig with certs and creates an empty TLSConfig. (Defaults to false) 148 // +optional 149 InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty" protobuf:"varint,4,opt,name=insecureSkipVerify"` 150 } 151 152 // SASLConfig refers to SASL configuration for a client 153 type SASLConfig struct { 154 // SASLMechanism is the name of the enabled SASL mechanism. 155 // Possible values: OAUTHBEARER, PLAIN (defaults to PLAIN). 156 // +optional 157 Mechanism string `json:"mechanism,omitempty" protobuf:"bytes,1,opt,name=mechanism"` 158 // User is the authentication identity (authcid) to present for 159 // SASL/PLAIN or SASL/SCRAM authentication 160 UserSecret *corev1.SecretKeySelector `json:"userSecret,omitempty" protobuf:"bytes,2,opt,name=userSecret"` 161 // Password for SASL/PLAIN authentication 162 PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty" protobuf:"bytes,3,opt,name=passwordSecret"` 163 } 164 165 // SchemaRegistryConfig refers to configuration for a client 166 type SchemaRegistryConfig struct { 167 // Schema Registry URL. 168 URL string `json:"url" protobuf:"bytes,1,opt,name=url"` 169 // Schema ID 170 SchemaID int32 `json:"schemaId" protobuf:"varint,2,name=schemaId"` 171 // +optional 172 // SchemaRegistry - basic authentication 173 Auth BasicAuth `json:"auth,omitempty" protobuf:"bytes,3,opt,name=auth"` 174 } 175 176 // Backoff for an operation 177 type Backoff struct { 178 // The initial duration in nanoseconds or strings like "1s", "3m" 179 // +optional 180 Duration *Int64OrString `json:"duration,omitempty" protobuf:"bytes,1,opt,name=duration"` 181 // Duration is multiplied by factor each iteration 182 // +optional 183 Factor *Amount `json:"factor,omitempty" protobuf:"bytes,2,opt,name=factor"` 184 // The amount of jitter applied each iteration 185 // +optional 186 Jitter *Amount `json:"jitter,omitempty" protobuf:"bytes,3,opt,name=jitter"` 187 // Exit with error after this many steps 188 // +optional 189 Steps int32 `json:"steps,omitempty" protobuf:"varint,4,opt,name=steps"` 190 } 191 192 func (b Backoff) GetSteps() int { 193 return int(b.Steps) 194 } 195 196 // Metadata holds the annotations and labels of an event source pod 197 type Metadata struct { 198 Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,1,rep,name=annotations"` 199 Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,2,rep,name=labels"` 200 } 201 202 func (s SASLConfig) GetMechanism() string { 203 switch s.Mechanism { 204 case "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512", "GSSAPI": 205 return s.Mechanism 206 default: 207 // default to PLAINTEXT mechanism 208 return "PLAIN" 209 } 210 }