Documentation
¶
Index ¶
- Constants
- func BinDir() (string, error)
- func CheckUnknownFields(structType reflect.Type, configKeys []string, format string) error
- func DataDir() (string, error)
- func EnsureImageTempDir() (string, error)
- func GetConfigFormat(configFile string) (string, error)
- func GetConfigParser(format string) (koanf.Parser, error)
- func GetFieldNameForFormat(v any, fieldName, format string) string
- func HaloyConfigDir() (string, error)
- func HaloydConfigDir() (string, error)
- func ImageDecodeHook() mapstructure.DecodeHookFuncType
- func ImageTempDirPath() (string, error)
- func LoadEnvFilesForTargets(targets []string)
- func LoadEnvFilesFromDir(dir string)
- func LoadHaloyEnvFiles()
- func LoadHaloydEnvFiles()
- func PortDecodeHook() mapstructure.DecodeHookFuncType
- func SaveClientConfig(config *ClientConfig, path string) error
- func SaveHaloydConfig(config *HaloydConfig, path string) error
- type BuildArg
- type BuildConfig
- type BuildPushOption
- type ClientConfig
- type ContainerLabels
- type DeployConfig
- type DeploymentStrategy
- type Domain
- type EnvVar
- type HaloydAPIConfig
- type HaloydConfig
- type HealthMonitorConfig
- type HistoryStrategy
- type Image
- type ImageHistory
- type NamingStrategy
- type OnePasswordSourceConfig
- type Port
- type Preset
- type RegistryAuth
- type SecretProviders
- type ServerConfig
- type SourceReference
- type TargetConfig
- type ValueSource
Constants ¶
const ( LabelAppName = "dev.haloy.appName" LabelDeploymentID = "dev.haloy.deployment-id" LabelHealthCheckPath = "dev.haloy.health-check-path" // optional default to "/" LabelPort = "dev.haloy.port" // optional LabelMinReadySeconds = "dev.haloy.min-ready-seconds" // optional, default 0 // Format strings for indexed canonical domains and aliases. // Use fmt.Sprintf(LabelDomainCanonical, index) to get "dev.haloy.domain.<index>" LabelDomainCanonical = "dev.haloy.domain.%d" // Use fmt.Sprintf(LabelDomainAlias, domainIndex, aliasIndex) to get "dev.haloy.domain.<domainIndex>.alias.<aliasIndex>" LabelDomainAlias = "dev.haloy.domain.%d.alias.%d" )
Variables ¶
This section is empty.
Functions ¶
func BinDir ¶
BinDir returns the directory where haloy binaries are installed. Defaults to /usr/local/bin.
func CheckUnknownFields ¶
func DataDir ¶
DataDir returns the Haloy data directory. Uses HALOY_DATA_DIR env var if set, otherwise defaults to /var/lib/haloy.
func EnsureImageTempDir ¶
EnsureImageTempDir creates the daemon image temp directory if needed.
func GetConfigFormat ¶
func GetFieldNameForFormat ¶
GetFieldNameForFormat returns the field name as it appears in the specified format
func HaloyConfigDir ¶
HaloyConfigDir returns the configuration directory for haloy (client CLI). Uses HALOY_CONFIG_DIR env var if set, otherwise defaults to ~/.config/haloy.
func HaloydConfigDir ¶
HaloydConfigDir returns the configuration directory for haloyd (daemon). Uses HALOY_CONFIG_DIR env var if set, otherwise defaults to /etc/haloy.
func ImageDecodeHook ¶
func ImageDecodeHook() mapstructure.DecodeHookFuncType
func ImageTempDirPath ¶
ImageTempDirPath returns the directory used for temporary image tar files on the daemon. It is placed under the haloy data directory so large uploads/assembly don't depend on /tmp.
func LoadEnvFilesForTargets ¶
func LoadEnvFilesForTargets(targets []string)
func LoadEnvFilesFromDir ¶
func LoadEnvFilesFromDir(dir string)
LoadEnvFilesFromDir loads .env and .env.local files from the specified directory. This is used to load env files from the config file's directory.
func LoadHaloyEnvFiles ¶
func LoadHaloyEnvFiles()
LoadHaloyEnvFiles loads environment files for haloy (client CLI). Loads from current directory and ~/.config/haloy.
func LoadHaloydEnvFiles ¶
func LoadHaloydEnvFiles()
LoadHaloydEnvFiles loads environment files for haloyd (daemon). Loads from current directory and /etc/haloy.
func PortDecodeHook ¶
func PortDecodeHook() mapstructure.DecodeHookFuncType
func SaveClientConfig ¶
func SaveClientConfig(config *ClientConfig, path string) error
func SaveHaloydConfig ¶
func SaveHaloydConfig(config *HaloydConfig, path string) error
Types ¶
type BuildArg ¶
type BuildArg struct {
Name string `json:"name" yaml:"name" toml:"name"`
ValueSource `mapstructure:",squash" json:",inline" yaml:",inline" toml:",inline"`
}
type BuildConfig ¶
type BuildConfig struct {
Context string `json:"context,omitempty" yaml:"context,omitempty" toml:"context,omitempty"`
Dockerfile string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty" toml:"dockerfile,omitempty"`
Platform string `json:"platform,omitempty" yaml:"platform,omitempty" toml:"platform,omitempty"`
Args []BuildArg `json:"args,omitempty" yaml:"args,omitempty" toml:"args,omitempty"`
Push BuildPushOption `json:"push,omitempty" yaml:"push,omitempty" toml:"push,omitempty"`
}
func (*BuildConfig) Validate ¶
func (b *BuildConfig) Validate(format string) error
type BuildPushOption ¶
type BuildPushOption string
const ( BuildPushOptionServer BuildPushOption = "server" BuildPushOptionRegistry BuildPushOption = "registry" )
type ClientConfig ¶
type ClientConfig struct {
Servers map[string]ServerConfig `json:"servers" yaml:"servers" toml:"servers"`
}
func LoadClientConfig ¶
func LoadClientConfig(path string) (*ClientConfig, error)
func (*ClientConfig) AddServer ¶
func (cc *ClientConfig) AddServer(url, tokenEnv string, force bool) error
func (*ClientConfig) DeleteServer ¶
func (cc *ClientConfig) DeleteServer(url string) error
func (*ClientConfig) ListServers ¶
func (cc *ClientConfig) ListServers() []string
type ContainerLabels ¶
type ContainerLabels struct {
AppName string
DeploymentID string
HealthCheckPath string
Port Port
MinReadySeconds int
Domains []Domain
}
func ParseContainerLabels ¶
func ParseContainerLabels(labels map[string]string) (*ContainerLabels, error)
Parse from docker labels to ContainerLabels struct.
func (*ContainerLabels) ToLabels ¶
func (cl *ContainerLabels) ToLabels() map[string]string
ToLabels converts the ContainerLabels struct back to a map[string]string.
func (*ContainerLabels) Validate ¶
func (cl *ContainerLabels) Validate() error
We assume that all labels need to be present for the labels to be valid.
type DeployConfig ¶
type DeployConfig struct {
Images map[string]*Image `json:"images,omitempty" yaml:"images,omitempty" toml:"images,omitempty"`
TargetConfig `mapstructure:",squash" json:",inline" yaml:",inline" toml:",inline"`
Targets map[string]*TargetConfig `json:"targets,omitempty" yaml:"targets,omitempty" toml:"targets,omitempty"`
SecretProviders *SecretProviders `json:"secretProviders,omitempty" yaml:"secret_providers,omitempty" toml:"secret_providers,omitempty"`
GlobalPreDeploy []string `json:"globalPreDeploy,omitempty" yaml:"global_pre_deploy,omitempty" toml:"global_pre_deploy,omitempty"`
GlobalPostDeploy []string `json:"globalPostDeploy,omitempty" yaml:"global_post_deploy,omitempty" toml:"global_post_deploy,omitempty"`
}
func (*DeployConfig) Validate ¶
func (dc *DeployConfig) Validate() error
type DeploymentStrategy ¶
type DeploymentStrategy string
const ( DeploymentStrategyRolling DeploymentStrategy = "rolling" // Default: blue-green deployments DeploymentStrategyReplace DeploymentStrategy = "replace" // Stop old, start new )
type Domain ¶
type EnvVar ¶
type EnvVar struct {
Name string `json:"name" yaml:"name" toml:"name"`
ValueSource `mapstructure:",squash" json:",inline" yaml:",inline" toml:",inline"`
// BuildArg indicates this environment variable should also be included as a build argument.
BuildArg bool `json:"buildArg,omitempty" yaml:"build_arg,omitempty" toml:"build_arg,omitempty"`
}
type HaloydAPIConfig ¶
type HaloydAPIConfig struct {
Domain string `json:"domain" yaml:"domain" toml:"domain"`
}
type HaloydConfig ¶
type HaloydConfig struct {
API HaloydAPIConfig `json:"api" yaml:"api" toml:"api"`
HealthMonitor HealthMonitorConfig `json:"health_monitor" yaml:"health_monitor" toml:"health_monitor"`
}
func LoadHaloydConfig ¶
func LoadHaloydConfig(path string) (*HaloydConfig, error)
func (*HaloydConfig) Normalize ¶
func (mc *HaloydConfig) Normalize() *HaloydConfig
Normalize sets default values for HaloydConfig
func (*HaloydConfig) Validate ¶
func (mc *HaloydConfig) Validate() error
type HealthMonitorConfig ¶
type HealthMonitorConfig struct {
Enabled *bool `json:"enabled" yaml:"enabled" toml:"enabled"` // nil means enabled (default)
Interval string `json:"interval" yaml:"interval" toml:"interval"` // e.g., "15s"
Fall int `json:"fall" yaml:"fall" toml:"fall"` // Mark unhealthy after N failures
Rise int `json:"rise" yaml:"rise" toml:"rise"` // Mark healthy after N successes
Timeout string `json:"timeout" yaml:"timeout" toml:"timeout"` // Per-check timeout, e.g., "5s"
}
HealthMonitorConfig holds configuration for continuous health monitoring.
func (*HealthMonitorConfig) GetFall ¶
func (c *HealthMonitorConfig) GetFall() int
GetFall returns the fall threshold, defaulting to 3 if not set.
func (*HealthMonitorConfig) GetInterval ¶
func (c *HealthMonitorConfig) GetInterval() time.Duration
GetInterval parses the interval string and returns the duration. Returns the default of 15s if not set or invalid.
func (*HealthMonitorConfig) GetRise ¶
func (c *HealthMonitorConfig) GetRise() int
GetRise returns the rise threshold, defaulting to 2 if not set.
func (*HealthMonitorConfig) GetTimeout ¶
func (c *HealthMonitorConfig) GetTimeout() time.Duration
GetTimeout parses the timeout string and returns the duration. Returns the default of 5s if not set or invalid.
func (*HealthMonitorConfig) IsEnabled ¶
func (c *HealthMonitorConfig) IsEnabled() bool
IsEnabled returns whether health monitoring is enabled. Defaults to true if not explicitly set.
type HistoryStrategy ¶
type HistoryStrategy string
const ( HistoryStrategyLocal HistoryStrategy = "local" // Keep images locally (default) HistoryStrategyRegistry HistoryStrategy = "registry" // Rely on registry tags HistoryStrategyNone HistoryStrategy = "none" // No rollback support )
type Image ¶
type Image struct {
Repository string `json:"repository" yaml:"repository" toml:"repository"`
Tag string `json:"tag,omitempty" yaml:"tag,omitempty" toml:"tag,omitempty"`
History *ImageHistory `json:"history,omitempty" yaml:"history,omitempty" toml:"history,omitempty"`
RegistryAuth *RegistryAuth `json:"registry,omitempty" yaml:"registry,omitempty" toml:"registry,omitempty"`
Build *bool `json:"build,omitempty" yaml:"build,omitempty" toml:"build,omitempty"`
BuildConfig *BuildConfig `json:"buildConfig,omitempty" yaml:"build_config,omitempty" toml:"build_config,omitempty"`
}
func (*Image) GetEffectivePushStrategy ¶
func (i *Image) GetEffectivePushStrategy() BuildPushOption
func (*Image) GetRegistryServer ¶
GetRegistryServer returns the registry server for the image. If explicitly set in RegistryAuth.Server, that value is used. Otherwise, it parses the server from the Repository field. Defaults to "docker.io" (Docker Hub) if no server can be determined.
func (*Image) ShouldBuild ¶
type ImageHistory ¶
type ImageHistory struct {
Strategy HistoryStrategy `json:"strategy" yaml:"strategy" toml:"strategy"`
Count *int `json:"count,omitempty" yaml:"count,omitempty" toml:"count,omitempty"`
Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty" toml:"pattern,omitempty"`
}
func (*ImageHistory) Validate ¶
func (h *ImageHistory) Validate() error
type NamingStrategy ¶
type NamingStrategy string
const ( NamingStrategyDynamic NamingStrategy = "dynamic" // Default: app-deploymentID NamingStrategyStatic NamingStrategy = "static" // app (requires replace strategy) )
type OnePasswordSourceConfig ¶
type Port ¶
type Port string
Using custom Port type so we can use both string and int for port in the config.
type RegistryAuth ¶
type RegistryAuth struct {
// Server is optional. If not set, it will be parsed from the Repository field.
Server string `json:"server,omitempty" yaml:"server,omitempty" toml:"server,omitempty"`
Username ValueSource `json:"username" yaml:"username" toml:"username"`
Password ValueSource `json:"password" yaml:"password" toml:"password"`
}
type SecretProviders ¶
type SecretProviders struct {
OnePassword map[string]OnePasswordSourceConfig `json:"onepassword,omitempty" yaml:"onepassword,omitempty" toml:"onepassword,omitempty"`
}
type ServerConfig ¶
type ServerConfig struct {
TokenEnv string `json:"token_env" yaml:"token_env" toml:"token_env"`
}
type SourceReference ¶
type SourceReference struct {
Env string `json:"env,omitempty" yaml:"env,omitempty" toml:"env,omitempty"`
Secret string `json:"secret,omitempty" yaml:"secret,omitempty" toml:"secret,omitempty"`
}
SourceReference defines a reference to a value from an external source. Only one of its fields should be set.
func (*SourceReference) Validate ¶
func (sr *SourceReference) Validate() error
Validate ensures that exactly one source type is specified in the reference.
type TargetConfig ¶
type TargetConfig struct {
// Name is the application name for this deployment.
// In a multi-target file, if this is omitted, the map key from 'targets' is used.
// In a single-deployment file, this is required at the top level.
Name string `json:"name,omitempty" yaml:"name,omitempty" toml:"name,omitempty"`
// Preset applies default configurations for specific use cases, like databases.
Preset Preset `json:"preset,omitempty" yaml:"preset,omitempty" toml:"preset,omitempty"`
// Image can be defined inline OR reference a named image (ImageKey) from the Images map
Image *Image `json:"image,omitempty" yaml:"image,omitempty" toml:"image,omitempty"`
ImageKey string `json:"imageKey,omitempty" yaml:"image_key,omitempty" toml:"image_key,omitempty"`
Server string `json:"server,omitempty" yaml:"server,omitempty" toml:"server,omitempty"`
APIToken *ValueSource `json:"apiToken,omitempty" yaml:"api_token,omitempty" toml:"api_token,omitempty"`
DeploymentStrategy DeploymentStrategy `json:"deploymentStrategy,omitempty" yaml:"deployment_strategy,omitempty" toml:"deployment_strategy,omitempty"`
NamingStrategy NamingStrategy `json:"namingStrategy,omitempty" yaml:"naming_strategy,omitempty" toml:"naming_strategy,omitempty"`
Protected *bool `json:"protected,omitempty" yaml:"protected,omitempty" toml:"protected,omitempty"`
Domains []Domain `json:"domains,omitempty" yaml:"domains,omitempty" toml:"domains,omitempty"`
Env []EnvVar `json:"env,omitempty" yaml:"env,omitempty" toml:"env,omitempty"`
HealthCheckPath string `json:"healthCheckPath,omitempty" yaml:"health_check_path,omitempty" toml:"health_check_path,omitempty"`
MinReadySeconds *int `json:"minReadySeconds,omitempty" yaml:"min_ready_seconds,omitempty" toml:"min_ready_seconds,omitempty"`
Port Port `json:"port,omitempty" yaml:"port,omitempty" toml:"port,omitempty"`
Replicas *int `json:"replicas,omitempty" yaml:"replicas,omitempty" toml:"replicas,omitempty"`
Volumes []string `json:"volumes,omitempty" yaml:"volumes,omitempty" toml:"volumes,omitempty"`
Network string `json:"network,omitempty" yaml:"network,omitempty" toml:"network,omitempty"`
PreDeploy []string `json:"preDeploy,omitempty" yaml:"pre_deploy,omitempty" toml:"pre_deploy,omitempty"`
PostDeploy []string `json:"postDeploy,omitempty" yaml:"post_deploy,omitempty" toml:"post_deploy,omitempty"`
// Non config fields. Not read from the config file and populated on load.
TargetName string `json:"-" yaml:"-" toml:"-"`
Format string `json:"-" yaml:"-" toml:"-"`
}
func (*TargetConfig) Validate ¶
func (tc *TargetConfig) Validate(format string) error
type ValueSource ¶
type ValueSource struct {
Value string `json:"value,omitempty" yaml:"value,omitempty" toml:"value,omitempty"`
From *SourceReference `json:"from,omitempty" yaml:"from,omitempty" toml:"from,omitempty"`
}
ValueSource represents a value that can be a plaintext literal or a sourced reference. Only one of its fields should be set.
func (*ValueSource) Validate ¶
func (vs *ValueSource) Validate() error
Validate ensures that the value is provided either as a literal or a 'From' reference, but not both.