config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentSchemaVersion                 = 1
	DefaultTUIAutoRefreshIntervalSeconds = 30
)
View Source
const (
	DefaultStackName       = "dev-stack"
	DefaultComposeFileName = "compose.yaml"
	DefaultNATSConfigName  = "nats.conf"
	DefaultRedisACLName    = "redis.acl"
	DefaultPgAdminServers  = "pgadmin-servers.json"
	DefaultPGPassName      = "pgpass"
	StackNameEnvVar        = "STACKCTL_STACK"
	CurrentStackFileName   = "current-stack"
)

Variables

View Source
var ErrNotFound = errors.New("stackctl config not found")

Functions

func ApplyPlatformDefaults

func ApplyPlatformDefaults(cfg *Config, platform system.Platform)

func CockpitHelperDescriptionForConfig

func CockpitHelperDescriptionForConfig(cfg Config) string

func CockpitHelperDescriptionForPlatform

func CockpitHelperDescriptionForPlatform(platform system.Platform) string

func CockpitInstallDescriptionForConfig

func CockpitInstallDescriptionForConfig(cfg Config) string

func CockpitInstallDescriptionForPlatform

func CockpitInstallDescriptionForPlatform(platform system.Platform) string

func CockpitInstallEnableReasonForConfig

func CockpitInstallEnableReasonForConfig(cfg Config) string

func CockpitInstallEnableReasonForPlatform

func CockpitInstallEnableReasonForPlatform(platform system.Platform) string

func ComposePath

func ComposePath(cfg Config) string

func ConfigDirPath

func ConfigDirPath() (string, error)

func ConfigFilePath

func ConfigFilePath() (string, error)

func ConfigFilePathForStack

func ConfigFilePathForStack(name string) (string, error)

func ConfigStacksDirPath

func ConfigStacksDirPath() (string, error)

func CurrentCockpitHelperDescription

func CurrentCockpitHelperDescription() string

func CurrentCockpitInstallDescription

func CurrentCockpitInstallDescription() string

func CurrentPackageManagerFieldDescription

func CurrentPackageManagerFieldDescription() string

func CurrentStackName

func CurrentStackName() (string, error)

func CurrentStackPath

func CurrentStackPath() (string, error)

func DataDirPath

func DataDirPath() (string, error)

func DefaultManagedStackDir

func DefaultManagedStackDir() string

func KnownConfigPaths

func KnownConfigPaths() ([]string, error)

func ManagedStackDir

func ManagedStackDir(stackName string) (string, error)

func ManagedStackNeedsScaffold

func ManagedStackNeedsScaffold(cfg Config) (bool, error)

func ManagedStacksDirPath

func ManagedStacksDirPath() (string, error)

func Marshal

func Marshal(cfg Config) ([]byte, error)

func NATSConfigPath

func NATSConfigPath(cfg Config) string

func NormalizeCockpitSettings

func NormalizeCockpitSettings(cfg *Config)

func NormalizeCockpitSettingsForPlatform

func NormalizeCockpitSettingsForPlatform(cfg *Config, platform system.Platform)

func PGPassPath

func PGPassPath(cfg Config) string

func PackageManagerFieldDescriptionForConfig

func PackageManagerFieldDescriptionForConfig(cfg Config) string

func PackageManagerFieldDescriptionForPlatform

func PackageManagerFieldDescriptionForPlatform(platform system.Platform) string

func PgAdminServersPath

func PgAdminServersPath(cfg Config) string

func PromptYesNo

func PromptYesNo(in io.Reader, out io.Writer, question string, defaultYes bool) (bool, error)

func RedisACLPath

func RedisACLPath(cfg Config) string

func ResolveSelectedStackName

func ResolveSelectedStackName() (string, error)

func Save

func Save(path string, cfg Config) error

func SelectedStackName

func SelectedStackName() string

func SetCurrentStackName

func SetCurrentStackName(name string) error

func ValidateOrError

func ValidateOrError(cfg Config) error

func ValidateStackName

func ValidateStackName(name string) error

Types

type BehaviorConfig

type BehaviorConfig struct {
	WaitForServicesStart bool `yaml:"wait_for_services_on_start"`
	StartupTimeoutSec    int  `yaml:"startup_timeout_seconds"`
}

type Config

type Config struct {
	SchemaVersion int              `yaml:"schema_version"`
	Stack         StackConfig      `yaml:"stack"`
	Services      ServicesConfig   `yaml:"services"`
	Connection    ConnectionConfig `yaml:"connection"`
	Ports         PortsConfig      `yaml:"ports"`
	URLs          URLsConfig       `yaml:"urls"`
	Behavior      BehaviorConfig   `yaml:"behavior"`
	Setup         SetupConfig      `yaml:"setup"`
	TUI           TUIConfig        `yaml:"tui"`
	System        SystemConfig     `yaml:"system"`
}

func Default

func Default() Config

func DefaultForStack

func DefaultForStack(stackName string) Config

func DefaultForStackOnPlatform

func DefaultForStackOnPlatform(stackName string, platform system.Platform) Config

func Load

func Load(path string) (Config, error)

func RunWizard

func RunWizard(in io.Reader, out io.Writer, base Config) (Config, error)

func (*Config) ApplyDerivedFields

func (c *Config) ApplyDerivedFields()

func (Config) CockpitEnabled

func (c Config) CockpitEnabled() bool

func (Config) EnabledStackServiceCount

func (c Config) EnabledStackServiceCount() int

func (Config) MeilisearchEnabled

func (c Config) MeilisearchEnabled() bool

func (Config) NATSEnabled

func (c Config) NATSEnabled() bool

func (Config) PgAdminBootstrapEnabled

func (c Config) PgAdminBootstrapEnabled() bool

func (Config) PgAdminEnabled

func (c Config) PgAdminEnabled() bool

func (Config) PostgresEnabled

func (c Config) PostgresEnabled() bool

func (Config) RedisACLEnabled

func (c Config) RedisACLEnabled() bool

func (Config) RedisEnabled

func (c Config) RedisEnabled() bool

func (Config) SeaweedFSEnabled

func (c Config) SeaweedFSEnabled() bool

type ConnectionConfig

type ConnectionConfig struct {
	Host                 string `yaml:"host"`
	PostgresDatabase     string `yaml:"postgres_database"`
	PostgresUsername     string `yaml:"postgres_username"`
	PostgresPassword     string `yaml:"postgres_password"`
	RedisPassword        string `yaml:"redis_password"`
	RedisACLUsername     string `yaml:"redis_acl_username"`
	RedisACLPassword     string `yaml:"redis_acl_password"`
	NATSToken            string `yaml:"nats_token"`
	SeaweedFSAccessKey   string `yaml:"seaweedfs_access_key"`
	SeaweedFSSecretKey   string `yaml:"seaweedfs_secret_key"`
	MeilisearchMasterKey string `yaml:"meilisearch_master_key"`
	PgAdminEmail         string `yaml:"pgadmin_email"`
	PgAdminPassword      string `yaml:"pgadmin_password"`
}

type MeilisearchServiceConfig

type MeilisearchServiceConfig struct {
	Image      string `yaml:"image"`
	DataVolume string `yaml:"data_volume"`
}

type NATSServiceConfig

type NATSServiceConfig struct {
	Image string `yaml:"image"`
}

type PgAdminServiceConfig

type PgAdminServiceConfig struct {
	Image                   string `yaml:"image"`
	DataVolume              string `yaml:"data_volume"`
	ServerMode              bool   `yaml:"server_mode"`
	BootstrapPostgresServer bool   `yaml:"bootstrap_postgres_server"`
	BootstrapServerName     string `yaml:"bootstrap_server_name"`
	BootstrapServerGroup    string `yaml:"bootstrap_server_group"`
}

type PortsConfig

type PortsConfig struct {
	Postgres    int `yaml:"postgres"`
	Redis       int `yaml:"redis"`
	NATS        int `yaml:"nats"`
	SeaweedFS   int `yaml:"seaweedfs"`
	Meilisearch int `yaml:"meilisearch"`
	PgAdmin     int `yaml:"pgadmin"`
	Cockpit     int `yaml:"cockpit"`
}

type PostgresServiceConfig

type PostgresServiceConfig struct {
	Image                     string `yaml:"image"`
	DataVolume                string `yaml:"data_volume"`
	MaintenanceDatabase       string `yaml:"maintenance_database"`
	MaxConnections            int    `yaml:"max_connections"`
	SharedBuffers             string `yaml:"shared_buffers"`
	LogMinDurationStatementMS int    `yaml:"log_min_duration_statement_ms"`
}

type RedisServiceConfig

type RedisServiceConfig struct {
	Image           string `yaml:"image"`
	DataVolume      string `yaml:"data_volume"`
	AppendOnly      bool   `yaml:"appendonly"`
	SavePolicy      string `yaml:"save_policy"`
	MaxMemoryPolicy string `yaml:"maxmemory_policy"`
}

type ScaffoldResult

type ScaffoldResult struct {
	StackDir            string
	ComposePath         string
	NATSConfigPath      string
	RedisACLPath        string
	PgAdminServersPath  string
	PGPassPath          string
	CreatedDir          bool
	WroteCompose        bool
	WroteNATSConfig     bool
	WroteRedisACL       bool
	WrotePgAdminServers bool
	WrotePGPass         bool
	AlreadyPresent      bool
}

func ScaffoldManagedStack

func ScaffoldManagedStack(cfg Config, force bool) (ScaffoldResult, error)

type SeaweedFSServiceConfig

type SeaweedFSServiceConfig struct {
	Image             string `yaml:"image"`
	DataVolume        string `yaml:"data_volume"`
	VolumeSizeLimitMB int    `yaml:"volume_size_limit_mb"`
}

type ServicesConfig

type ServicesConfig struct {
	PostgresContainer    string                   `yaml:"postgres_container"`
	RedisContainer       string                   `yaml:"redis_container"`
	NATSContainer        string                   `yaml:"nats_container"`
	SeaweedFSContainer   string                   `yaml:"seaweedfs_container"`
	MeilisearchContainer string                   `yaml:"meilisearch_container"`
	PgAdminContainer     string                   `yaml:"pgadmin_container"`
	Postgres             PostgresServiceConfig    `yaml:"postgres"`
	Redis                RedisServiceConfig       `yaml:"redis"`
	NATS                 NATSServiceConfig        `yaml:"nats"`
	SeaweedFS            SeaweedFSServiceConfig   `yaml:"seaweedfs"`
	Meilisearch          MeilisearchServiceConfig `yaml:"meilisearch"`
	PgAdmin              PgAdminServiceConfig     `yaml:"pgadmin"`
}

type SetupConfig

type SetupConfig struct {
	IncludePostgres      bool `yaml:"include_postgres"`
	IncludeRedis         bool `yaml:"include_redis"`
	IncludeCockpit       bool `yaml:"include_cockpit"`
	InstallCockpit       bool `yaml:"install_cockpit"`
	IncludeNATS          bool `yaml:"include_nats"`
	IncludeSeaweedFS     bool `yaml:"include_seaweedfs"`
	IncludeMeilisearch   bool `yaml:"include_meilisearch"`
	IncludePgAdmin       bool `yaml:"include_pgadmin"`
	ScaffoldDefaultStack bool `yaml:"scaffold_default_stack"`
}

type StackConfig

type StackConfig struct {
	Name        string `yaml:"name"`
	Dir         string `yaml:"dir"`
	ComposeFile string `yaml:"compose_file"`
	Managed     bool   `yaml:"managed"`
}

type SystemConfig

type SystemConfig struct {
	PackageManager string `yaml:"package_manager"`
}

type TUIConfig

type TUIConfig struct {
	AutoRefreshIntervalSec int `yaml:"auto_refresh_interval_seconds"`
}

type URLsConfig

type URLsConfig struct {
	SeaweedFS   string `yaml:"seaweedfs"`
	Meilisearch string `yaml:"meilisearch"`
	Cockpit     string `yaml:"cockpit"`
	PgAdmin     string `yaml:"pgadmin"`
}

type ValidationError

type ValidationError struct {
	Issues []ValidationIssue
}

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationIssue

type ValidationIssue struct {
	Field   string `yaml:"field"`
	Message string `yaml:"message"`
}

func Validate

func Validate(cfg Config) []ValidationIssue

Jump to

Keyboard shortcuts

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