Documentation
¶
Index ¶
- Constants
- func CheckUnknownFields(structType reflect.Type, configKeys []string, format string) error
- func ConfigDir() (string, error)
- func DataDir() (string, error)
- func GetConfigFormat(configFile string) (string, error)
- func GetConfigParser(format string) (koanf.Parser, error)
- func GetFieldNameForFormat(v any, fieldName, format string) string
- func IsSystemMode() bool
- func LoadEnvFiles()
- func LoadEnvFilesForTargets(targets []string)
- 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 HaloydConfig
- 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 "/" LabelACMEEmail = "dev.haloy.acme.email" LabelPort = "dev.haloy.port" // optional // 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" // Used to identify the role of the container (e.g., "haproxy", "haloyd", etc.) LabelRole = "dev.haloy.role" )
const ( HAProxyLabelRole = "haproxy" HaloydLabelRole = "haloyd" AppLabelRole = "app" )
Variables ¶
This section is empty.
Functions ¶
func CheckUnknownFields ¶
func ConfigDir ¶
ConfigDir returns the configuration directory for haloy/haloyadm System mode: /etc/haloy User mode: ~/.config/haloy
func DataDir ¶
DataDir returns the Haloy data directory Should work for code run in containers and host filesystem. System install: /var/lib/haloy User install: ~/.local/share/haloy
func GetConfigFormat ¶
func GetFieldNameForFormat ¶
GetFieldNameForFormat returns the field name as it appears in the specified format
func IsSystemMode ¶
func IsSystemMode() bool
func LoadEnvFiles ¶
func LoadEnvFiles()
func LoadEnvFilesForTargets ¶
func LoadEnvFilesForTargets(targets []string)
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
ACMEEmail string
Port Port
Domains []Domain
Role string
}
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"`
}
type DeploymentStrategy ¶
type DeploymentStrategy string
const ( DeploymentStrategyRolling DeploymentStrategy = "rolling" // Default: blue-green 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"`
}
type HaloydConfig ¶
type HaloydConfig struct {
API struct {
Domain string `json:"domain" yaml:"domain" toml:"domain"`
} `json:"api" yaml:"api" toml:"api"`
Certificates struct {
AcmeEmail string `json:"acmeEmail" yaml:"acme_email" toml:"acme_email"`
} `json:"certificates" yaml:"certificates" toml:"certificates"`
}
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 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) 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"`
ACMEEmail string `json:"acmeEmail,omitempty" yaml:"acme_email,omitempty" toml:"acme_email,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"`
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.