Documentation ¶
Index ¶
- Constants
- Variables
- 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 GetLoggerContext(opt zerolog.ConsoleWriter) zerolog.Context
- func GetObjectHash(obj metav1.Object) (string, error)
- func Hasher(value string) string
- func IsRetryableKubeAPIError(err error) bool
- func LoggerConf() zerolog.ConsoleWriter
- 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)
- type K8sEventType
Constants ¶
const ( // EnvVarKubeConfig is the path to the Kubernetes configuration EnvVarKubeConfig = "KUBE_CONFIG" // SuccessResponse for http request SuccessResponse = "Success" // 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 ( // DefaultSensorControllerDeploymentName is the default deployment name of the sensor-controller DefaultSensorControllerDeploymentName = "sensor-controller" // SensorControllerConfigMapKey is the key in the configmap to retrieve sensor configuration from. // Content encoding is expected to be YAML. SensorControllerConfigMapKey = "config" //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" // 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" // LabelOperation is a label for an operation in framework LabelOperation = "operation" // LabelEventSource is label for event name LabelEventSource = "event-name" // EnvVarSensorControllerInstanceID is used to get sensor controller instance id EnvVarSensorControllerInstanceID = "SENSOR_CONTROLLER_INSTANCE_ID" )
SENSOR CONSTANTS
const ( // DefaultGatewayControllerDeploymentName is the default deployment name of the gateway-controller-controller DefaultGatewayControllerDeploymentName = "gateway-controller" // 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" // GatewayControllerConfigMapKey is the key in the configmap to retrieve gateway-controller configuration from. // Content encoding is expected to be YAML. GatewayControllerConfigMapKey = "config" // EnvVarGatewayName refers env var for name of gateway EnvVarGatewayName = "GATEWAY_NAME" // EnvVarGatewayNamespace is namespace where gateway controller is deployed EnvVarGatewayNamespace = "GATEWAY_NAMESPACE" //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" // LabelGatewayEventSourceName is the label for a event source in gateway LabelGatewayEventSourceName = "config-name" // LabelGatewayEventSourceID is the label for gateway configuration ID LabelGatewayEventSourceID = "event-source-id" // AnnotationGatewayResourceSpecHashName is the annotation of a gateway resource spec hash AnnotationGatewayResourceSpecHashName = gateway.FullName + "/resource-spec-hash" // Server Connection Timeout, 10 seconds ServerConnTimeout = 10 )
GATEWAY CONSTANTS
const ( // CloudEventsVersion is the version of the CloudEvents spec targeted+ // by this library. CloudEventsVersion = "0.1" )
CloudEvents constants
const (
// EnvVarGatewayEventSourceConfigMap is used to get map containing event sources to run in a gateway
EnvVarGatewayEventSourceConfigMap = "GATEWAY_EVENT_SOURCE_CONFIG_MAP"
)
Gateway client constants
const (
EnvVarGatewayServerPort = "GATEWAY_SERVER_PORT"
)
Gateway server 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 DefaultConfigMapName ¶
DefaultConfigMapName returns a formulated name for a configmap name based on the sensor-controller deployment name
func DefaultEventSourceName ¶ added in v0.8.3
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 GetLoggerContext ¶
func GetLoggerContext(opt zerolog.ConsoleWriter) zerolog.Context
GetLoggerContext returns a logger with input options
func GetObjectHash ¶ added in v0.8.2
GetObjectHash returns hash of a given object
func IsRetryableKubeAPIError ¶
IsRetryableKubeAPIError returns if the error is a retryable kubernetes error
func LoggerConf ¶
func LoggerConf() zerolog.ConsoleWriter
LoggerConf returns standard logging configuration
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 ¶ 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
func ServerResourceForGroupVersionKind ¶
func ServerResourceForGroupVersionKind(disco discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (*metav1.APIResource, error)
ServerResourceForGroupVersionKind finds the API resources that fit the GroupVersionKind schema
Types ¶
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