common

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2020 License: Apache-2.0 Imports: 23 Imported by: 90

Documentation

Index

Constants

View Source
const (
	// EnvVarKubeConfig is the path to the Kubernetes configuration
	EnvVarKubeConfig = "KUBE_CONFIG"
	// EnvVarDebugLog is the env var to turn on the debug mode for logging
	EnvVarDebugLog = "DEBUG_LOG"
)

Environment variables

View Source
const (
	// EnvVarControllerConfigMap contains name of the configmap to retrieve controller configuration from
	EnvVarControllerConfigMap = "CONTROLLER_CONFIG_MAP"
	// EnvVarControllerInstanceID is used to get controller instance id
	EnvVarControllerInstanceID = "CONTROLLER_INSTANCE_ID"
	// EnvVarResourceName refers env var for name of the resource
	EnvVarResourceName = "NAME"
	// EnvVarNamespace refers to a K8s namespace
	EnvVarNamespace = "NAMESPACE"
	// EnvVarGatewayClientImage refers to the env var for gateway client image
	EnvVarGatewayClientImage = "GATEWAY_CLIENT_IMAGE"
	// EnvVarGatewayServerImage refers to the default gateway server image
	EnvVarGatewayServerImage = "GATEWAY_SERVER_IMAGE"
	// EnvVarSensorImage refers to the default sensor image
	EnvVarSensorImage = "SENSOR_IMAGE"
	// EnvVarSensorObject refers to the env of based64 encoded sensor spec
	EnvVarSensorObject = "SENSOR_OBJECT"
	// EnvVarEventSourceObject refers to the env of based64 encoded eventsource spec
	EnvVarEventSourceObject = "EVENTSOURCE_OBJECT"
)

Controller environment variables

View Source
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"
)

EventBus related

View Source
const (
	// SensorName refers env var for name of sensor
	SensorName = "SENSOR_NAME"
	// SensorNamespace is used to get namespace where sensors are deployed
	SensorNamespace = "SENSOR_NAMESPACE"
	// LabelSensorName is label for sensor name
	LabelSensorName = "sensor-name"
	// Port for the sensor server to listen events on
	SensorServerPort = 9300
)

Sensor constants

View Source
const (
	// LabelEventSourceName is the label for a event source
	LabelEventSourceName    = "eventsource-name"
	EnvVarGatewayServerPort = "GATEWAY_SERVER_PORT"
	// ProcessorPort is the default port for the gateway event processor server to run on.
	GatewayProcessorPort = "9300"
	//LabelGatewayName is the label for gateway name
	LabelGatewayName = "gateway-name"
)

Gateway constants

View Source
const (
	// EnvVarEventSource refers to event source name
	EnvVarEventSource = "EVENT_SOURCE"
	// AnnotationResourceSpecHash is the annotation of a K8s resource spec hash
	AnnotationResourceSpecHash = "resource-spec-hash"
)
View Source
const (
	// LabelEventSource is label for event name
	LabelEventSource = "event-source"
	// LabelOwnerName is the label for resource owner name
	LabelOwnerName = "owner-name"
	// LabelObjectName is the label for object name
	LabelObjectName = "object-name"
)

Miscellaneous Labels

View Source
const (
	MediaTypeJSON string = "application/json"
	MediaTypeYAML string = "application/yaml"
)

various supported media types

View Source
const (
	// GatewayControllerConfigMapKey is the key in the configmap to retrieve controller configuration from.
	// Content encoding is expected to be YAML.
	ControllerConfigMapKey = "config"
)
View Source
const (
	// DefaultControllerNamespace is the default namespace where the sensor and gateways controllers are installed
	DefaultControllerNamespace = "argo-events"
)

Defaults

View Source
const (
	// LabelGatewayName is the label for the K8s resource name
	LabelResourceName = "resource-name"
)

Controller labels

Variables

View Source
var DefaultRetry = wait.Backoff{
	Steps:    5,
	Duration: 10 * time.Millisecond,
	Factor:   1.0,
	Jitter:   0.1,
}

DefaultRetry is a default retry backoff settings when retrying API calls

View Source
var (
	ErrNilEventSource = errors.New("event source can't be nil")
)

Functions

func ErrEventSourceTypeMismatch added in v0.13.0

func ErrEventSourceTypeMismatch(eventSourceType string) string

func FormatEndpoint added in v0.13.0

func FormatEndpoint(endpoint string) string

FormatEndpoint returns a formatted api endpoint

func FormattedURL added in v0.13.0

func FormattedURL(url, endpoint string) string

FormattedURL returns a formatted url

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 GetClientConfig

func GetClientConfig(kubeconfig string) (*rest.Config, error)

GetClientConfig return rest config, if path not specified, assume in cluster config

func GetConnectionBackoff added in v0.13.0

func GetConnectionBackoff(backoff *apicommon.Backoff) *wait.Backoff

GetConnectionBackoff returns a connection backoff option

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 GetObjectHash added in v0.8.2

func GetObjectHash(obj metav1.Object) (string, error)

GetObjectHash returns hash of a given object

func GetSecretValue added in v0.14.0

func GetSecretValue(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 GetTLSConfig added in v0.14.0

func GetTLSConfig(caCertPath, clientCertPath, clientKeyPath string) (*tls.Config, error)

GetTLSConfig returns a tls configuration for given cert and key.

func Hasher added in v0.8.2

func Hasher(value string) string

Hasher hashes a string

func IsRetryableKubeAPIError

func IsRetryableKubeAPIError(err error) bool

IsRetryableKubeAPIError returns if the error is a retryable kubernetes error

func ParseExclusionDates

func ParseExclusionDates(vals []string) ([]time.Time, error)

ParseExclusionDates parses the exclusion dates from the vals string according to RFC 5545

func ParseTime added in v0.17.0

func ParseTime(t string, baseDate time.Time) (time.Time, error)

ParseTime parses time string in "HH:MM:SS" format into time.Time, which date is same as baseDate in UTC.

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 SendSuccessResponse

func SendSuccessResponse(writer http.ResponseWriter, response string)

SendSuccessResponse sends http success response

Types

type Minifier added in v0.17.0

type Minifier interface {
	GetExpression() string
}

Minifier is a bool expression minifier

func NewBoolExpression added in v0.17.0

func NewBoolExpression(expression string) (Minifier, error)

NewBoolExpression returns a Minifier instance It is used to simplify boolean epressions. For example, "(a || b || c) && (a && b)" can be simplified as "a && b" It is achieved by using Quine–McCluskey algorithm. See https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL