model

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDeployedAppsPerRegion

func CountDeployedAppsPerRegion(apps []ScaleState) map[string]int

func NewDefaultDeployParams

func NewDefaultDeployParams() []string

func NewDefaultLaunchParams

func NewDefaultLaunchParams(
	appName string,
	orgSlug string,
) []string

Types

type AppAtFsNode

type AppAtFsNode struct {
	Path             string
	AppYaml          string
	AppConfigUntyped map[string]any
	AppConfig        AppConfig
	AppConfigErr     error
}

func (AppAtFsNode) ErrCause

func (s AppAtFsNode) ErrCause() error

func (AppAtFsNode) IsAppNode

func (s AppAtFsNode) IsAppNode() bool

func (AppAtFsNode) IsAppSyntaxValid

func (s AppAtFsNode) IsAppSyntaxValid() bool

func (AppAtFsNode) IsValidApp

func (s AppAtFsNode) IsValidApp() bool

func (AppAtFsNode) ToPreCalculatedApoConf

func (s AppAtFsNode) ToPreCalculatedApoConf() *PreCalculatedAppConfig

type AppConfig

type AppConfig struct {
	App           string            `yaml:"app" toml:"app"`
	Org           string            `yaml:"org" toml:"org,omitempty"`
	PrimaryRegion string            `yaml:"primary_region" toml:"primary_region,omitempty"`
	ExtraRegions  []string          `yaml:"extra_regions,omitempty" toml:"extra_regions,omitempty"`
	Source        Source            `yaml:"source,omitempty" toml:"source"`
	MergeCfg      MergeCfg          `yaml:"merge_cfg,omitempty" toml:"merge_cfg" json:"merge_cfg,omitempty"`
	Services      []Service         `yaml:"services,omitempty" toml:"services,omitempty"`
	HttpService   *HttpService      `yaml:"http_service,omitempty" toml:"http_service,omitempty"`
	LaunchParams  []string          `yaml:"launch_params,omitempty" toml:"launch_params,omitempty"`
	DeployParams  []string          `yaml:"deploy_params,omitempty" toml:"deploy_params"`
	Env           map[string]string `yaml:"env,omitempty" toml:"env,omitempty"`
	Build         map[string]any    `yaml:"build,omitempty" toml:"build,omitempty"`
	Mounts        []Mount           `yaml:"mounts,omitempty" toml:"mounts,omitempty"` // fly.io only supports one mount :S
	Volumes       []VolumeConfig    `yaml:"volumes,omitempty" toml:"volumes,omitempty"`
	Machines      MachineConfig     `yaml:"machines,omitempty" toml:"machines,omitempty"`
	Secrets       []SecretRef       `yaml:"secrets,omitempty" toml:"secrets,omitempty"`
	NetworkConfig NetworkConfig     `yaml:"network,omitempty" toml:"network,omitempty"`
	KillTimeout   *int              `yaml:"kill_timeout,omitempty" toml:"kill_timeout,omitempty"`
}

func (*AppConfig) MinMachinesFromServices added in v0.0.41

func (a *AppConfig) MinMachinesFromServices() int

func (*AppConfig) RegionsWPrimaryLast

func (a *AppConfig) RegionsWPrimaryLast() []string

func (*AppConfig) Validate

func (a *AppConfig) Validate(options ...ValidateAppConfigOptions) error

func (AppConfig) WithKillTimeout added in v0.0.43

func (a AppConfig) WithKillTimeout(seconds int) AppConfig

type AppDeployFailure

type AppDeployFailure struct {
	Spec  AppAtFsNode
	Cause error
}

type AppDeploySuccess

type AppDeploySuccess struct {
	Spec        AppAtFsNode
	SuccessType SingleAppDeploySuccessType
}

type CommonAppConfig

type CommonAppConfig struct {
	AppDefaults      map[string]any `yaml:"app_defaults" toml:"app_defaults"`   // default yaml tree for all apps
	AppSubstitutions map[string]any `yaml:"substitutions" toml:"substitutions"` // raw text substitution regexes
	AppOverrides     map[string]any `yaml:"app_overrides" toml:"app_overrides"` // yaml overrides for all apps
}

CommonAppConfig is configuration defined in project.yaml files that applies to all apps in the project

func (CommonAppConfig) MakeAppConfig

func (c CommonAppConfig) MakeAppConfig(appYaml []byte, validate ...bool) (AppConfig, map[string]any, error)

MakeAppConfig creates an AppConfig from a raw app.yaml file, applying all substitutions and overrides, from the parent projects and their CommonAppConfig's.

func (CommonAppConfig) Plus

Plus merges two CommonAppConfig's, used when traversing the project tree with projects-in-projects.

type Concurrency

type Concurrency struct {
	Type      string `yaml:"type" toml:"type"`
	SoftLimit int    `yaml:"soft_limit" toml:"soft_limit"`
	HardLimit int    `yaml:"hard_limit" toml:"hard_limit"`
}

type DeployConfig

type DeployConfig struct {
	Force             bool
	Retries           int
	AttemptTimeout    time.Duration
	AbortOnFirstError bool
}

func NewDefaultDeployConfig

func NewDefaultDeployConfig() DeployConfig

func (DeployConfig) WithAbortOnFirstError

func (c DeployConfig) WithAbortOnFirstError(state ...bool) DeployConfig

func (DeployConfig) WithAttemptTimeout

func (c DeployConfig) WithAttemptTimeout(timeout ...time.Duration) DeployConfig

func (DeployConfig) WithForce

func (c DeployConfig) WithForce(force ...bool) DeployConfig

func (DeployConfig) WithRetries

func (c DeployConfig) WithRetries(retries ...int) DeployConfig

type DeployResult

type DeployResult struct {
	SucceededApps     []AppDeploySuccess
	FailedApps        []AppDeployFailure
	ProcessedProjects []ProjectAtFsNode
	FailedProjects    []ProjectProcessingFailure
}

func NewEmptyDeployResult

func NewEmptyDeployResult() DeployResult

func (DeployResult) HasErrors

func (r DeployResult) HasErrors() bool

func (DeployResult) Plus

func (r DeployResult) Plus(other DeployResult) DeployResult

func (DeployResult) Success

func (r DeployResult) Success() bool

type FsNode

type FsNode struct {
	Path     string
	App      *AppAtFsNode
	Project  *ProjectAtFsNode
	Children []FsNode
}

func (FsNode) Apps

func (s FsNode) Apps() []AppAtFsNode

func (FsNode) Flatten

func (s FsNode) Flatten() []FsNode

func (FsNode) HasAppNode

func (s FsNode) HasAppNode() bool

func (FsNode) HasProjectNode

func (s FsNode) HasProjectNode() bool

func (FsNode) IsAppSyntaxValid

func (s FsNode) IsAppSyntaxValid() bool

func (FsNode) IsValidApp

func (s FsNode) IsValidApp() bool

func (FsNode) Projects

func (s FsNode) Projects() []ProjectAtFsNode

func (FsNode) Traverse

func (s FsNode) Traverse(t func(node FsNode) error) error

func (FsNode) TraverseNoErr

func (s FsNode) TraverseNoErr(t func(node FsNode))

type FsNodeShallow

type FsNodeShallow struct {
	Path                  string
	HasAppYaml            bool
	HasProjectYaml        bool
	HasProjectsDir        bool
	TraversableCandidates []os.DirEntry
}

type GitRef

type GitRef struct {
	Branch string `yaml:"branch,omitempty" toml:"branch" json:"branch,omitempty"`
	Tag    string `yaml:"tag,omitempty" toml:"tag" json:"tag,omitempty"`
	Commit string `yaml:"commit,omitempty" toml:"commit" json:"commit,omitempty"`
}

func (*GitRef) IsEmpty

func (g *GitRef) IsEmpty() bool

type HttpService

type HttpService struct {
	InternalPort       int         `yaml:"internal_port" toml:"internal_port"`
	ForceHttps         bool        `yaml:"force_https" toml:"force_https"`
	AutoStopMachines   bool        `yaml:"auto_stop_machines" toml:"auto_stop_machines"`
	AutoStartMachines  bool        `yaml:"auto_start_machines" toml:"auto_start_machines"`
	MinMachinesRunning int         `yaml:"min_machines_running" toml:"min_machines_running"`
	Concurrency        Concurrency `yaml:"concurrency" toml:"concurrency,omitempty"`
	Processes          []string    `yaml:"processes" toml:"processes,omitempty"`
}

func (HttpService) IsEmpty

func (s HttpService) IsEmpty() bool

type IpConfig added in v0.0.41

type IpConfig struct {
	V       Ipv    `yaml:"v" toml:"v"`
	Network string `yaml:"network" toml:"network"`
	Org     string `yaml:"org" toml:"org"`
	Private bool   `yaml:"private" toml:"private"`
	Shared  bool   `yaml:"shared" toml:"shared"`
	Region  string `yaml:"region" toml:"region"`
}

func (IpConfig) Validate added in v0.0.41

func (c IpConfig) Validate() error

type Ipv added in v0.0.41

type Ipv string
const (
	IpV4   Ipv = "v4"
	IpV6   Ipv = "v6"
	IpVUkn Ipv = "unknown"
)

type MachineConfig

type MachineConfig struct {
	Count          int            `yaml:"count" toml:"count"` // default
	CountPerRegion map[string]int `yaml:"count_per_region" toml:"count_per_region"`
}

func (MachineConfig) CountInRegion

func (m MachineConfig) CountInRegion(region string) int

type MergeCfg

type MergeCfg struct {
	All     bool     `yaml:"all,omitempty" toml:"all" json:"all,omitempty"`
	Include []string `yaml:"include,omitempty" toml:"include,omitempty" json:"include,omitempty"`
}

type Mount

type Mount struct {
	Source      string `yaml:"source" toml:"source"`
	Destination string `yaml:"destination" toml:"destination"`
}

type NetworkConfig added in v0.0.41

type NetworkConfig struct {
	Ips          []IpConfig `yaml:"ips" toml:"ips"`
	AutoPruneIps bool       `yaml:"auto_prune_ips" toml:"auto_prune_ips"`
}

func (NetworkConfig) IsEmpty added in v0.0.41

func (c NetworkConfig) IsEmpty() bool

func (NetworkConfig) Validate added in v0.0.41

func (c NetworkConfig) Validate() error

type Port

type Port struct {
	Handlers   []string `yaml:"handlers" toml:"handlers"`
	Port       int      `yaml:"port" toml:"port"`
	ForceHttps bool     `yaml:"force_https" toml:"force_https"`
}

type PreCalculatedAppConfig

type PreCalculatedAppConfig struct {
	Typed   AppConfig
	UnTyped map[string]any
}

type ProjectAtFsNode

type ProjectAtFsNode struct {
	Path                   string
	ProjectYaml            string
	ProjectConfig          ProjectConfig
	ProjectConfigSyntaxErr error
	ProjectConfigSemErr    error
}

func (ProjectAtFsNode) ErrCause

func (s ProjectAtFsNode) ErrCause() error

func (ProjectAtFsNode) IsProjectNode

func (s ProjectAtFsNode) IsProjectNode() bool

func (ProjectAtFsNode) IsProjectSyntaxValid

func (s ProjectAtFsNode) IsProjectSyntaxValid() bool

func (ProjectAtFsNode) IsValidProject

func (s ProjectAtFsNode) IsValidProject() bool

type ProjectConfig

type ProjectConfig struct {
	Project string          `yaml:"project" toml:"project"` // Name Required. Unique name of the project
	Source  Source          `yaml:"source" toml:"source"`   // Source Required. Where the app configs of the project are located
	Common  CommonAppConfig `yaml:"common" toml:"common"`   // Common Optional. Common config for all apps in the project
}

func (*ProjectConfig) Validate

func (cfg *ProjectConfig) Validate() error

type ProjectProcessingFailure

type ProjectProcessingFailure struct {
	Spec  ProjectAtFsNode
	Cause error
}

type ScaleState

type ScaleState struct {
	Process  string         `json:"Process"`
	Count    int            `json:"Count"`
	CPUKind  string         `json:"CPUKind"`
	CPUs     int            `json:"CPUs"`
	MemoryMB int            `json:"Memory"`
	Regions  map[string]int `json:"Regions"`
}

func (ScaleState) CountInRegion

func (s ScaleState) CountInRegion(region string) int

func (ScaleState) IncludesRegion

func (s ScaleState) IncludesRegion(region string) bool

type SecretRef

type SecretRef struct {
	Name string           `yaml:"name" toml:"name"`
	Type SecretSourceType `yaml:"type" toml:"type"`
	Env  string           `yaml:"env" toml:"env"`
	Raw  string           `yaml:"raw" toml:"raw"`
}

func (SecretRef) GetSecretValue

func (s SecretRef) GetSecretValue() (string, error)

type SecretSourceType

type SecretSourceType string
const (
	SecretSourceTypeEnv SecretSourceType = "env"
	SecretSourceTypeRaw SecretSourceType = "raw" // not recommended

)

type Service

type Service struct {
	InternalPort       int         `yaml:"internal_port" toml:"internal_port"`
	Protocol           string      `yaml:"protocol" toml:"protocol"`
	ForceHttps         bool        `yaml:"force_https" toml:"force_https"`
	AutoStopMachines   bool        `yaml:"auto_stop_machines" toml:"auto_stop_machines"`
	AutoStartMachines  bool        `yaml:"auto_start_machines" toml:"auto_start_machines"`
	MinMachinesRunning int         `yaml:"min_machines_running" toml:"min_machines_running"`
	Concurrency        Concurrency `yaml:"concurrency" toml:"concurrency,omitempty"`
	Ports              []Port      `yaml:"ports" toml:"ports,omitempty"`
	Processes          []string    `yaml:"processes" toml:"processes,omitempty"`
}

func NewDefaultServiceConfig

func NewDefaultServiceConfig() Service

func (Service) WithMinScale added in v0.0.43

func (s Service) WithMinScale(minScale int) Service

type SingleAppDeploySuccessType

type SingleAppDeploySuccessType string
const (
	SingleAppDeployCreated  SingleAppDeploySuccessType = "created"
	SingleAppDeployUpdated  SingleAppDeploySuccessType = "updated"
	SingleAppDeployNoChange SingleAppDeploySuccessType = "no-change"
)

type Source

type Source struct {
	Repo   string     `yaml:"repo,omitempty" toml:"repo" json:"repo,omitempty"`
	Path   string     `yaml:"path,omitempty" toml:"path" json:"path,omitempty"`
	Ref    GitRef     `yaml:"ref,omitempty" toml:"ref" json:"ref,omitempty"`
	Type   SourceType `yaml:"type,omitempty" toml:"type" json:"type,omitempty"`
	Inline string     `yaml:"inline,omitempty" toml:"inline" json:"inline,omitempty"`
}

func NewInlineDockerFileSource

func NewInlineDockerFileSource(inline string) Source

func NewLocalFolderSource

func NewLocalFolderSource(path string) Source

func (*Source) AsGitCloneSource

func (s *Source) AsGitCloneSource() util_git.CloneSource

func (*Source) Validate

func (s *Source) Validate() error

type SourceType

type SourceType string
const (
	SourceTypeGit              SourceType = "git"
	SourceTypeLocal            SourceType = "local"
	SourceTypeInlineDockerFile SourceType = "inline-docker-file"
)

type TraverseAppTreeContext

type TraverseAppTreeContext struct {
	context.Context
	ValidAppCb       func(TraverseAppTreeContext, AppAtFsNode) error
	InvalidAppCb     func(TraverseAppTreeContext, AppAtFsNode) error
	SkippedAppCb     func(TraverseAppTreeContext, AppAtFsNode) error
	BeginProjectCb   func(TraverseAppTreeContext, ProjectAtFsNode) error
	EndProjectCb     func(TraverseAppTreeContext, ProjectAtFsNode) error
	SkippedProjectCb func(TraverseAppTreeContext, ProjectAtFsNode) error
	Seen             struct {
		Apps     map[string]bool
		Projects map[string]bool
	}
	Parents      []ProjectConfig
	CommonAppCfg CommonAppConfig
}

type ValidateAppConfigOptions

type ValidateAppConfigOptions struct {
	ValidateSource bool
}

func NewValidateAppConfigOptions

func NewValidateAppConfigOptions() ValidateAppConfigOptions

func (ValidateAppConfigOptions) WithValidateSource

func (opts ValidateAppConfigOptions) WithValidateSource(validateSource ...bool) ValidateAppConfigOptions

type VolumeConfig

type VolumeConfig struct {
	Name   string `json:"name" yaml:"name"`
	SizeGb int    `json:"size_gb" yaml:"size_gb"`
	Count  int    `json:"count" yaml:"count"`
}

type VolumeState

type VolumeState struct {
	ID        string    `json:"id"`
	Name      string    `json:"Name"`
	SizeGb    int       `json:"SizeGb"`
	State     string    `json:"State"`
	Region    string    `json:"Region"`
	Encrypted bool      `json:"Encrypted"`
	CreatedAt time.Time `json:"CreatedAt"`
}

Jump to

Keyboard shortcuts

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