Documentation ¶
Index ¶
- Constants
- Variables
- func CheckEventSourceVersion(cm *corev1.ConfigMap) error
- func DefaultConfigMapName(controllerName string) string
- func DefaultEventSourceName(gatewayName string, configurationName string) string
- func DefaultNatsQueueName(subject string) string
- func DefaultServiceName(serviceName string) string
- func GenerateK8sEvent(clientset kubernetes.Interface, reason string, eventType K8sEventType, ...) error
- func GetClientConfig(kubeconfig string) (*rest.Config, error)
- func GetObjectHash(obj metav1.Object) (string, error)
- func Hasher(value string) string
- func IsRetryableKubeAPIError(err error) bool
- func NewArgoEventsLogger() *logrus.Logger
- func ParseExclusionDates(vals []string) ([]time.Time, error)
- func SendErrorResponse(writer http.ResponseWriter, response string)
- func SendInternalErrorResponse(writer http.ResponseWriter, response string)
- func SendSuccessResponse(writer http.ResponseWriter, response string)
- func ServerResourceForGroupVersionKind(disco discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (*metav1.APIResource, error)
- func ServiceDNSName(serviceName, namespace string) string
- type Backoff
- type K8sEventType
Constants ¶
const ( // ErrorResponse for http request ErrorResponse = "Error" // StandardTimeFormat is time format reference for golang StandardTimeFormat = "2006-01-02 15:04:05" // StandardYYYYMMDDFormat formats date in yyyy-mm-dd format StandardYYYYMMDDFormat = "2006-01-02" // DefaultControllerNamespace is the default namespace where the sensor and gateways controllers are installed DefaultControllerNamespace = "argo-events" )
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" )
ENV VARS
const ( // LabelOperation is a label for an operation in framework LabelOperation = "operation" // LabelEventSource is label for event name LabelEventSource = "event-source" )
LABELS
const ( // env variables constants //LabelKeySensorControllerInstanceID is the label which allows to separate application among multiple running sensor controllers. LabelKeySensorControllerInstanceID = sensor.FullName + "/sensor-controller-instanceid" // LabelSensorKeyPhase is a label applied to sensors to indicate the current phase of the sensor (for filtering purposes) LabelSensorKeyPhase = sensor.FullName + "/phase" // LabelSensorKeyComplete is the label to mark sensors as complete LabelSensorKeyComplete = sensor.FullName + "/complete" // EnvVarSensorControllerConfigMap is the name of the configmap to use for the sensor-controller EnvVarSensorControllerConfigMap = "SENSOR_CONFIG_MAP" // labels constants // LabelSensorControllerName is the default deployment name of the sensor-controller LabelSensorControllerName = "sensor-controller" LabelArgoEventsSensorVersion = "argo-events-sensor-version" // SensorControllerConfigMapKey is the key in the configmap to retrieve sensor configuration from. // Content encoding is expected to be YAML. SensorControllerConfigMapKey = "config" // miscellaneous constants // AnnotationSensorResourceSpecHashName is the annotation of a sensor resource spec hash AnnotationSensorResourceSpecHashName = sensor.FullName + "/resource-spec-hash" )
SENSOR CONTROLLER CONSTANTS
const ( // SensorServiceEndpoint is the endpoint to dispatch the event to SensorServiceEndpoint = "/" // 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" // EnvVarSensorControllerInstanceID is used to get sensor controller instance id EnvVarSensorControllerInstanceID = "SENSOR_CONTROLLER_INSTANCE_ID" )
SENSOR CONSTANTS
const ( // env variables // EnvVarGatewayControllerConfigMap contains name of the configmap to retrieve gateway-controller configuration from EnvVarGatewayControllerConfigMap = "GATEWAY_CONTROLLER_CONFIG_MAP" // EnvVarGatewayControllerInstanceID is used to get gateway controller instance id EnvVarGatewayControllerInstanceID = "GATEWAY_CONTROLLER_INSTANCE_ID" // EnvVarGatewayControllerName is used to get name of gateway controller EnvVarGatewayControllerName = "GATEWAY_CONTROLLER_NAME" // EnvVarGatewayName refers env var for name of gateway EnvVarGatewayName = "GATEWAY_NAME" // EnvVarGatewayNamespace is namespace where gateway controller is deployed EnvVarGatewayNamespace = "GATEWAY_NAMESPACE" // labels // LabelGatewayControllerName is the default deployment name of the gateway-controller-controller LabelGatewayControllerName = "gateway-controller" //LabelKeyGatewayControllerInstanceID is the label which allows to separate application among multiple running gateway-controller controllers. LabelKeyGatewayControllerInstanceID = gateway.FullName + "/gateway-controller-instanceid" // LabelGatewayKeyPhase is a label applied to gateways to indicate the current phase of the gateway-controller (for filtering purposes) LabelGatewayKeyPhase = gateway.FullName + "/phase" // LabelGatewayName is the label for gateway name LabelGatewayName = "gateway-name" // LabelArgoEventsGatewayVersion is the label for the gateway version LabelArgoEventsGatewayVersion = "argo-events-gateway-version" // AnnotationGatewayResourceSpecHashName is the annotation of a gateway resource spec hash AnnotationGatewayResourceSpecHashName = gateway.FullName + "/resource-spec-hash" // GatewayControllerConfigMapKey is the key in the configmap to retrieve gateway-controller configuration from. // Content encoding is expected to be YAML. GatewayControllerConfigMapKey = "config" )
GATEWAY CONTROLLER CONSTANTS
const ( // LabelGatewayEventSourceName is the label for a event source in gateway LabelGatewayEventSourceName = "event-source-name" // LabelGatewayEventSourceID is the label for gateway configuration ID LabelGatewayEventSourceID = "event-source-id" // LabelArgoEventsEventSourceVersion is the label for event source version LabelArgoEventsEventSourceVersion = "argo-events-event-source-version" // EnvVarGatewayEventSourceConfigMap is used to get map containing event sources to run in a gateway EnvVarGatewayEventSourceConfigMap = "GATEWAY_EVENT_SOURCE_CONFIG_MAP" EnvVarGatewayServerPort = "GATEWAY_SERVER_PORT" // Server Connection Timeout, 10 seconds ServerConnTimeout = 10 )
GATEWAY CONSTANTS
const ( LabelNamespace = "namespace" LabelPhase = "phase" LabelInstanceID = "instance-id" LabelPodName = "pod-name" LabelServiceName = "svc-name" LabelEndpoint = "endpoint" LabelPort = "port" LabelURL = "url" LabelNodeName = "node-name" LabelNodeType = "node-type" LabelHTTPMethod = "http-method" LabelClientID = "client-id" LabelVersion = "version" LabelTime = "time" LabelTriggerName = "trigger-name" )
Logger constants
const ( // CloudEventsVersion is the version of the CloudEvents spec targeted+ // by this library. CloudEventsVersion = "0.1" )
CloudEvents constants
const (
// LabelEventType is label for k8 event type
LabelEventType = "event-type"
)
Variables ¶
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
Functions ¶
func CheckEventSourceVersion ¶
func DefaultConfigMapName ¶
DefaultConfigMapName returns a formulated name for a configmap name based on the sensor-controller deployment name
func DefaultEventSourceName ¶
DefaultEventSourceName returns a formulated name for a gateway configuration
func DefaultNatsQueueName ¶
DefaultNatsQueueName returns a queue name for nats subject
func DefaultServiceName ¶
DefaultServiceName returns a formulated name for a service
func GenerateK8sEvent ¶
func GenerateK8sEvent(clientset kubernetes.Interface, reason string, eventType K8sEventType, action string, name, namespace, instanceId, kind string, labels map[string]string) error
GenerateK8sEvent generates a kubernetes event
func GetClientConfig ¶
GetClientConfig return rest config, if path not specified, assume in cluster config
func GetObjectHash ¶
GetObjectHash returns hash of a given object
func IsRetryableKubeAPIError ¶
IsRetryableKubeAPIError returns if the error is a retryable kubernetes error
func NewArgoEventsLogger ¶
NewArgoEventsLogger returns a new ArgoEventsLogger
func ParseExclusionDates ¶
ParseExclusionDates parses the exclusion dates from the vals string according to RFC 5545
func SendErrorResponse ¶
func SendErrorResponse(writer http.ResponseWriter, response string)
SendErrorResponse sends http error response
func SendInternalErrorResponse ¶
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
func ServerResourceForGroupVersionKind ¶
func ServerResourceForGroupVersionKind(disco discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (*metav1.APIResource, error)
ServerResourceForGroupVersionKind finds the API resources that fit the GroupVersionKind schema
func ServiceDNSName ¶
ServiceDNSName returns a formulated dns name for a service
Types ¶
type Backoff ¶
type Backoff struct { Duration time.Duration `json:"duration"` // the base duration Factor float64 `json:"factor"` // Duration is multiplied by factor each iteration Jitter float64 `json:"jitter"` // The amount of jitter applied each iteration Steps int `json:"steps"` // Exit with error after this many steps }
Backoff defines an operational backoff
type K8sEventType ¶
type K8sEventType string
K8sEventType is the type of event generated to indicate change in state of resource
var ( EscalationEventType K8sEventType = "Escalation" StateChangeEventType K8sEventType = "StateChange" OperationFailureEventType K8sEventType = "OperationFailed" OperationSuccessEventType K8sEventType = "OperationSuccessful" )
Possible values for K8sEventType