Documentation ¶
Overview ¶
Package appconfig implements functionality related to reading and writing app configuration files.
Index ¶
- Constants
- Variables
- func ConfigFileExistsAtPath(p string) (bool, error)
- func NameFromContext(ctx context.Context) string
- func ResolveConfigFileFromPath(p string) (string, error)
- func WithConfig(ctx context.Context, cfg *Config) context.Context
- func WithName(ctx context.Context, name string) context.Context
- type Attached
- type AttachedSecrets
- type Build
- type Compute
- type Config
- func ConfigFromContext(ctx context.Context) *Config
- func FromAppAndMachineSet(ctx context.Context, appName string, machines machine.MachineSet) (*Config, string, error)
- func FromDefinition(definition *fly.Definition) (*Config, error)
- func FromRemoteApp(ctx context.Context, appName string) (*Config, error)
- func LoadConfig(path string) (cfg *Config, err error)
- func NewConfig() *Config
- func (c *Config) AllServices() (services []Service)
- func (cfg *Config) BuildStrategies() []string
- func (c *Config) ComputeForGroup(groupName string) *Compute
- func (c *Config) ConfigFilePath() string
- func (c *Config) DefaultProcessName() string
- func (cfg *Config) DeployStrategy() string
- func (c *Config) DetermineIPType(ipType string) string
- func (c *Config) DockerBuildTarget() string
- func (c *Config) Dockerfile() string
- func (c *Config) Flatten(groupName string) (*Config, error)
- func (c *Config) FormatProcessNames() string
- func (c *Config) HasUdpService() bool
- func (c *Config) Ignorefile() string
- func (c *Config) InitCmd(groupName string) ([]string, error)
- func (c *Config) InternalPort() int
- func (c *Config) IsUsingGPU() bool
- func (c *Config) MarshalAsTOML() ([]byte, error)
- func (c *Config) MarshalAsYAML() ([]byte, error)
- func (c *Config) MarshalJSON() ([]byte, error)
- func (cfg *Config) MergeFiles(files []*fly.File) error
- func (c *Config) ProcessNames() []string
- func (c *Config) SetConcurrency(soft int, hard int)
- func (c *Config) SetConfigFilePath(configFilePath string)
- func (c *Config) SetDockerCommand(cmd string)
- func (c *Config) SetDockerEntrypoint(entrypoint string)
- func (c *Config) SetEnvVariable(name, value string)
- func (c *Config) SetEnvVariables(vals map[string]string)
- func (c *Config) SetHttpCheck(path string, headers map[string]string)
- func (c *Config) SetInternalPort(port int)
- func (c *Config) SetKillSignal(signal string)
- func (c *Config) SetMachinesPlatform() error
- func (c *Config) SetMounts(volumes []Mount)
- func (c *Config) SetProcess(name, value string)
- func (c *Config) SetReleaseCommand(cmd string)
- func (c *Config) SetStatics(statics []Static)
- func (c *Config) ToConsoleMachineConfig() (*fly.MachineConfig, error)
- func (c *Config) ToDefinition() (*fly.Definition, error)
- func (c *Config) ToMachineConfig(processGroup string, src *fly.MachineConfig) (*fly.MachineConfig, error)
- func (c *Config) ToReleaseMachineConfig() (*fly.MachineConfig, error)
- func (c *Config) ToTestMachineConfig(svc *ServiceMachineCheck, origMachine *fly.Machine) (*fly.MachineConfig, error)
- func (cfg *Config) URL() *url.URL
- func (cfg *Config) Validate(ctx context.Context) (err error, extra_info string)
- func (cfg *Config) ValidateGroups(ctx context.Context, groups []string) (err error, extraInfo string)
- func (c *Config) WriteTo(w io.Writer, format string) (int64, error)
- func (c *Config) WriteToDisk(ctx context.Context, path string) (err error)
- func (c *Config) WriteToFile(filename string) (err error)
- type Deploy
- type Experimental
- type File
- type HTTPService
- type Metrics
- type Mount
- type Restart
- type RestartPolicy
- type Service
- type ServiceHTTPCheck
- type ServiceMachineCheck
- type ServiceTCPCheck
- type Static
- type TestMachineConfigErr
- type ToplevelCheck
Constants ¶
const (
// DefaultConfigFileName denotes the default application configuration file name.
DefaultConfigFileName = "fly.toml"
)
Variables ¶
var ( ValidationError = errors.New("invalid app configuration") MachinesDeployStrategies = []string{"canary", "rolling", "immediate", "bluegreen"} )
Functions ¶
func ConfigFileExistsAtPath ¶
func NameFromContext ¶
NameFromContext returns the app name ctx carries or an empty string.
func WithConfig ¶
WithConfig derives a context that carries cfg from ctx.
Types ¶
type Attached ¶ added in v0.2.100
type Attached struct {
Secrets AttachedSecrets `toml:"secrets,omitempty" json:"secrets,omitempty"`
}
type AttachedSecrets ¶ added in v0.2.100
type Build ¶
type Build struct { Builder string `toml:"builder,omitempty" json:"builder,omitempty"` Args map[string]string `toml:"args,omitempty" json:"args,omitempty"` Buildpacks []string `toml:"buildpacks,omitempty" json:"buildpacks,omitempty"` Image string `toml:"image,omitempty" json:"image,omitempty"` Settings map[string]any `toml:"settings,omitempty" json:"settings,omitempty"` Builtin string `toml:"builtin,omitempty" json:"builtin,omitempty"` Dockerfile string `toml:"dockerfile,omitempty" json:"dockerfile,omitempty"` Ignorefile string `toml:"ignorefile,omitempty" json:"ignorefile,omitempty"` DockerBuildTarget string `toml:"build-target,omitempty" json:"build-target,omitempty"` }
type Compute ¶ added in v0.1.122
type Compute struct { Size string `json:"size,omitempty" toml:"size,omitempty"` Memory string `json:"memory,omitempty" toml:"memory,omitempty"` *fly.MachineGuest `toml:",inline" json:",inline"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
type Config ¶
type Config struct { AppName string `toml:"app,omitempty" json:"app,omitempty"` PrimaryRegion string `toml:"primary_region,omitempty" json:"primary_region,omitempty"` KillSignal *string `toml:"kill_signal,omitempty" json:"kill_signal,omitempty"` KillTimeout *fly.Duration `toml:"kill_timeout,omitempty" json:"kill_timeout,omitempty"` SwapSizeMB *int `toml:"swap_size_mb,omitempty" json:"swap_size_mb,omitempty"` ConsoleCommand string `toml:"console_command,omitempty" json:"console_command,omitempty"` // Sections that are typically short and benefit from being on top Experimental *Experimental `toml:"experimental,omitempty" json:"experimental,omitempty"` Build *Build `toml:"build,omitempty" json:"build,omitempty"` Deploy *Deploy `toml:"deploy,omitempty" json:"deploy,omitempty"` Env map[string]string `toml:"env,omitempty" json:"env,omitempty"` // Fields that are process group aware must come after Processes Processes map[string]string `toml:"processes,omitempty" json:"processes,omitempty"` Mounts []Mount `toml:"mounts,omitempty" json:"mounts,omitempty"` HTTPService *HTTPService `toml:"http_service,omitempty" json:"http_service,omitempty"` Services []Service `toml:"services,omitempty" json:"services,omitempty"` Checks map[string]*ToplevelCheck `toml:"checks,omitempty" json:"checks,omitempty"` Files []File `toml:"files,omitempty" json:"files,omitempty"` HostDedicationID string `toml:"host_dedication_id,omitempty" json:"host_dedication_id,omitempty"` MachineChecks []*ServiceMachineCheck `toml:"machine_checks,omitempty" json:"machine_checks,omitempty"` Restart []Restart `toml:"restart,omitempty" json:"restart,omitempty"` Compute []*Compute `toml:"vm,omitempty" json:"vm,omitempty"` // Others, less important. Statics []Static `toml:"statics,omitempty" json:"statics,omitempty"` Metrics []*Metrics `toml:"metrics,omitempty" json:"metrics,omitempty"` // MergedFiles is a list of files that have been merged from the app config and flags. MergedFiles []*fly.File `toml:"-" json:"-"` // contains filtered or unexported fields }
Config wraps the properties of app configuration. NOTE: If you any new setting here, please also add a value for it at testdata/rull-reference.toml
func ConfigFromContext ¶
ConfigFromContext returns the Config ctx carries.
func FromAppAndMachineSet ¶
func FromDefinition ¶
func FromDefinition(definition *fly.Definition) (*Config, error)
func FromRemoteApp ¶ added in v0.0.479
func LoadConfig ¶
LoadConfig loads the app config at the given path.
func (*Config) AllServices ¶ added in v0.0.514
func (*Config) BuildStrategies ¶ added in v0.0.500
func (*Config) ComputeForGroup ¶ added in v0.2.3
ComputeForGroup finds the most specific VM compute requirements for this process group In reality there are only four valid cases:
- No [[vm]] section
- One [[vm]] section with `processes = [groupName]`
- Previous case plus global [[compute]] without processes
- Only a [[vm]] section without processes set which applies to all groups
func (*Config) ConfigFilePath ¶
func (*Config) DefaultProcessName ¶ added in v0.0.489
DefaultProcessName returns: * "app" when no processes are defined * "app" if present in the processes map * The first process name in ascending lexicographical order
func (*Config) DeployStrategy ¶ added in v0.2.61
func (*Config) DetermineIPType ¶ added in v0.2.95
func (*Config) DockerBuildTarget ¶
func (*Config) Dockerfile ¶
func (*Config) Flatten ¶ added in v0.0.514
Flatten generates a machine config specific to a process_group.
Only services, mounts, checks, metrics, files and restarts specific to the provided process group will be in the returned config.
func (*Config) FormatProcessNames ¶ added in v0.0.509
FormatProcessNames formats the process group list like `['foo', 'bar']`
func (*Config) HasUdpService ¶
func (*Config) Ignorefile ¶
func (*Config) InternalPort ¶ added in v0.0.500
func (*Config) IsUsingGPU ¶ added in v0.2.23
IsUsingGPU returns true if any VMs have a gpu-kind set.
func (*Config) MarshalAsTOML ¶ added in v0.2.57
MarshalAsTOML serializes the configuration to TOML format
func (*Config) MarshalAsYAML ¶ added in v0.2.57
MarshalAsYAML first marshals the config to JSON and then converts it to YAML this is done to pick up the json: struct tags; fortunately, we write YAML infrequently, and only on explicit user request
func (*Config) MarshalJSON ¶ added in v0.0.508
MarshalJSON implements the json.Marshaler interface
func (*Config) MergeFiles ¶ added in v0.1.64
MergeFiles merges the provided files with the files in the config wherein the provided files take precedence.
func (*Config) ProcessNames ¶ added in v0.0.509
ProcessNames lists each key of c.Processes, sorted lexicographically If c.Processes == nil, returns ["app"]
func (*Config) SetConcurrency ¶
func (*Config) SetConfigFilePath ¶ added in v0.0.540
func (*Config) SetDockerCommand ¶
func (*Config) SetDockerEntrypoint ¶
func (*Config) SetEnvVariable ¶
func (*Config) SetEnvVariables ¶
func (*Config) SetInternalPort ¶
func (*Config) SetKillSignal ¶
func (*Config) SetMachinesPlatform ¶
SetMachinesPlatform informs the TOML marshaller that this config is for the machines platform
func (*Config) SetProcess ¶
func (*Config) SetReleaseCommand ¶
func (*Config) SetStatics ¶
func (*Config) ToConsoleMachineConfig ¶ added in v0.0.557
func (c *Config) ToConsoleMachineConfig() (*fly.MachineConfig, error)
func (*Config) ToDefinition ¶
func (c *Config) ToDefinition() (*fly.Definition, error)
func (*Config) ToMachineConfig ¶ added in v0.0.510
func (c *Config) ToMachineConfig(processGroup string, src *fly.MachineConfig) (*fly.MachineConfig, error)
func (*Config) ToReleaseMachineConfig ¶ added in v0.0.510
func (c *Config) ToReleaseMachineConfig() (*fly.MachineConfig, error)
func (*Config) ToTestMachineConfig ¶ added in v0.2.55
func (c *Config) ToTestMachineConfig(svc *ServiceMachineCheck, origMachine *fly.Machine) (*fly.MachineConfig, error)
func (*Config) ValidateGroups ¶ added in v0.1.120
func (*Config) WriteToDisk ¶
func (*Config) WriteToFile ¶
type Deploy ¶
type Deploy struct { ReleaseCommand string `toml:"release_command,omitempty" json:"release_command,omitempty"` ReleaseCommandTimeout *fly.Duration `toml:"release_command_timeout,omitempty" json:"release_command_timeout,omitempty"` Strategy string `toml:"strategy,omitempty" json:"strategy,omitempty"` WaitTimeout *fly.Duration `toml:"wait_timeout,omitempty" json:"wait_timeout,omitempty"` }
type Experimental ¶
type Experimental struct { Cmd []string `toml:"cmd,omitempty" json:"cmd,omitempty"` Entrypoint []string `toml:"entrypoint,omitempty" json:"entrypoint,omitempty"` Exec []string `toml:"exec,omitempty" json:"exec,omitempty"` AutoRollback bool `toml:"auto_rollback,omitempty" json:"auto_rollback,omitempty"` EnableConsul bool `toml:"enable_consul,omitempty" json:"enable_consul,omitempty"` EnableEtcd bool `toml:"enable_etcd,omitempty" json:"enable_etcd,omitempty"` LazyLoadImages bool `toml:"lazy_load_images,omitempty" json:"lazy_load_images,omitempty"` Attached Attached `toml:"attached,omitempty" json:"attached,omitempty"` MachineConfig string `toml:"machine_config,omitempty" json:"machine_config,omitempty"` }
type File ¶ added in v0.1.64
type File struct { GuestPath string `toml:"guest_path,omitempty" json:"guest_path,omitempty" validate:"required"` LocalPath string `toml:"local_path,omitempty" json:"local_path,omitempty"` SecretName string `toml:"secret_name,omitempty" json:"secret_name,omitempty"` RawValue string `toml:"raw_value,omitempty" json:"raw_value,omitempty"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
type HTTPService ¶
type HTTPService struct { InternalPort int `json:"internal_port,omitempty" toml:"internal_port,omitempty" validate:"required,numeric"` ForceHTTPS bool `toml:"force_https,omitempty" json:"force_https,omitempty"` // AutoStopMachines and AutoStartMachines should not have omitempty for TOML; see the note in Service. AutoStopMachines *fly.MachineAutostop `json:"auto_stop_machines,omitempty" toml:"auto_stop_machines"` AutoStartMachines *bool `json:"auto_start_machines,omitempty" toml:"auto_start_machines"` MinMachinesRunning *int `json:"min_machines_running,omitempty" toml:"min_machines_running,omitempty"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` Concurrency *fly.MachineServiceConcurrency `toml:"concurrency,omitempty" json:"concurrency,omitempty"` TLSOptions *fly.TLSOptions `json:"tls_options,omitempty" toml:"tls_options,omitempty"` HTTPOptions *fly.HTTPOptions `json:"http_options,omitempty" toml:"http_options,omitempty"` HTTPChecks []*ServiceHTTPCheck `json:"checks,omitempty" toml:"checks,omitempty"` MachineChecks []*ServiceMachineCheck `json:"machine_checks,omitempty" toml:"machine_checks,omitempty"` }
func (*HTTPService) ToService ¶ added in v0.0.514
func (s *HTTPService) ToService() *Service
type Metrics ¶ added in v0.1.93
type Metrics struct { *fly.MachineMetrics Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
type Mount ¶ added in v0.0.522
type Mount struct { Source string `toml:"source,omitempty" json:"source,omitempty"` Destination string `toml:"destination,omitempty" json:"destination,omitempty"` InitialSize string `toml:"initial_size,omitempty" json:"initial_size,omitempty"` SnapshotRetention *int `toml:"snapshot_retention,omitempty" json:"snapshot_retention,omitempty"` AutoExtendSizeThreshold int `toml:"auto_extend_size_threshold,omitempty" json:"auto_extend_size_threshold,omitempty"` AutoExtendSizeIncrement string `toml:"auto_extend_size_increment,omitempty" json:"auto_extend_size_increment,omitempty"` AutoExtendSizeLimit string `toml:"auto_extend_size_limit,omitempty" json:"auto_extend_size_limit,omitempty"` Processes []string `toml:"processes,omitempty" json:"processes,omitempty"` }
type Restart ¶ added in v0.2.28
type Restart struct { Policy RestartPolicy `toml:"policy,omitempty" json:"policy,omitempty"` MaxRetries int `toml:"retries,omitempty" json:"retries,omitempty"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
type RestartPolicy ¶ added in v0.2.28
type RestartPolicy string
const ( RestartPolicyAlways RestartPolicy = "always" RestartPolicyNever RestartPolicy = "never" RestartPolicyOnFailure RestartPolicy = "on-failure" )
type Service ¶
type Service struct { Protocol string `json:"protocol,omitempty" toml:"protocol"` InternalPort int `json:"internal_port,omitempty" toml:"internal_port"` // AutoStopMachines and AutoStartMachines should not have omitempty for TOML. The encoder // already omits nil since it can't be represented, and omitempty makes it omit false as well. AutoStopMachines *fly.MachineAutostop `json:"auto_stop_machines,omitempty" toml:"auto_stop_machines"` AutoStartMachines *bool `json:"auto_start_machines,omitempty" toml:"auto_start_machines"` MinMachinesRunning *int `json:"min_machines_running,omitempty" toml:"min_machines_running,omitempty"` Ports []fly.MachinePort `json:"ports,omitempty" toml:"ports"` Concurrency *fly.MachineServiceConcurrency `json:"concurrency,omitempty" toml:"concurrency"` TCPChecks []*ServiceTCPCheck `json:"tcp_checks,omitempty" toml:"tcp_checks,omitempty"` HTTPChecks []*ServiceHTTPCheck `json:"http_checks,omitempty" toml:"http_checks,omitempty"` MachineChecks []*ServiceMachineCheck `json:"machine_checks,omitempty" toml:"machine_checks,omitempty"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
type ServiceHTTPCheck ¶
type ServiceHTTPCheck struct { Interval *fly.Duration `json:"interval,omitempty" toml:"interval,omitempty"` Timeout *fly.Duration `json:"timeout,omitempty" toml:"timeout,omitempty"` GracePeriod *fly.Duration `toml:"grace_period,omitempty" json:"grace_period,omitempty"` // HTTP Specifics HTTPMethod *string `json:"method,omitempty" toml:"method,omitempty"` HTTPPath *string `json:"path,omitempty" toml:"path,omitempty"` HTTPProtocol *string `json:"protocol,omitempty" toml:"protocol,omitempty"` HTTPTLSSkipVerify *bool `json:"tls_skip_verify,omitempty" toml:"tls_skip_verify,omitempty"` HTTPTLSServerName *string `json:"tls_server_name,omitempty" toml:"tls_server_name,omitempty"` HTTPHeaders map[string]string `json:"headers,omitempty" toml:"headers,omitempty"` }
func (*ServiceHTTPCheck) String ¶
func (chk *ServiceHTTPCheck) String(port int) string
type ServiceMachineCheck ¶ added in v0.2.55
type ServiceMachineCheck struct { Command []string `json:"command,omitempty" toml:"command,omitempty"` Image string `json:"image,omitempty" toml:"image,omitempty"` Entrypoint []string `json:"entrypoint,omitempty" toml:"entrypoint,omitempty"` KillSignal *string `json:"kill_signal,omitempty" toml:"kill_signal,omitempty"` KillTimeout *fly.Duration `json:"kill_timeout,omitempty" toml:"kill_timeout,omitempty"` }
type ServiceTCPCheck ¶
type ServiceTCPCheck struct { Interval *fly.Duration `json:"interval,omitempty" toml:"interval,omitempty"` Timeout *fly.Duration `json:"timeout,omitempty" toml:"timeout,omitempty"` GracePeriod *fly.Duration `toml:"grace_period,omitempty" json:"grace_period,omitempty"` }
func (*ServiceTCPCheck) String ¶
func (chk *ServiceTCPCheck) String(port int) string
type Static ¶
type Static struct { GuestPath string `toml:"guest_path" json:"guest_path,omitempty" validate:"required"` UrlPrefix string `toml:"url_prefix" json:"url_prefix,omitempty" validate:"required"` TigrisBucket string `toml:"tigris_bucket,omitempty" json:"tigris_bucket"` IndexDocument string `toml:"index_document,omitempty" json:"index_document,omitempty"` }
type TestMachineConfigErr ¶ added in v0.2.55
type TestMachineConfigErr int
const ( MissingCommand TestMachineConfigErr = iota MissingImage )
func (TestMachineConfigErr) Error ¶ added in v0.2.55
func (e TestMachineConfigErr) Error() string
func (TestMachineConfigErr) Suggestion ¶ added in v0.2.55
func (e TestMachineConfigErr) Suggestion() string
type ToplevelCheck ¶
type ToplevelCheck struct { Port *int `json:"port,omitempty" toml:"port,omitempty"` Type *string `json:"type,omitempty" toml:"type,omitempty"` Interval *fly.Duration `json:"interval,omitempty" toml:"interval,omitempty"` Timeout *fly.Duration `json:"timeout,omitempty" toml:"timeout,omitempty"` GracePeriod *fly.Duration `json:"grace_period,omitempty" toml:"grace_period,omitempty"` HTTPMethod *string `json:"method,omitempty" toml:"method,omitempty"` HTTPPath *string `json:"path,omitempty" toml:"path,omitempty"` HTTPProtocol *string `json:"protocol,omitempty" toml:"protocol,omitempty"` HTTPTLSSkipVerify *bool `json:"tls_skip_verify,omitempty" toml:"tls_skip_verify,omitempty"` HTTPTLSServerName *string `json:"tls_server_name,omitempty" toml:"tls_server_name,omitempty"` HTTPHeaders map[string]string `json:"headers,omitempty" toml:"headers,omitempty"` Processes []string `json:"processes,omitempty" toml:"processes,omitempty"` }
func (*ToplevelCheck) String ¶
func (chk *ToplevelCheck) String() string