env

package
v0.0.0-...-ea047a2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backend

func Backend() (string, error)

Backend returns the selected backend based on the environment variable "BACKEND". "NATS" is the default value in case of an empty variable.

Types

type BackendConfig

type BackendConfig struct {
	PublisherConfig PublisherConfig

	BackendCRNamespace string `envconfig:"BACKEND_CR_NAMESPACE" default:"kyma-system"`
	BackendCRName      string `envconfig:"BACKEND_CR_NAME" default:"eventing-backend"`

	WebhookSecretName   string `envconfig:"WEBHOOK_SECRET_NAME" default:"eventing-webhook-server-cert"`
	MutatingWebhookName string `envconfig:"MUTATING_WEBHOOK_NAME" default:"subscription-mutating-webhook-configuration"`
	//nolint:lll
	ValidatingWebhookName string `envconfig:"VALIDATING_WEBHOOK_NAME" default:"subscription-validating-webhook-configuration"`

	DefaultSubscriptionConfig DefaultSubscriptionConfig

	//nolint:lll
	EventingWebhookAuthSecretName string `envconfig:"EVENTING_WEBHOOK_AUTH_SECRET_NAME" required:"true" default:"eventing-webhook-auth"`
	//nolint:lll
	EventingWebhookAuthSecretNamespace string `envconfig:"EVENTING_WEBHOOK_AUTH_SECRET_NAMESPACE" required:"true" default:"kyma-system"`
}

BackendConfig represents the environment config for the Backend Controller.

func GetBackendConfig

func GetBackendConfig() BackendConfig

type Config

type Config struct {
	// Following details are for eventing-controller to communicate to BEB
	BEBAPIURL     string `envconfig:"BEB_API_URL" default:"https://enterprise-messaging-pubsub.cfapps.sap.hana.ondemand.com/sap/ems/v1"`
	ClientID      string `envconfig:"CLIENT_ID" default:"client-id"`
	ClientSecret  string `envconfig:"CLIENT_SECRET" default:"client-secret"`
	TokenEndpoint string `envconfig:"TOKEN_ENDPOINT" default:"token-endpoint"`

	// Following details are for BEB to communicate to Kyma
	WebhookActivationTimeout time.Duration `envconfig:"WEBHOOK_ACTIVATION_TIMEOUT" default:"60s"`
	WebhookTokenEndpoint     string        `envconfig:"WEBHOOK_TOKEN_ENDPOINT" required:"true"`

	// Default protocol setting for BEB
	ExemptHandshake bool   `envconfig:"EXEMPT_HANDSHAKE" default:"true"`
	Qos             string `envconfig:"QOS" default:"AT_LEAST_ONCE"`
	ContentMode     string `envconfig:"CONTENT_MODE" default:""`

	// Default namespace for BEB
	BEBNamespace string `envconfig:"BEB_NAMESPACE" default:"ns"`

	// Domain holds the Kyma domain
	Domain string `envconfig:"DOMAIN" required:"true"`

	// EventTypePrefix prefix for the EventType
	// note: eventType format is <prefix>.<application>.<event>.<version>
	EventTypePrefix string `envconfig:"EVENT_TYPE_PREFIX" required:"true"`

	// EventingWebhookAuthEnabled enable/disable the Eventing webhook auth feature flag.
	EventingWebhookAuthEnabled bool `envconfig:"EVENTING_WEBHOOK_AUTH_ENABLED" required:"false" default:"false"`

	// NATSProvisioningEnabled enable/disable the NATS resources provisioning feature flag.
	NATSProvisioningEnabled bool `envconfig:"NATS_PROVISIONING_ENABLED" required:"false" default:"true"`
}

Config represents the environment config for the Eventing Controller.

func GetConfig

func GetConfig() Config

type DefaultSubscriptionConfig

type DefaultSubscriptionConfig struct {
	MaxInFlightMessages   int           `envconfig:"DEFAULT_MAX_IN_FLIGHT_MESSAGES" default:"10"`
	DispatcherRetryPeriod time.Duration `envconfig:"DEFAULT_DISPATCHER_RETRY_PERIOD" default:"5m"`
	DispatcherMaxRetries  int           `envconfig:"DEFAULT_DISPATCHER_MAX_RETRIES" default:"10"`
}

type NATSConfig

type NATSConfig struct {
	// Following details are for eventing-controller to communicate to Nats
	URL           string `envconfig:"NATS_URL" required:"true"`
	MaxReconnects int
	ReconnectWait time.Duration

	// EventTypePrefix prefix for the EventType
	// note: eventType format is <prefix>.<application>.<event>.<version>
	EventTypePrefix string `envconfig:"EVENT_TYPE_PREFIX" required:"true"`

	// HTTP Transport config for the message dispatcher
	MaxIdleConns        int           `envconfig:"MAX_IDLE_CONNS" default:"50"`
	MaxConnsPerHost     int           `envconfig:"MAX_CONNS_PER_HOST" default:"50"`
	MaxIdleConnsPerHost int           `envconfig:"MAX_IDLE_CONNS_PER_HOST" default:"50"`
	IdleConnTimeout     time.Duration `envconfig:"IDLE_CONN_TIMEOUT" default:"10s"`

	// JetStream-specific configs
	// Name of the JetStream stream where all events are stored.
	JSStreamName string `envconfig:"JS_STREAM_NAME" required:"true"`
	// Prefix for the subjects in the stream.
	JSSubjectPrefix string `envconfig:"JS_STREAM_SUBJECT_PREFIX" required:"true"`
	// Storage type of the stream, memory or file.
	JSStreamStorageType string `envconfig:"JS_STREAM_STORAGE_TYPE" default:"memory"`
	// Number of replicas for the JetStream stream
	JSStreamReplicas int `envconfig:"JS_STREAM_REPLICAS" default:"1"`
	// Retention policy specifies when to delete events from the stream.
	//  interest: when all known observables have acknowledged a message, it can be removed.
	//  limits: messages are retained until any given limit is reached.
	//  configured via JSStreamMaxMessages and JSStreamMaxBytes.
	JSStreamRetentionPolicy string `envconfig:"JS_STREAM_RETENTION_POLICY" default:"interest"`
	JSStreamMaxMessages     int64  `envconfig:"JS_STREAM_MAX_MSGS" default:"-1"`
	JSStreamMaxBytes        string `envconfig:"JS_STREAM_MAX_BYTES" default:"-1"`
	JSStreamMaxMsgsPerTopic int64  `envconfig:"JS_STREAM_MAX_MSGS_PER_TOPIC" default:"-1"`
	// JSStreamDiscardPolicy specifies which events to discard from the stream in case limits are reached
	//  new: reject new messages for the stream
	//  old: discard old messages from the stream to make room for new messages
	JSStreamDiscardPolicy string `envconfig:"JS_STREAM_DISCARD_POLICY" default:"new"`
	// Deliver Policy determines for a consumer where in the stream it starts receiving messages
	// (more info https://docs.nats.io/nats-concepts/jetstream/consumers#deliverpolicy-optstartseq-optstarttime):
	// - all: The consumer starts receiving from the earliest available message.
	// - last: When first consuming messages, the consumer starts receiving messages with the latest message.
	// - last_per_subject: When first consuming messages, start with the latest one for each filtered subject
	//   currently in the stream.
	// - new: When first consuming messages, the consumer starts receiving messages that were created
	//   after the consumer was created.
	JSConsumerDeliverPolicy string `envconfig:"JS_CONSUMER_DELIVER_POLICY" default:"new"`
}

NATSConfig represents the environment config for the Eventing Controller with Nats.

func GetNATSConfig

func GetNATSConfig(maxReconnects int, reconnectWait time.Duration) (NATSConfig, error)

type PublisherConfig

type PublisherConfig struct {
	Image             string `envconfig:"PUBLISHER_IMAGE" default:"eu.gcr.io/kyma-project/event-publisher-proxy:c06eb4fc"`
	ImagePullPolicy   string `envconfig:"PUBLISHER_IMAGE_PULL_POLICY" default:"IfNotPresent"`
	PortNum           int    `envconfig:"PUBLISHER_PORT_NUM" default:"8080"`
	MetricsPortNum    int    `envconfig:"PUBLISHER_METRICS_PORT_NUM" default:"8080"`
	ServiceAccount    string `envconfig:"PUBLISHER_SERVICE_ACCOUNT" default:"eventing-publisher-proxy"`
	Replicas          int32  `envconfig:"PUBLISHER_REPLICAS" default:"1"`
	RequestsCPU       string `envconfig:"PUBLISHER_REQUESTS_CPU" default:"32m"`
	RequestsMemory    string `envconfig:"PUBLISHER_REQUESTS_MEMORY" default:"64Mi"`
	RequestTimeout    string `envconfig:"PUBLISHER_REQUEST_TIMEOUT" default:"5s"`
	LimitsCPU         string `envconfig:"PUBLISHER_LIMITS_CPU" default:"100m"`
	LimitsMemory      string `envconfig:"PUBLISHER_LIMITS_MEMORY" default:"128Mi"`
	PriorityClassName string `envconfig:"PUBLISHER_PRIORITY_CLASS_NAME" default:""`
	// publisher takes the controller values
	AppLogFormat string `envconfig:"APP_LOG_FORMAT" default:"json"`
	AppLogLevel  string `envconfig:"APP_LOG_LEVEL" default:"info"`
}

Jump to

Keyboard shortcuts

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