config

package
v0.0.5-alpha Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	EnvironmentTest        = "test"
	EnvironmentDevelopment = "development"
	EnvironmentProduction  = "production"
)
View Source
const (
	ACMEEnvironmentProduction   = "production"
	ACMEEnvironmentStaging      = "staging"
	DefaultPlatformTLSNamespace = "stackdome-control-plane"
	ACMEProductionDirectoryURL  = "https://acme-v02.api.letsencrypt.org/directory"
	ACMEStagingDirectoryURL     = "https://acme-staging-v02.api.letsencrypt.org/directory"
)

Variables

View Source
var (
	// Application
	EnvJWTSecret            = StringVar("JWT_SECRET", "JWT token signing secret", nil, true)
	EnvLogLevel             = StringVar("LOG_LEVEL", "Logging level (debug, info, warn, error)", ptr("info"), false)
	EnvLogFormat            = StringVar("LOG_FORMAT", "Log output format (json or text)", ptr("json"), false)
	EnvEncryptionKey        = StringVar("ENCRYPTION_KEY", "Master encryption key (64-1024 chars)", nil, true)
	EnvRuntimeMode          = StringVar("RUNTIME_MODE", "Runtime mode (self_hosted or stackdome_cloud)", ptr(string(RuntimeModeSelfHosted)), false)
	EnvComputeMode          = StringVar("COMPUTE_MODE", "Compute mode (bring_your_own or shared)", ptr(string(ComputeModeBYOC)), false)
	EnvStackdomeCloudConfig = StringVar("STACKDOME_CLOUD_CONFIG", "Path to the Stackdome Cloud runtime configuration", nil, false)
	EnvTurnstileSecret      = StringVar("TURNSTILE_SECRET", "Cloudflare Turnstile secret for signup verification", nil, false)
	// GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET are used for GitHub OAuth login
	EnvGitHubClientID     = StringVar("GITHUB_CLIENT_ID", "GitHub OAuth app client ID", nil, false)
	EnvGitHubClientSecret = StringVar("GITHUB_CLIENT_SECRET", "GitHub OAuth app client secret", nil, false)
	EnvGitHubRedirectURI  = StringVar("GITHUB_REDIRECT_URI", "GitHub OAuth app redirect URI (optional; derived from SERVER_EXTERNAL_URL when unset)", nil, false)
	// The GITHUB_APP_* vars configure one platform-wide GitHub App that every
	// org installs; unset leaves each org creating its own app via the
	// manifest flow.
	EnvGitHubAppID            = IntVar("GITHUB_APP_ID", "Platform GitHub App numeric ID", nil, false)
	EnvGitHubAppSlug          = StringVar("GITHUB_APP_SLUG", "Platform GitHub App URL slug", nil, false)
	EnvGitHubAppPrivateKey    = StringVar("GITHUB_APP_PRIVATE_KEY", "Platform GitHub App private key (PEM)", nil, false)
	EnvGitHubAppWebhookSecret = StringVar("GITHUB_APP_WEBHOOK_SECRET", "Platform GitHub App webhook secret", nil, false)

	// Server
	EnvServerHostname    = StringVar("SERVER_HOSTNAME", "Server hostname/domain", nil, false)
	EnvServerExternalURL = StringVar("SERVER_EXTERNAL_URL", "Externally reachable base URL of the hub (used for GitHub App callbacks and webhooks)", nil, false)
	// GitHub API base URL override (httptest stubs / GHES)
	EnvGitHubAPIBaseURL   = StringVar("GITHUB_API_BASE_URL", "GitHub API base URL", ptr("https://api.github.com"), false)
	EnvServerBindAddress  = StringVar("SERVER_BIND_ADDRESS", "Server bind address and port", ptr("0.0.0.0:8000"), false)
	EnvMetricsBindAddress = StringVar("METRICS_BIND_ADDRESS", "Internal Prometheus metrics bind address", ptr("0.0.0.0:9090"), false)

	// Database
	EnvDBHost           = StringVar("DB_HOST", "PostgreSQL host", nil, true)
	EnvDBPort           = IntVar("DB_PORT", "PostgreSQL port", nil, true)
	EnvDBName           = StringVar("DB_NAME", "Database name", nil, true)
	EnvDBUsername       = StringVar("DB_USERNAME", "Database user", nil, true)
	EnvDBPassword       = StringVar("DB_PASSWORD", "Database password", nil, true)
	EnvDBSSLMode        = StringVar("DB_SSL_MODE", "SSL mode (disable or require)", ptr("disable"), false)
	EnvDBMaxConnections = IntVar("DB_MAX_CONNECTIONS", "Max open DB connections", ptr(50), false)
	EnvDBRootCertFile   = StringVar("DB_ROOT_CERT_FILE", "Root CA cert path for SSL", nil, false)
	EnvDBDebugMode      = BoolVar("DB_DEBUG_MODE", "Enable DB query debug logging", ptr(false), false)

	// Shared Compute Cluster
	EnvSharedComputeClusterAPIURL = StringVar("SHARED_COMPUTE_CLUSTER_API_URL", "Shared compute cluster API URL", nil, false)
	EnvSharedComputeClusterCAData = StringVar("SHARED_COMPUTE_CLUSTER_CA_DATA", "Shared compute cluster CA cert (base64)", nil, false)
	EnvSharedComputeClusterToken  = StringVar("SHARED_COMPUTE_CLUSTER_TOKEN", "Shared compute cluster auth token", nil, false)

	// Platform routing and TLS
	EnvPlatformEmail                   = StringVar("PLATFORM_EMAIL", "Operator contact email; ACME contact for the platform TLS issuer", nil, false)
	EnvPlatformBaseDomain              = StringVar("PLATFORM_BASE_DOMAIN", "Base domain for the platform org and per-org subdomains", nil, false)
	EnvPlatformDNSCloudflareAPIToken   = StringVar("PLATFORM_DNS_CLOUDFLARE_API_TOKEN", "Cloudflare API token used for platform wildcard DNS challenges", nil, false)
	EnvPlatformTLSEnabled              = BoolVar("PLATFORM_TLS_ENABLED", "Enable platform-managed TLS on shared compute", ptr(false), false)
	EnvPlatformACMEEnvironment         = StringVar("PLATFORM_ACME_ENVIRONMENT", "Let's Encrypt ACME environment (production or staging)", nil, false)
	EnvPlatformTLSNamespace            = StringVar("PLATFORM_TLS_NAMESPACE", "Namespace for platform TLS resources", nil, false)
	EnvPlatformOrgRegistryStorageSize  = StringVar("PLATFORM_ORG_REGISTRY_STORAGE_SIZE", "Default storage size for each org's registry seeded at signup", ptr(models.DefaultPlatformOrgRegistryStorageSize), false)
	EnvPlatformOrgRegistryStorageClass = StringVar("PLATFORM_ORG_REGISTRY_STORAGE_CLASS", "Default storage class for each org's registry seeded at signup", nil, false)

	// Environment
	EnvStackdomeEnv = StringVar("STACKDOME_ENV", "Runtime environment (DEVELOPMENT, PRODUCTION)", ptr("DEVELOPMENT"), false)

	// Test Overrides
	EnvTestJWTSecret     = StringVar("TEST_JWT_SECRET", "Override JWT secret in tests", nil, false)
	EnvTestEncryptionKey = StringVar("TEST_ENCRYPTION_KEY", "Override encryption key in tests", nil, false)
	EnvTestLogLevel      = StringVar("TEST_LOG_LEVEL", "Override log level in tests", ptr("info"), false)
)
View Source
var (
	ErrIncompleteSharedComputeClusterConfig = &ConfigError{"SHARED_COMPUTE_CLUSTER_API_URL, SHARED_COMPUTE_CLUSTER_CA_DATA and SHARED_COMPUTE_CLUSTER_TOKEN must all be set together"}
	ErrUnsupportedComputeMode               = &ConfigError{"COMPUTE_MODE must be bring_your_own or shared"}
	ErrSharedComputeProvisioningRequired    = &ConfigError{"shared compute provisioning is required in shared compute mode"}
	ErrSharedComputeProvisioningNotAllowed  = &ConfigError{"shared compute provisioning is not allowed in bring_your_own compute mode"}
	ErrPlatformRoutingNotAllowed            = &ConfigError{"platform routing is not allowed in bring_your_own compute mode"}
	ErrPlatformBaseDomainRequired           = &ConfigError{"PLATFORM_BASE_DOMAIN is required in shared compute mode"}
	ErrPlatformTLSRequired                  = &ConfigError{"PLATFORM_TLS_ENABLED is required in stackdome_cloud runtime mode"}
	ErrPlatformTLSConfigNotAllowed          = &ConfigError{"platform TLS configuration requires PLATFORM_TLS_ENABLED=true"}
	ErrPlatformEmailRequired                = &ConfigError{"PLATFORM_EMAIL is required when platform TLS is enabled"}
	ErrPlatformCloudflareTokenRequired      = &ConfigError{"PLATFORM_DNS_CLOUDFLARE_API_TOKEN is required when platform TLS is enabled"}
	ErrPlatformACMEEnvironmentInvalid       = &ConfigError{"PLATFORM_ACME_ENVIRONMENT must be production or staging"}
	ErrPlatformTLSNamespaceRequired         = &ConfigError{"PLATFORM_TLS_NAMESPACE is required when platform TLS is enabled"}
)

Functions

func ValidatePlatformRouting

func ValidatePlatformRouting(runtime RuntimeMode, mode ComputeMode, platform *PlatformConfig) error

func ValidateSharedComputeProvisioning

func ValidateSharedComputeProvisioning(mode ComputeMode, cluster *ClusterConfig) error

Types

type ApplicationConfig

type ApplicationConfig struct {
	Server                   *ServerConfig         `json:"server"`
	Database                 *DatabaseConfig       `json:"database"`
	JwtSecret                string                `json:"jwt_secret"`
	EncryptionKey            string                `json:"encryption_key"`
	LogLevel                 string                `json:"log_level"`
	LogFormat                string                `json:"log_format"`
	RuntimeMode              RuntimeMode           `json:"runtime_mode"`
	ComputeMode              ComputeMode           `json:"compute_mode"`
	StackdomeCloudConfigPath string                `json:"stackdome_cloud_config_path"`
	StackdomeCloud           *StackdomeCloudConfig `json:"stackdome_cloud,omitempty"`
	TurnstileSecret          string                `json:"-"`
	GitHubOAuth              *GitHubOAuthConfig    `json:"github_oauth"`
	// GitHubApp is the platform-wide GitHub App; unset means per-org apps.
	GitHubApp *GitHubAppConfig `json:"github_app"`
	// ServerExternalURL is the externally reachable base URL of the hub,
	// required for the GitHub App manifest flow (browser redirects, webhooks).
	ServerExternalURL string `json:"server_external_url"`
	// GitHubAPIBaseURL overrides the GitHub API endpoint (tests, GHES).
	GitHubAPIBaseURL string `json:"github_api_base_url"`
	// SharedComputeCluster holds the SHARED_COMPUTE_CLUSTER_* configuration.
	SharedComputeCluster *ClusterConfig `json:"shared_compute_cluster"`
}

func NewApplicationConfig

func NewApplicationConfig() *ApplicationConfig

func (*ApplicationConfig) CustomDomainsEnabled

func (c *ApplicationConfig) CustomDomainsEnabled() bool

func (*ApplicationConfig) ExternalPostgresImportEnabled

func (c *ApplicationConfig) ExternalPostgresImportEnabled() bool

func (*ApplicationConfig) IsStackdomeCloud

func (c *ApplicationConfig) IsStackdomeCloud() bool

func (*ApplicationConfig) LoadEnvVariables

func (c *ApplicationConfig) LoadEnvVariables() error

func (*ApplicationConfig) LoadStackdomeCloudConfig

func (c *ApplicationConfig) LoadStackdomeCloudConfig() error

func (*ApplicationConfig) UsesSharedCompute

func (c *ApplicationConfig) UsesSharedCompute() bool

func (*ApplicationConfig) Validate

func (c *ApplicationConfig) Validate() error

type ClusterConfig

type ClusterConfig struct {
	ClusterURL    string `yaml:"cluster_url"`
	ClusterCAData string `yaml:"cluster_ca_data"`
	Token         string `yaml:"token"`
}

func (*ClusterConfig) AnySet

func (c *ClusterConfig) AnySet() bool

func (*ClusterConfig) IsSet

func (c *ClusterConfig) IsSet() bool

func (*ClusterConfig) LoadEnvVariables

func (c *ClusterConfig) LoadEnvVariables() error

func (*ClusterConfig) Validate

func (c *ClusterConfig) Validate() error

type ComputeMode

type ComputeMode string
const (
	ComputeModeBYOC   ComputeMode = "bring_your_own"
	ComputeModeShared ComputeMode = "shared"
)

type ConfigDuration

type ConfigDuration time.Duration

func (ConfigDuration) Duration

func (d ConfigDuration) Duration() time.Duration

func (*ConfigDuration) UnmarshalYAML

func (d *ConfigDuration) UnmarshalYAML(value *yaml.Node) error

type ConfigError

type ConfigError struct {
	// contains filtered or unexported fields
}

func (*ConfigError) Error

func (e *ConfigError) Error() string

type DBConnectionConfig

type DBConnectionConfig struct {
	Host     string `json:"host" yaml:"host"`
	Port     int    `json:"port" yaml:"port"`
	Name     string `json:"name" yaml:"name"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Dialect            string  `json:"dialect"`
	SSLMode            SSLMode `json:"sslmode"`
	RootCertFile       string
	Debug              bool `json:"debug"`
	MaxOpenConnections int  `json:"max_connections"`
	DBConnectionConfig
}

func NewDatabaseConfig

func NewDatabaseConfig() *DatabaseConfig

func (*DatabaseConfig) ConnectionString

func (c *DatabaseConfig) ConnectionString() string

func (*DatabaseConfig) ConnectionStringWithName

func (c *DatabaseConfig) ConnectionStringWithName(name string, withSSL bool) string

func (*DatabaseConfig) LoadEnvVariables

func (c *DatabaseConfig) LoadEnvVariables()

func (*DatabaseConfig) LogSafeConnectionString

func (c *DatabaseConfig) LogSafeConnectionString(withSSL bool) string

func (*DatabaseConfig) LogSafeConnectionStringWithName

func (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, withSSL bool) string

func (*DatabaseConfig) Validate

func (c *DatabaseConfig) Validate() error

type EnvVar

type EnvVar[T any] struct {
	Name         string
	Description  string
	DefaultValue *T
	Required     bool
	// contains filtered or unexported fields
}

func BoolVar

func BoolVar(name, description string, defaultVal *bool, required bool) EnvVar[bool]

func IntVar

func IntVar(name, description string, defaultVal *int, required bool) EnvVar[int]

func StringVar

func StringVar(name, description string, defaultVal *string, required bool) EnvVar[string]

func (EnvVar[T]) Lookup

func (e EnvVar[T]) Lookup() (T, bool)

type GitHubAppConfig

type GitHubAppConfig struct {
	AppID         int64  `json:"app_id"`
	Slug          string `json:"slug"`
	PrivateKey    string `json:"private_key"`
	WebhookSecret string `json:"webhook_secret"`
}

GitHubAppConfig is the platform-wide GitHub App every org installs. Not configured: each org creates its own app through the manifest flow. Login uses the same app's client id/secret via the GITHUB_CLIENT_* vars.

func (*GitHubAppConfig) Configured

func (c *GitHubAppConfig) Configured() bool

func (*GitHubAppConfig) LoadEnvVariables

func (c *GitHubAppConfig) LoadEnvVariables()

type GitHubOAuthConfig

type GitHubOAuthConfig struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURI  string `json:"redirect_uri"`
}

func NewGitHubOAuthConfig

func NewGitHubOAuthConfig() *GitHubOAuthConfig

func (*GitHubOAuthConfig) Enabled

func (c *GitHubOAuthConfig) Enabled() bool

func (*GitHubOAuthConfig) LoadEnvVariables

func (c *GitHubOAuthConfig) LoadEnvVariables()

type PlatformConfig

type PlatformConfig struct {
	Email                 string
	BaseDomain            string
	DNSCloudflareAPIToken string
	PlatformTLSEnabled    bool
	ACMEEnvironment       string
	TLSNamespace          string
	OrgRegistry           models.OrgRegistryDefaults
}

func NewPlatformConfig

func NewPlatformConfig() *PlatformConfig

func (*PlatformConfig) ACMEDirectoryURL

func (p *PlatformConfig) ACMEDirectoryURL() string

func (*PlatformConfig) LoadEnvVariables

func (p *PlatformConfig) LoadEnvVariables() error

type RuntimeMode

type RuntimeMode string
const (
	RuntimeModeSelfHosted     RuntimeMode = "self_hosted"
	RuntimeModeStackdomeCloud RuntimeMode = "stackdome_cloud"
)

type SSLMode

type SSLMode string
const (
	DBSSLModeDisable SSLMode = "disable"
	DBSSLModeRequire SSLMode = "require"
)

type ServerConfig

type ServerConfig struct {
	Hostname           string `json:"hostname"`
	BindAddress        string `json:"bind_address"`
	MetricsBindAddress string `json:"metrics_bind_address"`
}

func NewServerConfig

func NewServerConfig() *ServerConfig

func (*ServerConfig) LoadEnvVariables

func (c *ServerConfig) LoadEnvVariables()

func (*ServerConfig) Validate

func (c *ServerConfig) Validate() error

type StackdomeCloudClientIPSource

type StackdomeCloudClientIPSource string
const (
	StackdomeCloudClientIPSourceCloudflare StackdomeCloudClientIPSource = "cloudflare"
	StackdomeCloudClientIPSourceRemoteAddr StackdomeCloudClientIPSource = "remote_addr"
)

type StackdomeCloudComputeAccessConfig

type StackdomeCloudComputeAccessConfig struct {
	MaxActiveSharedComputeLeases int            `yaml:"maxActiveSharedComputeLeases" json:"max_active_shared_compute_leases"`
	TrialEntitlementDuration     ConfigDuration `yaml:"trialEntitlementDuration" json:"trial_entitlement_duration"`
}

StackdomeCloudComputeAccessConfig configures the default trial grant and the platform ceiling enforced when reserving shared compute.

type StackdomeCloudConfig

type StackdomeCloudConfig struct {
	Access   StackdomeCloudComputeAccessConfig `yaml:"access" json:"access"`
	Limits   computequota.ComputeLimits        `yaml:"limits" json:"limits"`
	Registry StackdomeCloudRegistryConfig      `yaml:"registry" json:"registry"`
	Features StackdomeCloudFeaturesConfig      `yaml:"features" json:"features"`
	Signup   StackdomeCloudSignupConfig        `yaml:"signup" json:"signup"`
}

func LoadStackdomeCloudConfig

func LoadStackdomeCloudConfig(path string) (*StackdomeCloudConfig, error)

func (*StackdomeCloudConfig) Validate

func (c *StackdomeCloudConfig) Validate() error

type StackdomeCloudEmailThrottleConfig

type StackdomeCloudEmailThrottleConfig struct {
	MaxTrackedAddresses int            `yaml:"maxTrackedAddresses" json:"max_tracked_addresses"`
	MaxAttempts         int            `yaml:"maxAttempts" json:"max_attempts"`
	Window              ConfigDuration `yaml:"window" json:"window"`
}

type StackdomeCloudFeaturesConfig

type StackdomeCloudFeaturesConfig struct {
	CustomDomains          bool `yaml:"customDomains" json:"custom_domains"`
	ExternalPostgresImport bool `yaml:"externalPostgresImport" json:"external_postgres_import"`
	// WorkspaceUsers is accepted only as false for compatibility with the first cloud config.
	WorkspaceUsers bool `yaml:"workspaceUsers" json:"workspace_users"`
}

type StackdomeCloudIPThrottleConfig

type StackdomeCloudIPThrottleConfig struct {
	MaxTrackedClients int            `yaml:"maxTrackedClients" json:"max_tracked_clients"`
	MaxAttempts       int            `yaml:"maxAttempts" json:"max_attempts"`
	Window            ConfigDuration `yaml:"window" json:"window"`
}

type StackdomeCloudRegistryConfig

type StackdomeCloudRegistryConfig struct {
	MaxActiveRegistries int    `yaml:"maxActiveRegistries" json:"max_active_registries"`
	StorageClass        string `yaml:"storageClass" json:"storage_class"`
	StorageSize         string `yaml:"storageSize" json:"storage_size"`
}

type StackdomeCloudSignupConfig

type StackdomeCloudSignupConfig struct {
	ClientIPSource StackdomeCloudClientIPSource  `yaml:"clientIPSource" json:"client_ip_source"`
	Turnstile      StackdomeCloudTurnstileConfig `yaml:"turnstile" json:"turnstile"`
	// Throttle is always enforced in the Stackdome Cloud runtime.
	Throttle StackdomeCloudThrottleConfig `yaml:"throttle" json:"throttle"`
}

type StackdomeCloudThrottleConfig

type StackdomeCloudThrottleConfig struct {
	IP    StackdomeCloudIPThrottleConfig    `yaml:"ip" json:"ip"`
	Email StackdomeCloudEmailThrottleConfig `yaml:"email" json:"email"`
}

type StackdomeCloudTurnstileConfig

type StackdomeCloudTurnstileConfig struct {
	Enabled             bool           `yaml:"enabled" json:"enabled"`
	SiteKey             string         `yaml:"siteKey" json:"site_key"`
	ExpectedHostname    string         `yaml:"expectedHostname" json:"expected_hostname"`
	ExpectedAction      string         `yaml:"expectedAction" json:"expected_action"`
	VerificationTimeout ConfigDuration `yaml:"verificationTimeout" json:"verification_timeout"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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