-
Notifications
You must be signed in to change notification settings - Fork 735
/
common.go
115 lines (100 loc) · 3.54 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
Copyright 2020 BlackRock, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package common
import (
"reflect"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
)
// Environment variables
const (
// EnvVarKubeConfig is the path to the Kubernetes configuration
EnvVarKubeConfig = "KUBECONFIG"
// EnvVarDebugLog is the env var to turn on the debug mode for logging
EnvVarDebugLog = "DEBUG_LOG"
// EnvImagePullPolicy is the env var to set container's ImagePullPolicy
EnvImagePullPolicy = "IMAGE_PULL_POLICY"
)
// EventBus related
const (
// EnvVarEventBusConfig refers to the eventbus config env
EnvVarEventBusConfig = "EVENTBUS_CONFIG"
// EnvVarEventBusSubject refers to the eventbus subject env
EnvVarEventBusSubject = "EVENTBUS_SUBJECT"
// volumeMount path for eventbus auth file
EventBusAuthFileMountPath = "/etc/eventbus/auth"
// Default NATS Streaming messages max age
NATSStreamingMaxAge = "72h"
// Default NATS Streaming max messages per channel
NATSStreamingMaxMsgs = uint64(1000000)
// Default NATS Streaming max subscriptions per channel
NATSStreamingMaxSubs = uint64(1000)
// Default NATS Streaming max total size of messages per channel
NATSStreamingMaxBytes = "1GB"
// Default NATS Streaming max size of message payload
NATSStreamingMaxPayload = "1MB"
// Default NATS Streaming RAFT heartbeat timeout
NATSStreamingRaftHeartbeatTimeout = "2s"
// Default NATS Streaming RAFT election timeout
NATSStreamingRaftElectionTimeout = "2s"
// Default NATS Streaming RAFT lease timeout
NATSStreamingRaftLeaseTimeout = "1s"
// Default NATS Streaming RAFT commit timeout
NATSStreamingRaftCommitTimeout = "100ms"
// Default EventBus name
DefaultEventBusName = "default"
)
// Sensor constants
const (
// EnvVarSensorObject refers to the env of based64 encoded sensor spec
EnvVarSensorObject = "SENSOR_OBJECT"
// SensorNamespace is used to get namespace where sensors are deployed
SensorNamespace = "SENSOR_NAMESPACE"
// LabelSensorName is label for sensor name
LabelSensorName = "sensor-name"
)
// EventSource
const (
// EnvVarEventSourceObject refers to the env of based64 encoded eventsource spec
EnvVarEventSourceObject = "EVENTSOURCE_OBJECT"
// EnvVarEventSource refers to event source name
EnvVarEventSource = "EVENT_SOURCE"
// LabelEventSourceName is the label for a event source
LabelEventSourceName = "eventsource-name"
)
var (
ErrNilEventSource = errors.New("event source can't be nil")
)
// Miscellaneous Labels
const (
// LabelOwnerName is the label for resource owner name
LabelOwnerName = "owner-name"
// AnnotationResourceSpecHash is the annotation of a K8s resource spec hash
AnnotationResourceSpecHash = "resource-spec-hash"
)
// various supported media types
const (
MediaTypeJSON string = "application/json"
MediaTypeYAML string = "application/yaml"
)
// Metrics releated
const (
EventSourceMetricsPort = 7777
SensorMetricsPort = 7777
ControllerMetricsPort = 7777
EventBusMetricsPort = 7777
)
var (
SecretKeySelectorType = reflect.TypeOf(&corev1.SecretKeySelector{})
ConfigMapKeySelectorType = reflect.TypeOf(&corev1.ConfigMapKeySelector{})
)