Documentation ¶
Index ¶
- Constants
- Variables
- func Convert2WaitBackoff(backoff *apicommon.Backoff) (*wait.Backoff, error)
- func DoWithRetry(backoff *apicommon.Backoff, f func() error) error
- func ElementsMatch(first []string, second []string) bool
- func ErrEventSourceTypeMismatch(eventSourceType string) string
- func FormatEndpoint(endpoint string) string
- func FormattedURL(url, endpoint string) string
- func GenerateConfigMapVolumeSpecs(selector *v1.ConfigMapKeySelector) (v1.Volume, v1.VolumeMount)
- func GenerateEnvFromConfigMapSpec(selector *v1.ConfigMapKeySelector) v1.EnvFromSource
- func GenerateEnvFromSecretSpec(selector *v1.SecretKeySelector) v1.EnvFromSource
- func GenerateSecretVolumeSpecs(selector *v1.SecretKeySelector) (v1.Volume, v1.VolumeMount)
- func GetClientConfig(kubeconfig string) (*rest.Config, error)
- func GetConfigMapFromVolume(selector *v1.ConfigMapKeySelector) (string, error)
- func GetConfigMapVolumePath(selector *v1.ConfigMapKeySelector) (string, error)
- func GetEnvFromConfigMap(selector *v1.ConfigMapKeySelector) (string, bool)
- func GetEnvFromSecret(selector *v1.SecretKeySelector) (string, bool)
- func GetImagePullPolicy() v1.PullPolicy
- func GetObjectHash(obj metav1.Object) (string, error)
- func GetSaramaConfigFromYAMLString(yaml string) (*sarama.Config, error)
- func GetSecretFromVolume(selector *v1.SecretKeySelector) (string, error)
- func GetSecretValue(ctx context.Context, client kubernetes.Interface, namespace string, ...) (string, error)
- func GetSecretVolumePath(selector *v1.SecretKeySelector) (string, error)
- func GetTLSConfig(config *apicommon.TLSConfig) (*tls.Config, error)
- func Hasher(value string) string
- func IsRetryableKubeAPIError(err error) bool
- func MustHash(v interface{}) string
- func MustJSON(in interface{}) string
- func MustUnJSON(v interface{}, in interface{})
- func ParseExclusionDates(vals []string) ([]time.Time, error)
- func ParseTime(t string, baseDate time.Time) (time.Time, error)
- func PrevCronTime(cronSpec string, parser cronlib.Parser, t time.Time) (time.Time, error)
- func RandomString(length int) string
- func SendErrorResponse(writer http.ResponseWriter, response string)
- func SendInternalErrorResponse(writer http.ResponseWriter, response string)
- func SendResponse(writer http.ResponseWriter, statusCode int, response string)
- func SendSuccessResponse(writer http.ResponseWriter, response string)
- func SliceContains(strSlice []string, targetStr string) bool
- func StructToMap(obj interface{}, output map[string]interface{}) error
- func ViperWithLogging() *viper.Viper
- func VolumesFromSecretsOrConfigMaps(t reflect.Type, objs ...interface{}) ([]v1.Volume, []v1.VolumeMount)
- type StringKeyedMap
- type XDGSCRAMClient
Constants ¶
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" // ENVVarPodName should be set to the name of the pod EnvVarPodName = "POD_NAME" // ENVVarLeaderElection sets the leader election mode EnvVarLeaderElection = "LEADER_ELECTION" // EnvImagePullPolicy is the env var to set container's ImagePullPolicy EnvImagePullPolicy = "IMAGE_PULL_POLICY" )
Environment variables
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 STANMaxAge = "72h" // Default NATS Streaming max messages per channel STANMaxMsgs = uint64(1000000) // Default NATS Streaming max subscriptions per channel STANMaxSubs = uint64(1000) // Default NATS Streaming max total size of messages per channel STANMaxBytes = "1GB" // Default NATS Streaming max size of message payload STANMaxPayload = "1MB" // Default NATS Streaming RAFT heartbeat timeout STANRaftHeartbeatTimeout = "2s" // Default NATS Streaming RAFT election timeout STANRaftElectionTimeout = "2s" // Default NATS Streaming RAFT lease timeout STANRaftLeaseTimeout = "1s" // Default NATS Streaming RAFT commit timeout STANRaftCommitTimeout = "100ms" // Default EventBus name DefaultEventBusName = "default" // key of auth server secret JetStreamServerSecretAuthKey = "auth" // key of encryption server secret JetStreamServerSecretEncryptionKey = "encryption" // key of client auth secret JetStreamClientAuthSecretKey = "client-auth" // key for server private key JetStreamServerPrivateKeyKey = "private-key" // key for server TLS certificate JetStreamServerCertKey = "cert" // key for server CA certificate JetStreamServerCACertKey = "ca-cert" // key for server private key JetStreamClusterPrivateKeyKey = "cluster-private-key" // key for server TLS certificate JetStreamClusterCertKey = "cluster-cert" // key for server CA certificate JetStreamClusterCACertKey = "cluster-ca-cert" // key of nats-js.conf in the configmap JetStreamConfigMapKey = "nats-js" // Jetstream Stream name JetStreamStreamName = "default" // Default JetStream max size of message payload JetStreamMaxPayload = "1MB" )
EventBus related
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" )
Sensor constants
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" )
EventSource
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" // AnnotationLeaderElection is the annotation for leader election AnnotationLeaderElection = "events.argoproj.io/leader-election" )
Miscellaneous Labels
const ( MediaTypeJSON string = "application/json" MediaTypeYAML string = "application/yaml" )
various supported media types
const ( EventSourceMetricsPort = 7777 SensorMetricsPort = 7777 ControllerMetricsPort = 7777 EventBusMetricsPort = 7777 ControllerHealthPort = 8081 )
Metrics releated
Variables ¶
var ( SecretKeySelectorType = reflect.TypeOf(&corev1.SecretKeySelector{}) ConfigMapKeySelectorType = reflect.TypeOf(&corev1.ConfigMapKeySelector{}) )
var ( SHA256New scram.HashGeneratorFcn = sha256.New SHA512New scram.HashGeneratorFcn = sha512.New )
var (
DefaultBackoff = apicommon.Backoff{
Steps: 5,
Duration: &defaultDuration,
Factor: &defaultFactor,
Jitter: &defaultJitter,
}
)
var (
ErrNilEventSource = fmt.Errorf("event source can't be nil")
)
Functions ¶
func Convert2WaitBackoff ¶ added in v1.3.0
Convert2WaitBackoff converts to a wait backoff option
func DoWithRetry ¶ added in v1.7.3
func ElementsMatch ¶ added in v1.6.0
ElementsMatch returns true if the two provided string slices contain the same elements while avoiding duplications. WARN: this method avoids duplications.
func ErrEventSourceTypeMismatch ¶ added in v0.13.0
func FormatEndpoint ¶ added in v0.13.0
FormatEndpoint returns a formatted api endpoint
func FormattedURL ¶ added in v0.13.0
FormattedURL returns a formatted url
func GenerateConfigMapVolumeSpecs ¶ added in v1.0.0
func GenerateConfigMapVolumeSpecs(selector *v1.ConfigMapKeySelector) (v1.Volume, v1.VolumeMount)
GenerateConfigMapVolumeSpecs builds a "volume" and "volumeMount"spec with a configMapKeySelector
func GenerateEnvFromConfigMapSpec ¶ added in v0.17.0
func GenerateEnvFromConfigMapSpec(selector *v1.ConfigMapKeySelector) v1.EnvFromSource
GenerateEnvFromConfigMapSpec builds a "envFrom" spec with a configMapKeySelector
func GenerateEnvFromSecretSpec ¶ added in v0.17.0
func GenerateEnvFromSecretSpec(selector *v1.SecretKeySelector) v1.EnvFromSource
GenerateEnvFromSecretSpec builds a "envFrom" spec with a secretKeySelector
func GenerateSecretVolumeSpecs ¶ added in v1.0.0
func GenerateSecretVolumeSpecs(selector *v1.SecretKeySelector) (v1.Volume, v1.VolumeMount)
GenerateSecretVolumeSpecs builds a "volume" and "volumeMount"spec with a secretKeySelector
func GetClientConfig ¶
GetClientConfig return rest config, if path not specified, assume in cluster config
func GetConfigMapFromVolume ¶ added in v1.0.0
func GetConfigMapFromVolume(selector *v1.ConfigMapKeySelector) (string, error)
GetConfigMapFromVolume retrieves the value of mounted config map volume "/argo-events/config/${configMapRef.name}/${configMapRef.key}" is expected to be the file path
func GetConfigMapVolumePath ¶ added in v1.0.0
func GetConfigMapVolumePath(selector *v1.ConfigMapKeySelector) (string, error)
GetConfigMapVolumePath returns the path of the mounted configmap
func GetEnvFromConfigMap ¶ added in v0.17.0
func GetEnvFromConfigMap(selector *v1.ConfigMapKeySelector) (string, bool)
GetEnvFromConfigMap retrieves the value of envFrom.configMapRef "${configMapRef.name}_" is expected to be defined as "prefix"
func GetEnvFromSecret ¶ added in v0.17.0
func GetEnvFromSecret(selector *v1.SecretKeySelector) (string, bool)
GetEnvFromSecret retrieves the value of envFrom.secretRef "${secretRef.name}_" is expected to be defined as "prefix"
func GetImagePullPolicy ¶ added in v1.6.0
func GetImagePullPolicy() v1.PullPolicy
func GetObjectHash ¶ added in v0.8.2
GetObjectHash returns hash of a given object
func GetSaramaConfigFromYAMLString ¶ added in v1.7.2
GetSaramaConfigFromYAMLString parse yaml string to sarama.config. Note: All the time.Duration config can not be correctly decoded because it does not implement the decode function.
func GetSecretFromVolume ¶ added in v1.0.0
func GetSecretFromVolume(selector *v1.SecretKeySelector) (string, error)
GetSecretFromVolume retrieves the value of mounted secret volume "/argo-events/secrets/${secretRef.name}/${secretRef.key}" is expected to be the file path
func GetSecretValue ¶ added in v0.14.0
func GetSecretValue(ctx context.Context, client kubernetes.Interface, namespace string, selector *v1.SecretKeySelector) (string, error)
GetSecretValue retrieves the secret value from the secret in namespace with name and key
func GetSecretVolumePath ¶ added in v1.0.0
func GetSecretVolumePath(selector *v1.SecretKeySelector) (string, error)
GetSecretVolumePath returns the path of the mounted secret
func GetTLSConfig ¶ added in v0.14.0
GetTLSConfig returns a tls configuration for given cert and key or skips the certs if InsecureSkipVerify is true.
func IsRetryableKubeAPIError ¶
IsRetryableKubeAPIError returns if the error is a retryable kubernetes error
func MustUnJSON ¶ added in v1.7.0
func MustUnJSON(v interface{}, in interface{})
MustUnJSON unmarshalls JSON or panics. v - must be []byte or string in - must be a pointer.
func ParseExclusionDates ¶
ParseExclusionDates parses the exclusion dates from the vals string according to RFC 5545
func ParseTime ¶ added in v0.17.0
ParseTime parses time string in "HH:MM:SS" format into time.Time, which date is same as baseDate in UTC.
func PrevCronTime ¶ added in v1.6.0
For a given cron specification, return the previous activation time If no time can be found to satisfy the schedule, return the zero time.
func RandomString ¶ added in v1.7.0
generate a random string with given length
func SendErrorResponse ¶
func SendErrorResponse(writer http.ResponseWriter, response string)
SendErrorResponse sends http error response
func SendInternalErrorResponse ¶ added in v0.8.3
func SendInternalErrorResponse(writer http.ResponseWriter, response string)
SendInternalErrorResponse sends http internal error response
func SendResponse ¶ added in v1.0.0
func SendResponse(writer http.ResponseWriter, statusCode int, response string)
SendResponse sends http response with given status code
func SendSuccessResponse ¶
func SendSuccessResponse(writer http.ResponseWriter, response string)
SendSuccessResponse sends http success response
func SliceContains ¶ added in v1.6.0
SliceContains checks if a string slice contains a specific string
func StructToMap ¶ added in v1.7.0
func ViperWithLogging ¶ added in v1.9.2
func VolumesFromSecretsOrConfigMaps ¶ added in v1.0.0
func VolumesFromSecretsOrConfigMaps(t reflect.Type, objs ...interface{}) ([]v1.Volume, []v1.VolumeMount)
VolumesFromSecretsOrConfigMaps builds volumes and volumeMounts spec based on the obj and its children's secretKeyselector or configMapKeySelector
Types ¶
type StringKeyedMap ¶ added in v1.9.0
type StringKeyedMap[T any] struct { // contains filtered or unexported fields }
Concurrent Safe String keyed map
func NewStringKeyedMap ¶ added in v1.9.0
func NewStringKeyedMap[T any]() StringKeyedMap[T]
func (*StringKeyedMap[T]) Delete ¶ added in v1.9.0
func (sm *StringKeyedMap[T]) Delete(key string)
func (*StringKeyedMap[T]) Load ¶ added in v1.9.0
func (sm *StringKeyedMap[T]) Load(key string) (T, bool)
func (*StringKeyedMap[T]) Store ¶ added in v1.9.0
func (sm *StringKeyedMap[T]) Store(key string, item T)
type XDGSCRAMClient ¶ added in v1.7.2
type XDGSCRAMClient struct { *scram.Client *scram.ClientConversation scram.HashGeneratorFcn }
func (*XDGSCRAMClient) Begin ¶ added in v1.7.2
func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error)
func (*XDGSCRAMClient) Done ¶ added in v1.7.2
func (x *XDGSCRAMClient) Done() bool