config

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDockerStrategies added in v1.15.0

func GetDockerStrategies() []string

GetDockerStrategies returns the accepted values for the Docker stop strategy.

func GetProviders

func GetProviders() []string

Types

type BlockingStrategy

type BlockingStrategy struct {
	// DefaultTimeout is the maximum time the blocking strategy waits for all requested
	// instances to become ready before returning a timeout error.
	// Env: SABLIER_STRATEGY_BLOCKING_DEFAULT_TIMEOUT
	// CLI: --strategy.blocking.default-timeout
	// Default: 1m
	// Since: v1.0.0
	DefaultTimeout time.Duration

	// DefaultRefreshFrequency is how often the blocking strategy polls instance readiness
	// while waiting for workloads to start.
	// Env: SABLIER_STRATEGY_BLOCKING_DEFAULT_REFRESH_FREQUENCY
	// CLI: --strategy.blocking.default-refresh-frequency
	// Default: 5s
	// Since: v1.9.0
	DefaultRefreshFrequency time.Duration
}

BlockingStrategy holds configuration for the blocking strategy.

type Config

type Config struct {
	Server   Server
	Storage  Storage
	Provider Provider
	Sessions Sessions
	Logging  Logging
	Strategy Strategy
	Webhooks Webhooks
	Tracing  Tracing
}

func NewConfig

func NewConfig() Config

type Docker added in v1.11.0

type Docker struct {
	// Strategy controls how containers are brought to a stopped state.
	// "stop" terminates the container process, freeing both CPU and memory.
	// "pause" suspends execution while keeping the container in memory, allowing faster restarts.
	// Env: SABLIER_PROVIDER_DOCKER_STRATEGY
	// CLI: --provider.docker.strategy
	// Default: "stop"
	// Since: v1.11.0
	Strategy string

	// HonorRestartPolicy makes Sablier honor a container's restart policy when it
	// exits successfully (exit code 0). When enabled, a container with a "no" or
	// "on-failure" policy is reported as completed (a one-shot/init container that
	// finished its job). An "always"/"unless-stopped" container that is exited was
	// stopped and is reported as stopped (Docker does not auto-restart a manually
	// stopped container). When disabled, Sablier keeps the historical behavior and
	// always reports a successfully exited container as stopped.
	//
	// Note: Docker normalizes an unset restart policy to "no", so an unset policy
	// is indistinguishable from an explicit "no" and is therefore also reported
	// as completed when this option is enabled.
	//
	// Deprecated: this option only exists to preserve backward compatibility. It
	// will be removed in v2, where honoring the restart policy becomes the
	// default behavior.
	// Env: SABLIER_PROVIDER_DOCKER_HONOR_RESTART_POLICY
	// CLI: --provider.docker.honor-restart-policy
	// Default: false
	// Since: NEXT_RELEASE
	HonorRestartPolicy bool
}

func (Docker) IsValid added in v1.11.0

func (docker Docker) IsValid() error

type DynamicStrategy

type DynamicStrategy struct {
	// CustomThemesPath is a directory from which Sablier loads custom waiting-page themes.
	// All .html files found recursively under this path are registered as named themes.
	// Leave empty to use only the built-in themes.
	// Env: SABLIER_STRATEGY_DYNAMIC_CUSTOM_THEMES_PATH
	// CLI: --strategy.dynamic.custom-themes-path
	// Default: "" (built-in themes only)
	// Since: v1.0.0
	CustomThemesPath string

	// ShowDetailsByDefault controls whether the waiting page shows per-instance
	// status details without requiring the caller to opt in.
	// Env: SABLIER_STRATEGY_DYNAMIC_SHOW_DETAILS_BY_DEFAULT
	// CLI: --strategy.dynamic.show-details-by-default
	// Default: true
	// Since: v1.0.0
	ShowDetailsByDefault bool

	// DefaultTheme is the name of the waiting-page theme used when the caller does not specify one.
	// Env: SABLIER_STRATEGY_DYNAMIC_DEFAULT_THEME
	// CLI: --strategy.dynamic.default-theme
	// Default: "hacker-terminal"
	// Since: v1.0.0
	DefaultTheme string

	// DefaultRefreshFrequency is how often the waiting page polls Sablier for an updated
	// readiness status when no frequency is specified by the caller.
	// Env: SABLIER_STRATEGY_DYNAMIC_DEFAULT_REFRESH_FREQUENCY
	// CLI: --strategy.dynamic.default-refresh-frequency
	// Default: 5s
	// Since: v1.0.0
	DefaultRefreshFrequency time.Duration
}

DynamicStrategy holds configuration for the dynamic (waiting-page) strategy.

type Kubernetes

type Kubernetes struct {
	// QPS is the maximum number of queries per second sent to the Kubernetes API server
	// for client-side rate limiting.
	// Env: SABLIER_PROVIDER_KUBERNETES_QPS
	// CLI: --provider.kubernetes.qps
	// Default: 5
	// Since: v1.4.1-beta.2
	QPS float32

	// Burst is the maximum number of requests the Kubernetes client can send in a burst
	// before rate limiting kicks in.
	// Env: SABLIER_PROVIDER_KUBERNETES_BURST
	// CLI: --provider.kubernetes.burst
	// Default: 10
	// Since: v1.4.1-beta.2
	Burst int

	// Delimiter separates the namespace, resource type, and name in instance identifiers.
	// Defaults to "_" for backward compatibility; prefer "/" or "." for new deployments.
	// Env: SABLIER_PROVIDER_KUBERNETES_DELIMITER
	// CLI: --provider.kubernetes.delimiter
	// Default: "_"
	// Since: v1.7.0
	Delimiter string

	// ReadyOnFirstReplica reports a Deployment or StatefulSet as ready as soon as
	// at least one replica is ready, instead of requiring all desired replicas to
	// be ready. With the default behavior, a single restarting pod of a
	// multi-replica workload flips the instance back to "starting" (and its
	// sessions to the waiting page) even though the workload still serves traffic
	// through its remaining ready replicas. Enabling this also lets traffic flow
	// during scale-up as soon as the first replica of each workload is up.
	// A workload scaled to zero is always reported as stopped, regardless of
	// this option.
	// Env: SABLIER_PROVIDER_KUBERNETES_READY_ON_FIRST_REPLICA
	// CLI: --provider.kubernetes.ready-on-first-replica
	// Default: false
	// Since: NEXT_RELEASE
	ReadyOnFirstReplica bool
}

type Logging

type Logging struct {
	// Level sets the minimum log severity. Accepted values: debug, info, warn, error.
	// Env: SABLIER_LOGGING_LEVEL
	// CLI: --logging.level
	// Default: "info"
	// Since: v1.0.0
	Level string
}

Logging holds the logging configuration.

func NewLoggingConfig

func NewLoggingConfig() Logging

type MetricsConfig added in v1.12.0

type MetricsConfig struct {
	// Enabled exposes a Prometheus-compatible /metrics endpoint when true.
	// Env: SABLIER_SERVER_METRICS_ENABLED
	// CLI: --server.metrics.enabled
	// Default: false
	// Since: v1.12.0
	Enabled bool
}

MetricsConfig controls the Prometheus metrics endpoint.

type Podman added in v1.10.0

type Podman struct {
	// Uri is the connection URI for the Podman service.
	// Accepted schemes: unix://, tcp://, ssh://.
	// Leave empty to fall back to the CONTAINER_HOST environment variable.
	// Env: SABLIER_PROVIDER_PODMAN_URI
	// CLI: --provider.podman.uri
	// Default: "unix:///run/podman/podman.sock"
	// Since: v1.10.0
	Uri string
}

type Provider

type Provider struct {
	// Name selects the container runtime to manage workloads.
	// Accepted values: docker, swarm, kubernetes, podman, proxmox_lxc.
	// Env: SABLIER_PROVIDER_NAME
	// CLI: --provider.name
	// Default: "docker"
	// Since: v1.0.0
	Name string

	// AutoStopOnStartup stops all instances labelled with sablier.enable=true at
	// Sablier startup, ensuring a clean zero-scale state even after an unclean shutdown.
	// Env: SABLIER_PROVIDER_AUTO_STOP_ON_STARTUP
	// CLI: --provider.auto-stop-on-startup
	// Default: true
	// Since: v1.8.0
	AutoStopOnStartup bool

	// AutoStopExternallyStarted continuously stops instances with sablier.enable=true
	// that are running but were not started by Sablier itself.
	// Env: SABLIER_PROVIDER_AUTO_STOP_EXTERNALLY_STARTED
	// CLI: --provider.auto-stop-externally-started
	// Default: false
	// Since: v1.13.0
	AutoStopExternallyStarted bool

	// AutoWarmExternallyStarted continuously creates a session (with the default
	// session duration) for instances with sablier.enable=true that are running
	// but were not started by Sablier itself, instead of stopping them. The regular
	// expiration lifecycle then stops the instance once its session expires.
	// This is the non-destructive counterpart to AutoStopExternallyStarted.
	// Env: SABLIER_PROVIDER_AUTO_WARM_EXTERNALLY_STARTED
	// CLI: --provider.auto-warm-externally-started
	// Default: false
	// Since: NEXT_RELEASE
	AutoWarmExternallyStarted bool

	// RejectUnlabeledRequests rejects requests for instances that do not carry
	// the sablier.enable=true label, preventing accidental management of unlabelled workloads.
	// Env: SABLIER_PROVIDER_REJECT_UNLABELED_REQUESTS
	// CLI: --provider.reject-unlabeled-requests
	// Default: false
	// Since: v1.13.0
	RejectUnlabeledRequests bool

	// VerifyEnabledOnExpiration re-checks the sablier.enable=true label before stopping
	// an expired instance, useful when labels are managed dynamically.
	// Env: SABLIER_PROVIDER_VERIFY_ENABLED_ON_EXPIRATION
	// CLI: --provider.verify-enabled-on-expiration
	// Default: false
	// Since: v1.13.0
	VerifyEnabledOnExpiration bool

	Kubernetes Kubernetes
	Podman     Podman
	Docker     Docker
	ProxmoxLXC ProxmoxLXC
}

Provider holds the provider configurations.

func NewProviderConfig

func NewProviderConfig() Provider

func (Provider) IsValid

func (provider Provider) IsValid() error

type ProxmoxLXC added in v1.12.0

type ProxmoxLXC struct {
	// URL is the Proxmox VE REST API base URL (e.g. "https://proxmox:8006/api2/json").
	// Env: SABLIER_PROVIDER_PROXMOX_LXC_URL
	// CLI: --provider.proxmox-lxc.url
	// Default: ""
	// Since: v1.12.0
	URL string

	// TokenID is the Proxmox API token identifier in the form "user@realm!tokenname"
	// (e.g. "root@pam!sablier").
	// Env: SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_ID
	// CLI: --provider.proxmox-lxc.token-id
	// Default: ""
	// Since: v1.12.0
	TokenID string

	// TokenSecret is the UUID secret associated with the Proxmox API token.
	// Env: SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_SECRET
	// CLI: --provider.proxmox-lxc.token-secret
	// Default: ""
	// Since: v1.12.0
	TokenSecret string

	// TLSInsecure disables TLS certificate verification when connecting to the Proxmox API.
	// Enable only for self-signed certificates in trusted networks.
	// Env: SABLIER_PROVIDER_PROXMOX_LXC_TLS_INSECURE
	// CLI: --provider.proxmox-lxc.tls-insecure
	// Default: false
	// Since: v1.12.0
	TLSInsecure bool
}

ProxmoxLXC holds the Proxmox VE LXC provider configuration.

func (ProxmoxLXC) IsValid added in v1.12.0

func (p ProxmoxLXC) IsValid() error

type Server

type Server struct {
	// Port is the TCP port the Sablier server listens on.
	// Env: SABLIER_SERVER_PORT
	// CLI: --server.port
	// Default: 10000
	// Since: v1.0.0
	Port int

	// BasePath is the URL path prefix for all API routes.
	// Useful when Sablier is served behind a reverse proxy at a sub-path.
	// Env: SABLIER_SERVER_BASE_PATH
	// CLI: --server.base-path
	// Default: "/"
	// Since: v1.0.0
	BasePath string

	Metrics MetricsConfig
}

Server holds the HTTP server configuration.

func NewServerConfig

func NewServerConfig() Server

type Sessions

type Sessions struct {
	// DefaultDuration is the session lifetime when no explicit duration is provided by the plugin or API caller.
	// Env: SABLIER_SESSIONS_DEFAULT_DURATION
	// CLI: --sessions.default-duration
	// Default: 5m
	// Since: v1.0.0
	DefaultDuration time.Duration

	// ExpirationInterval is how often Sablier checks for and stops expired sessions.
	// A longer interval reduces CPU overhead; align it with your shortest session duration
	// (e.g. if all sessions are ≥1 h, 5 m is a reasonable trade-off).
	// Env: SABLIER_SESSIONS_EXPIRATION_INTERVAL
	// CLI: --sessions.expiration-interval
	// Default: 20s
	// Since: v1.0.0
	ExpirationInterval time.Duration
}

Sessions holds the session lifecycle configuration.

func NewSessionsConfig

func NewSessionsConfig() Sessions

type Storage

type Storage struct {
	// File is the path to a file where Sablier persists its session state across restarts.
	// Leave empty to run stateless (state is lost on restart).
	// Env: SABLIER_STORAGE_FILE
	// CLI: --storage.file
	// Default: "" (stateless)
	// Since: v1.0.0
	File string
}

Storage holds the state persistence configuration.

func NewStorageConfig

func NewStorageConfig() Storage

type Strategy

type Strategy struct {
	Dynamic  DynamicStrategy
	Blocking BlockingStrategy
}

func NewStrategyConfig

func NewStrategyConfig() Strategy

type Tracing added in v1.13.0

type Tracing struct {
	// Enabled activates distributed tracing. When false, no spans are created or exported.
	// Env: SABLIER_TRACING_ENABLED
	// CLI: --tracing.enabled
	// Default: false
	// Since: v1.13.0
	Enabled bool

	// ExporterType selects the trace exporter backend.
	// Accepted values: "otlphttp" (default), "stdout".
	// Env: SABLIER_TRACING_EXPORTER_TYPE
	// CLI: --tracing.exporter-type
	// Default: "otlphttp"
	// Since: v1.13.0
	ExporterType string

	// Endpoint is the OTLP collector base URL (scheme + host + optional port).
	// Examples: "http://jaeger:4318", "http://tempo:4318".
	// Only used when ExporterType is "otlphttp".
	// Env: SABLIER_TRACING_ENDPOINT
	// CLI: --tracing.endpoint
	// Default: "http://localhost:4318"
	// Since: v1.13.0
	Endpoint string

	// ServiceName is the logical name of this service as it appears in the tracing backend UI.
	// Env: SABLIER_TRACING_SERVICE_NAME
	// CLI: --tracing.service-name
	// Default: "sablier"
	// Since: v1.13.0
	ServiceName string

	// SamplingRate is the fraction of requests to trace, from 0.0 (none) to 1.0 (all).
	// Env: SABLIER_TRACING_SAMPLING_RATE
	// CLI: --tracing.sampling-rate
	// Default: 1.0
	// Since: v1.13.0
	SamplingRate float64
}

Tracing holds the OpenTelemetry tracing configuration.

func NewTracingConfig added in v1.13.0

func NewTracingConfig() Tracing

type WebhookEndpoint added in v1.13.0

type WebhookEndpoint struct {
	// URL is the full HTTP(S) address to POST events to. Required.
	URL string

	// Headers is an optional map of HTTP request headers added to every delivery
	// (e.g. {"Authorization": "Bearer <token>"}).
	Headers map[string]string

	// Events restricts which lifecycle events trigger a delivery to this endpoint.
	// Accepted values: "started", "stopped".
	// Omit or leave empty to receive all events.
	Events []string
}

WebhookEndpoint describes a single HTTP notification target.

type Webhooks added in v1.13.0

type Webhooks struct {
	// Endpoints is the list of HTTP targets to notify on instance lifecycle events.
	Endpoints []WebhookEndpoint
}

Webhooks holds the outbound webhook notification configuration. Sablier fires an HTTP POST to every configured endpoint whenever an instance transitions to "started" or "stopped". Webhooks are configured via the YAML configuration file only; there is no corresponding CLI flag or environment variable.

func NewWebhooksConfig added in v1.13.0

func NewWebhooksConfig() Webhooks

Jump to

Keyboard shortcuts

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