github.com/argoproj/argo-events@v1.9.1/common/common.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 17 package common 18 19 import ( 20 "fmt" 21 "reflect" 22 23 corev1 "k8s.io/api/core/v1" 24 ) 25 26 // Environment variables 27 const ( 28 // EnvVarKubeConfig is the path to the Kubernetes configuration 29 EnvVarKubeConfig = "KUBECONFIG" 30 // EnvVarDebugLog is the env var to turn on the debug mode for logging 31 EnvVarDebugLog = "DEBUG_LOG" 32 // ENVVarPodName should be set to the name of the pod 33 EnvVarPodName = "POD_NAME" 34 // ENVVarLeaderElection sets the leader election mode 35 EnvVarLeaderElection = "LEADER_ELECTION" 36 // EnvImagePullPolicy is the env var to set container's ImagePullPolicy 37 EnvImagePullPolicy = "IMAGE_PULL_POLICY" 38 ) 39 40 // EventBus related 41 const ( 42 // EnvVarEventBusConfig refers to the eventbus config env 43 EnvVarEventBusConfig = "EVENTBUS_CONFIG" 44 // EnvVarEventBusSubject refers to the eventbus subject env 45 EnvVarEventBusSubject = "EVENTBUS_SUBJECT" 46 // volumeMount path for eventbus auth file 47 EventBusAuthFileMountPath = "/etc/eventbus/auth" 48 // Default NATS Streaming messages max age 49 STANMaxAge = "72h" 50 // Default NATS Streaming max messages per channel 51 STANMaxMsgs = uint64(1000000) 52 // Default NATS Streaming max subscriptions per channel 53 STANMaxSubs = uint64(1000) 54 // Default NATS Streaming max total size of messages per channel 55 STANMaxBytes = "1GB" 56 // Default NATS Streaming max size of message payload 57 STANMaxPayload = "1MB" 58 // Default NATS Streaming RAFT heartbeat timeout 59 STANRaftHeartbeatTimeout = "2s" 60 // Default NATS Streaming RAFT election timeout 61 STANRaftElectionTimeout = "2s" 62 // Default NATS Streaming RAFT lease timeout 63 STANRaftLeaseTimeout = "1s" 64 // Default NATS Streaming RAFT commit timeout 65 STANRaftCommitTimeout = "100ms" 66 67 // Default EventBus name 68 DefaultEventBusName = "default" 69 70 // key of auth server secret 71 JetStreamServerSecretAuthKey = "auth" 72 // key of encryption server secret 73 JetStreamServerSecretEncryptionKey = "encryption" 74 // key of client auth secret 75 JetStreamClientAuthSecretKey = "client-auth" 76 // key for server private key 77 JetStreamServerPrivateKeyKey = "private-key" 78 // key for server TLS certificate 79 JetStreamServerCertKey = "cert" 80 // key for server CA certificate 81 JetStreamServerCACertKey = "ca-cert" 82 // key for server private key 83 JetStreamClusterPrivateKeyKey = "cluster-private-key" 84 // key for server TLS certificate 85 JetStreamClusterCertKey = "cluster-cert" 86 // key for server CA certificate 87 JetStreamClusterCACertKey = "cluster-ca-cert" 88 // key of nats-js.conf in the configmap 89 JetStreamConfigMapKey = "nats-js" 90 // Jetstream Stream name 91 JetStreamStreamName = "default" 92 // Default JetStream max size of message payload 93 JetStreamMaxPayload = "1MB" 94 ) 95 96 // Sensor constants 97 const ( 98 // EnvVarSensorObject refers to the env of based64 encoded sensor spec 99 EnvVarSensorObject = "SENSOR_OBJECT" 100 // SensorNamespace is used to get namespace where sensors are deployed 101 SensorNamespace = "SENSOR_NAMESPACE" 102 // LabelSensorName is label for sensor name 103 LabelSensorName = "sensor-name" 104 ) 105 106 // EventSource 107 const ( 108 // EnvVarEventSourceObject refers to the env of based64 encoded eventsource spec 109 EnvVarEventSourceObject = "EVENTSOURCE_OBJECT" 110 // EnvVarEventSource refers to event source name 111 EnvVarEventSource = "EVENT_SOURCE" 112 // LabelEventSourceName is the label for a event source 113 LabelEventSourceName = "eventsource-name" 114 ) 115 116 var ( 117 ErrNilEventSource = fmt.Errorf("event source can't be nil") 118 ) 119 120 // Miscellaneous Labels 121 const ( 122 // LabelOwnerName is the label for resource owner name 123 LabelOwnerName = "owner-name" 124 // AnnotationResourceSpecHash is the annotation of a K8s resource spec hash 125 AnnotationResourceSpecHash = "resource-spec-hash" 126 // AnnotationLeaderElection is the annotation for leader election 127 AnnotationLeaderElection = "events.argoproj.io/leader-election" 128 ) 129 130 // various supported media types 131 const ( 132 MediaTypeJSON string = "application/json" 133 MediaTypeYAML string = "application/yaml" 134 ) 135 136 // Metrics releated 137 const ( 138 EventSourceMetricsPort = 7777 139 SensorMetricsPort = 7777 140 ControllerMetricsPort = 7777 141 EventBusMetricsPort = 7777 142 ControllerHealthPort = 8081 143 ) 144 145 var ( 146 SecretKeySelectorType = reflect.TypeOf(&corev1.SecretKeySelector{}) 147 ConfigMapKeySelectorType = reflect.TypeOf(&corev1.ConfigMapKeySelector{}) 148 )