config

package
v0.0.0-...-0ae3b14 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FederationModeDisabled  = ""
	FederationModePublish   = "publish"
	FederationModeSubscribe = "subscribe"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ApiTokenNameSuffix         string `envconfig:"API_TOKEN_NAME_SUFFIX"`
	Federation                 FederationConfig
	HealthProbeBindAddress     string `envconfig:"HEALTH_PROBE_BIND_ADDRESS" default:":8081"`
	LeaderElectionEnabled      bool   `envconfig:"LEADER_ELECTION_ENABLED" default:"true"`
	LeaderElectionResourceName string `envconfig:"LEADER_ELECTION_RESOURCE_NAME" default:"509984d3.nais.io"`
	MetricsBindAddress         string `envconfig:"METRICS_BIND_ADDRESS" default:"127.0.0.1:8080"`
	ClusterName                string `envconfig:"CLUSTER_NAME" required:"true"`
	PodName                    string `envconfig:"POD_NAME" required:"true"`
	PodNamespace               string `envconfig:"POD_NAMESPACE" required:"true"`
	Log                        LogConfig
	Timeout                    TimeoutConfig
	WebhookPort                int `envconfig:"WEBHOOK_PORT" default:"9443"`
	Features                   Features
	OpenTelemetry              OpenTelemetryConfig
}

func LoadFromEnv

func LoadFromEnv() (*Config, error)

func (*Config) ManagerOptions

func (c *Config) ManagerOptions(scheme *runtime.Scheme) manager.Options

func (*Config) PubsubPublisher

func (c *Config) PubsubPublisher(ctx context.Context) (federation.Publisher, error)

func (*Config) PubsubSubscriber

func (c *Config) PubsubSubscriber(ctx context.Context) (federation.Subscriber, error)

type Features

type Features struct {
	// UnleashTokenUpdate enables updating tokens in Unleash.
	ApiTokenUpdateEnabled        bool `envconfig:"FEATURE_API_TOKEN_UPDATE_ENABLED" default:"false"`
	ApiTokenDeduplicationEnabled bool `envconfig:"FEATURE_API_TOKEN_DEDUPLICATION_ENABLED" default:"false"`
}

type FederationConfig

type FederationConfig struct {
	Mode               FederationMode `envconfig:"FEDERATION_PUBSUB_MODE"`
	PubsubProjectID    string         `envconfig:"FEDERATION_PUBSUB_GCP_PROJECT_ID"`
	PubsubTopic        string         `envconfig:"FEDERATION_PUBSUB_TOPIC"`
	PubsubSubscription string         `envconfig:"FEDERATION_PUBSUB_SUBSCRIPTION"`
}

func (*FederationConfig) IsEnabled

func (f *FederationConfig) IsEnabled() bool

type FederationMode

type FederationMode string

func (*FederationMode) Set

func (p *FederationMode) Set(value string) error

type LogConfig

type LogConfig struct {
	Level string `envconfig:"LOG_LEVEL" default:"info"`
}

type OpenTelemetryConfig

type OpenTelemetryConfig struct {
	TracesExporter       string `envconfig:"OTEL_TRACES_EXPORTER" default:"none"`
	ExporterOtlpEndpoint string `envconfig:"OTEL_EXPORTER_OTLP_ENDPOINT" default:"http://localhost:4317"`
	ExporterOtlpProtocol string `envconfig:"OTEL_EXPORTER_OTLP_PROTOCOL" default:"grpc"`
}

type TimeoutConfig

type TimeoutConfig struct {
	// WriteSeconds is the maximum number of seconds to wait for a write operation to complete.
	Write time.Duration `envconfig:"TIMEOUT_WRITE" default:"10s"`
}

func (*TimeoutConfig) WriteContext

func (t *TimeoutConfig) WriteContext(ctx context.Context) (context.Context, context.CancelFunc)

Jump to

Keyboard shortcuts

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