models

package
v0.4.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogSourceStdout        = "stdout"
	LogSourceFile          = "file"
	LogSourceContainerFile = "container_file"
)
View Source
const (
	InfraTypeNginx    = "nginx"
	InfraTypeCertbot  = "certbot"
	InfraTypeDatabase = "database"
	InfraTypeRedis    = "redis"
	InfraTypePowerDNS = "powerdns"

	InfraStatusRunning  = "running"
	InfraStatusStopped  = "stopped"
	InfraStatusExternal = "external"
	InfraStatusUnknown  = "unknown"
)
View Source
const CredentialMask = "********"

CredentialMask is returned in place of a secret value so callers can tell a secret is set without receiving it. A value equal to the mask on update is treated as "unchanged".

Variables

This section is empty.

Functions

func IsSecretKey

func IsSecretKey(kind CredentialKind, key string) bool

IsSecretKey reports whether a Data key holds a secret for the given kind.

Types

type AuthType added in v0.1.5

type AuthType string
const (
	AuthTypeBasic AuthType = "basic"
	AuthTypeToken AuthType = "token"
)

type BackupHookSpec added in v0.1.5

type BackupHookSpec struct {
	Service string `yaml:"service" json:"service"`
	Command string `yaml:"command" json:"command"`
	Timeout int    `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}

type BackupSpec added in v0.1.5

type BackupSpec struct {
	ContainerPaths  []ContainerBackupPath `yaml:"container_paths,omitempty" json:"container_paths,omitempty"`
	Databases       []DatabaseBackupSpec  `yaml:"databases,omitempty" json:"databases,omitempty"`
	PreHooks        []BackupHookSpec      `yaml:"pre_hooks,omitempty" json:"pre_hooks,omitempty"`
	PostHooks       []BackupHookSpec      `yaml:"post_hooks,omitempty" json:"post_hooks,omitempty"`
	ExcludePatterns []string              `yaml:"exclude_patterns,omitempty" json:"exclude_patterns,omitempty"`
}

type Certificate

type Certificate struct {
	Domain       string    `json:"domain"`
	Issuer       string    `json:"issuer"`
	NotBefore    time.Time `json:"not_before"`
	NotAfter     time.Time `json:"not_after"`
	DaysLeft     int       `json:"days_left"`
	Status       string    `json:"status"`
	Path         string    `json:"path" cli:"-"`
	AutoRenew    bool      `json:"auto_renew"`
	DeploymentID string    `json:"deployment_id,omitempty"`
}

type ContainerBackupPath added in v0.1.5

type ContainerBackupPath struct {
	Service       string `yaml:"service" json:"service"`
	ContainerPath string `yaml:"container_path" json:"container_path"`
	Description   string `yaml:"description,omitempty" json:"description,omitempty"`
	Required      bool   `yaml:"required" json:"required"`
}

type Credential

type Credential struct {
	ID        string            `json:"id" yaml:"id"`
	Name      string            `json:"name" yaml:"name"`
	Kind      CredentialKind    `json:"kind" yaml:"kind"`
	Data      map[string]string `json:"data" yaml:"data"`
	CreatedAt time.Time         `json:"created_at" yaml:"created_at"`
	UpdatedAt time.Time         `json:"updated_at" yaml:"updated_at"`
}

Credential is a generic, kind-tagged secret held by the credential manager, separate from the registry-specific RegistryCredential. Secret-bearing keys in Data are masked when marshaled to JSON but written verbatim to the 0600 on-disk store.

func (Credential) MarshalJSON

func (c Credential) MarshalJSON() ([]byte, error)

type CredentialKind

type CredentialKind string
const (
	CredentialKindS3  CredentialKind = "s3"
	CredentialKindGit CredentialKind = "git"
)

type DatabaseBackupSpec added in v0.1.5

type DatabaseBackupSpec struct {
	Service string `yaml:"service" json:"service"`
	Type    string `yaml:"type" json:"type"`
	// Container, when set, is the exact container to exec the dump in, overriding
	// the name derived from the deployment and service.
	Container string `yaml:"container,omitempty" json:"container,omitempty"`
	// AllDatabases dumps the whole server (pg_dumpall / mysqldump --all-databases)
	// with root credentials, used to back up a database-server deployment such as
	// the shared infrastructure database.
	AllDatabases bool   `yaml:"all_databases,omitempty" json:"all_databases,omitempty"`
	HostEnv      string `yaml:"host_env,omitempty" json:"host_env,omitempty"`
	PortEnv      string `yaml:"port_env,omitempty" json:"port_env,omitempty"`
	UserEnv      string `yaml:"user_env,omitempty" json:"user_env,omitempty"`
	PasswordEnv  string `yaml:"password_env,omitempty" json:"password_env,omitempty"`
	DatabaseEnv  string `yaml:"database_env,omitempty" json:"database_env,omitempty"`
	Host         string `yaml:"host,omitempty" json:"host,omitempty"`
	Port         int    `yaml:"port,omitempty" json:"port,omitempty"`
	User         string `yaml:"user,omitempty" json:"user,omitempty"`
	Password     string `yaml:"password,omitempty" json:"password,omitempty"`
	Database     string `yaml:"database,omitempty" json:"database,omitempty"`
}

type DatabaseConfig added in v0.1.5

type DatabaseConfig struct {
	ID           string `yaml:"id" json:"id"`
	Alias        string `yaml:"alias" json:"alias"`
	Type         string `yaml:"type" json:"type"`
	Mode         string `yaml:"mode" json:"mode"`
	Service      string `yaml:"service,omitempty" json:"service,omitempty"`
	Host         string `yaml:"host,omitempty" json:"host,omitempty"`
	Port         int    `yaml:"port,omitempty" json:"port,omitempty"`
	Container    string `yaml:"container,omitempty" json:"container,omitempty"`
	DatabaseName string `yaml:"database_name,omitempty" json:"database_name,omitempty"`
	Username     string `yaml:"username,omitempty" json:"username,omitempty"`
	EnvPrefix    string `yaml:"env_prefix,omitempty" json:"env_prefix,omitempty"`
	IsShared     bool   `yaml:"is_shared,omitempty" json:"is_shared,omitempty"`
}

type Deployment

type Deployment struct {
	Name      string           `json:"name"`
	Path      string           `json:"path" cli:"-"`
	Status    string           `json:"status"`
	CreatedAt time.Time        `json:"created_at"`
	UpdatedAt time.Time        `json:"updated_at"`
	Services  []Service        `json:"services,omitempty"`
	Metadata  *ServiceMetadata `json:"metadata,omitempty"`
}

type DeploymentRateLimit added in v0.1.5

type DeploymentRateLimit struct {
	Path    string `yaml:"path" json:"path"`
	Rate    int    `yaml:"rate" json:"rate"`
	Burst   int    `yaml:"burst" json:"burst"`
	Enabled bool   `yaml:"enabled" json:"enabled"`
}

type DeploymentSecurityConfig added in v0.1.5

type DeploymentSecurityConfig struct {
	Enabled        bool                  `yaml:"enabled" json:"enabled"`
	BlockedIPs     []string              `yaml:"blocked_ips,omitempty" json:"blocked_ips,omitempty"`
	ProtectedPaths []ProtectedPath       `yaml:"protected_paths,omitempty" json:"protected_paths,omitempty"`
	RateLimits     []DeploymentRateLimit `yaml:"rate_limits,omitempty" json:"rate_limits,omitempty"`
}

type DeploymentStatus

type DeploymentStatus string
const (
	StatusRunning DeploymentStatus = "running"
	StatusPaused  DeploymentStatus = "paused"
	StatusStopped DeploymentStatus = "stopped"
	StatusError   DeploymentStatus = "error"
	StatusUnknown DeploymentStatus = "unknown"
)

type DomainConfig added in v0.1.5

type DomainConfig struct {
	ID            string    `yaml:"id" json:"id"`
	Service       string    `yaml:"service" json:"service"`
	ContainerPort int       `yaml:"container_port" json:"container_port"`
	Domain        string    `yaml:"domain" json:"domain"`
	PathPrefix    string    `yaml:"path_prefix,omitempty" json:"path_prefix,omitempty"`
	StripPrefix   bool      `yaml:"strip_prefix,omitempty" json:"strip_prefix,omitempty"`
	SSL           SSLConfig `yaml:"ssl" json:"ssl"`
	Aliases       []string  `yaml:"aliases,omitempty" json:"aliases,omitempty"`
	// RouteOnlyAliases are extra hostnames routed to this deployment but excluded
	// from certificate issuance and renewal, for a hostname whose TLS is
	// terminated by an external proxy (e.g. Cloudflare) whose DNS does not point
	// at FlatRun. They share the primary domain's certificate over the proxy's
	// SNI; issuing a certificate for them would fail ACME validation.
	RouteOnlyAliases []string `yaml:"route_only_aliases,omitempty" json:"route_only_aliases,omitempty"`
	// ProxyTimeout is the proxy read/send timeout in seconds. Defaults to 60
	// when unset; raise it for domains that proxy long-lived WebSocket
	// connections so idle sockets are not closed mid-connection.
	ProxyTimeout int `yaml:"proxy_timeout,omitempty" json:"proxy_timeout,omitempty"`
	// StaticCache opts this domain into a long browser cache for static assets
	// (css, js, images, fonts). It applies only to responses whose path has a
	// static extension; dynamic responses keep the app's own cache headers.
	StaticCache bool `yaml:"static_cache,omitempty" json:"static_cache,omitempty"`
}

type HealthCheckConfig

type HealthCheckConfig struct {
	Type             string `yaml:"type,omitempty" json:"type,omitempty"`
	Service          string `yaml:"service,omitempty" json:"service,omitempty"`
	Port             int    `yaml:"port,omitempty" json:"port,omitempty"`
	Path             string `yaml:"path" json:"path"`
	Interval         string `yaml:"interval" json:"interval"`
	SuccessStatuses  []int  `yaml:"success_statuses,omitempty" json:"success_statuses,omitempty"`
	ResponseContains string `yaml:"response_contains,omitempty" json:"response_contains,omitempty"`
	Command          string `yaml:"command,omitempty" json:"command,omitempty"`
}

type InfraService added in v0.1.5

type InfraService struct {
	Name        string         `json:"name"`
	Type        string         `json:"type"`
	Status      string         `json:"status"`
	Managed     bool           `json:"managed"`
	External    bool           `json:"external"`
	ContainerID string         `json:"container_id,omitempty"`
	Image       string         `json:"image,omitempty"`
	Health      string         `json:"health,omitempty"`
	CreatedAt   time.Time      `json:"created_at,omitempty"`
	Config      map[string]any `json:"config,omitempty"`
}

type LogSource

type LogSource struct {
	ID      string `yaml:"id" json:"id"`
	Name    string `yaml:"name" json:"name"`
	Type    string `yaml:"type" json:"type"`
	Service string `yaml:"service,omitempty" json:"service,omitempty"`
	Path    string `yaml:"path,omitempty" json:"path,omitempty"`
	Format  string `yaml:"format,omitempty" json:"format,omitempty"`
	Builtin bool   `yaml:"-" json:"builtin,omitempty"`
}

LogSource is one place a deployment's logs can be read from: container output, a deployment file on the host, or a file inside one service container.

func BuiltinLogSourcesForKind

func BuiltinLogSourcesForKind(kind string) []LogSource

type Network

type Network struct {
	ID         string             `json:"id"`
	Name       string             `json:"name"`
	Driver     string             `json:"driver"`
	Scope      string             `json:"scope"`
	Subnet     string             `json:"subnet"`
	Gateway    string             `json:"gateway"`
	Containers []NetworkContainer `json:"containers"`
	Labels     map[string]string  `json:"labels"`
	Created    string             `json:"created"`
}

type NetworkContainer

type NetworkContainer struct {
	Name       string `json:"name"`
	IPv4       string `json:"ipv4"`
	MacAddress string `json:"mac_address"`
}

type NetworkingConfig

type NetworkingConfig struct {
	Expose        bool   `yaml:"expose" json:"expose"`
	Domain        string `yaml:"domain" json:"domain"`
	Service       string `yaml:"service,omitempty" json:"service,omitempty"`
	ContainerPort int    `yaml:"container_port" json:"container_port"`
	Protocol      string `yaml:"protocol" json:"protocol"`
	ProxyType     string `yaml:"proxy_type" json:"proxy_type"`
}

type ProtectedCommandRule added in v0.2.0

type ProtectedCommandRule struct {
	ID            string `yaml:"id,omitempty" json:"id,omitempty"`
	Name          string `yaml:"name,omitempty" json:"name,omitempty"`
	Match         string `yaml:"match" json:"match"`
	Pattern       string `yaml:"pattern" json:"pattern"`
	CaseSensitive bool   `yaml:"case_sensitive,omitempty" json:"case_sensitive,omitempty"`
	Description   string `yaml:"description,omitempty" json:"description,omitempty"`
}

type ProtectedModeConfig added in v0.2.0

type ProtectedModeConfig struct {
	Enabled             bool                   `yaml:"enabled" json:"enabled"`
	BlockedActions      []string               `yaml:"blocked_actions,omitempty" json:"blocked_actions,omitempty"`
	BlockedCommandRules []ProtectedCommandRule `yaml:"blocked_command_rules,omitempty" json:"blocked_command_rules,omitempty"`
	DisableTerminal     bool                   `yaml:"disable_terminal,omitempty" json:"disable_terminal,omitempty"`
}

type ProtectedPath added in v0.1.5

type ProtectedPath struct {
	Pattern string `yaml:"pattern" json:"pattern"`
	Enabled bool   `yaml:"enabled" json:"enabled"`
}

type QuickAction added in v0.1.5

type QuickAction struct {
	ID          string `yaml:"id" json:"id"`
	Name        string `yaml:"name" json:"name"`
	Command     string `yaml:"command" json:"command"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
	Icon        string `yaml:"icon,omitempty" json:"icon,omitempty"`
	Service     string `yaml:"service,omitempty" json:"service,omitempty"`
}

type RegistryCredential added in v0.1.5

type RegistryCredential struct {
	ID               string    `json:"id" yaml:"id"`
	Name             string    `json:"name" yaml:"name"`
	RegistryTypeSlug string    `json:"registry_type_slug" yaml:"registry_type_slug"`
	RegistryURL      string    `json:"registry_url,omitempty" yaml:"registry_url,omitempty"`
	Username         string    `json:"username" yaml:"username"`
	Password         string    `json:"-" yaml:"password"`
	Email            string    `json:"email,omitempty" yaml:"email,omitempty"`
	IsDefault        bool      `json:"is_default" yaml:"is_default"`
	CreatedAt        time.Time `json:"created_at" yaml:"created_at"`
	UpdatedAt        time.Time `json:"updated_at" yaml:"updated_at"`
}

type RegistryCredentialWithType added in v0.1.5

type RegistryCredentialWithType struct {
	RegistryCredential
	RegistryType *RegistryType `json:"registry_type,omitempty"`
}

type RegistryType added in v0.1.5

type RegistryType struct {
	Slug        string             `json:"slug" yaml:"slug"`
	Name        string             `json:"name" yaml:"name"`
	URLPatterns []string           `json:"url_patterns" yaml:"url_patterns"`
	AuthType    AuthType           `json:"auth_type" yaml:"auth_type"`
	LoginURL    string             `json:"login_url,omitempty" yaml:"login_url,omitempty"`
	DocsURL     string             `json:"docs_url,omitempty" yaml:"docs_url,omitempty"`
	Icon        string             `json:"icon,omitempty" yaml:"icon,omitempty"`
	Source      RegistryTypeSource `json:"source" yaml:"source"`
	IsOfficial  bool               `json:"is_official" yaml:"is_official"`
	CreatedAt   time.Time          `json:"created_at" yaml:"created_at"`
	UpdatedAt   time.Time          `json:"updated_at" yaml:"updated_at"`
}

func DefaultRegistryTypes added in v0.1.5

func DefaultRegistryTypes() []RegistryType

type RegistryTypeSource added in v0.1.5

type RegistryTypeSource string
const (
	RegistrySourceBuiltin     RegistryTypeSource = "builtin"
	RegistrySourceLocal       RegistryTypeSource = "local"
	RegistrySourceMarketplace RegistryTypeSource = "marketplace"
)

type SSLConfig

type SSLConfig struct {
	Enabled  bool `yaml:"enabled" json:"enabled"`
	AutoCert bool `yaml:"auto_cert" json:"auto_cert"`
}

type ScalingConfig

type ScalingConfig struct {
	Service   string               `yaml:"service" json:"service"`
	Stateless bool                 `yaml:"stateless" json:"stateless"`
	Storage   ScalingStorageConfig `yaml:"storage,omitempty" json:"storage,omitempty"`
}

type ScalingStorageConfig

type ScalingStorageConfig struct {
	Mode  string `yaml:"mode,omitempty" json:"mode,omitempty"`
	Class string `yaml:"class,omitempty" json:"class,omitempty"`
}

type Service

type Service struct {
	Name        string    `json:"name"`
	ContainerID string    `json:"container_id"`
	Image       string    `json:"image"`
	Status      string    `json:"status"`
	Health      string    `json:"health,omitempty"`
	Ports       []string  `json:"ports,omitempty"`
	Networks    []string  `json:"networks,omitempty"`
	IsPrimary   bool      `json:"is_primary"`
	CreatedAt   time.Time `json:"created_at"`
}

type ServiceMetadata

type ServiceMetadata struct {
	Name       string      `yaml:"name" json:"name"`
	Type       string      `yaml:"type" json:"type"`
	Kind       string      `yaml:"kind,omitempty" json:"kind,omitempty"`
	LogSources []LogSource `yaml:"log_sources,omitempty" json:"log_sources,omitempty"`
	// PrimaryService is the user-pinned primary service. When set it overrides
	// auto-detection for the default-domain upstream and is preserved across
	// compose updates and re-discovery.
	PrimaryService     string                    `yaml:"primary_service,omitempty" json:"primary_service,omitempty"`
	Networking         NetworkingConfig          `yaml:"networking" json:"networking"`
	SSL                SSLConfig                 `yaml:"ssl" json:"ssl"`
	HealthCheck        HealthCheckConfig         `yaml:"healthcheck" json:"healthcheck"`
	QuickActions       []QuickAction             `yaml:"quick_actions,omitempty" json:"quick_actions,omitempty"`
	Security           *DeploymentSecurityConfig `yaml:"security,omitempty" json:"security,omitempty"`
	Backup             *BackupSpec               `yaml:"backup,omitempty" json:"backup,omitempty"`
	Scaling            *ScalingConfig            `yaml:"scaling,omitempty" json:"scaling,omitempty"`
	ProtectedMode      *ProtectedModeConfig      `yaml:"protected_mode,omitempty" json:"protected_mode,omitempty"`
	RequirePlan        bool                      `yaml:"require_plan,omitempty" json:"require_plan,omitempty"`
	CredentialID       string                    `yaml:"credential_id,omitempty" json:"credential_id,omitempty"`
	ServiceCredentials map[string]string         `yaml:"service_credentials,omitempty" json:"service_credentials,omitempty"`
	Domains            []DomainConfig            `yaml:"domains,omitempty" json:"domains,omitempty"`
	Databases          []DatabaseConfig          `yaml:"databases,omitempty" json:"databases,omitempty"`
}

func (*ServiceMetadata) EffectiveLogSources

func (m *ServiceMetadata) EffectiveLogSources() []LogSource

EffectiveLogSources is every source a viewer can pick: the stdout stream, the kind's built-in file profiles, and any the user added (which override built-ins by id).

func (*ServiceMetadata) EffectivePrimaryService

func (m *ServiceMetadata) EffectivePrimaryService() string

EffectivePrimaryService returns the service treated as the deployment's primary: the user-pinned PrimaryService when set, otherwise the auto-detected routing service.

func (*ServiceMetadata) FindLogSource

func (m *ServiceMetadata) FindLogSource(id string) (LogSource, bool)

func (*ServiceMetadata) GetDatabases added in v0.1.5

func (m *ServiceMetadata) GetDatabases() []DatabaseConfig

func (*ServiceMetadata) GetDomains added in v0.1.5

func (m *ServiceMetadata) GetDomains() []DomainConfig

func (*ServiceMetadata) GetPrimaryDatabase added in v0.1.5

func (m *ServiceMetadata) GetPrimaryDatabase() *DatabaseConfig

func (*ServiceMetadata) GetUniqueDomainNames added in v0.1.5

func (m *ServiceMetadata) GetUniqueDomainNames() []string

func (*ServiceMetadata) HasMultipleDatabases added in v0.1.5

func (m *ServiceMetadata) HasMultipleDatabases() bool

func (*ServiceMetadata) HasMultipleDomains added in v0.1.5

func (m *ServiceMetadata) HasMultipleDomains() bool

Jump to

Keyboard shortcuts

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