Documentation
¶
Index ¶
- func AllInstanceNames(cfg *InfraConfig) []string
- func AllNames(instances []Instance) []string
- func BuildImage(name, source string) (string, error)
- func BuildSourceImages(services []string, specs map[string]ServiceSpec) (map[string]string, error)
- func CountInstances(cfg *InfraConfig) int
- func DeployToInstance(p *platform.Platform, imagePaths map[string]string, cfg *InfraConfig, ...) error
- func ExpandEnv(s string) string
- func ExtractPackages(targetDir, newModule string, packages []string) error
- func InitProviders(cfg *InfraConfig) (map[string]*platform.Platform, error)
- func ProviderFor(providers map[string]*platform.Platform, cfg *InfraConfig, serverType string) *platform.Platform
- func RenderApp(targetDir string, data Data) error
- func RenderProject(targetDir string, data Data) error
- func SafeName(s string) bool
- func SafePath(s string) bool
- func SafeRelPath(s string) bool
- func SyncSecrets(server *platform.Server, services map[string]ServiceSpec)
- type Data
- type InfraConfig
- type Instance
- type MultipleInstancesError
- type PlatformConfig
- type PortSpec
- type ServerSpec
- type ServiceSpec
- type VolumeMount
- type VolumeSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllInstanceNames ¶ added in v0.2.0
func AllInstanceNames(cfg *InfraConfig) []string
AllInstanceNames returns the names of all deployed instances.
func BuildImage ¶ added in v0.2.0
BuildImage builds a Docker image locally and saves it as a gzipped tarball. Returns the path to the tarball, or empty string if local Docker is unavailable.
func BuildSourceImages ¶ added in v0.2.0
BuildSourceImages builds Docker images for all source-based services.
func CountInstances ¶ added in v0.2.0
func CountInstances(cfg *InfraConfig) int
func DeployToInstance ¶ added in v0.2.0
func DeployToInstance( p *platform.Platform, imagePaths map[string]string, cfg *InfraConfig, serverType string, inst *Instance, region platform.Region, ) error
DeployToInstance deploys services to a specific instance.
func ExtractPackages ¶
ExtractPackages copies framework packages from the embedded pkg/ source into targetDir/internal/<package>/, rewriting imports to the new module path.
func InitProviders ¶ added in v0.2.0
func InitProviders(cfg *InfraConfig) (map[string]*platform.Platform, error)
InitProviders creates a platform client for each named platform in the config.
func ProviderFor ¶ added in v0.2.0
func ProviderFor(providers map[string]*platform.Platform, cfg *InfraConfig, serverType string) *platform.Platform
ProviderFor returns the platform for a specific server type.
func RenderApp ¶
RenderApp renders only the app subdirectory (controllers/, models/, views/, main.go) for adding a new app to an existing project.
func RenderProject ¶
RenderProject walks res/scaffold/ and writes files into targetDir.
Routing rules:
- res/scaffold/web/ → targetDir/<Dir>/
- res/scaffold/<path> → targetDir/<path>
Files ending in .tmpl are executed as text/template with <<>> delimiters and written with the .tmpl suffix stripped. All other files are copied verbatim.
func SafeName ¶ added in v0.2.0
SafeName validates a name contains only safe characters (no path separators).
func SafePath ¶ added in v0.2.0
SafePath validates an absolute path for shell interpolation (no .., must start with /).
func SafeRelPath ¶ added in v0.2.0
SafeRelPath validates a relative path for setup scripts (no .., no leading /).
func SyncSecrets ¶ added in v0.2.0
func SyncSecrets(server *platform.Server, services map[string]ServiceSpec)
SyncSecrets pushes local env vars to the server for empty env_files.
Types ¶
type Data ¶
type Data struct {
Name string
Module string
Dir string // app subdirectory (default: "web")
WithFrontend bool
WithAssistant bool
WithPlatform bool
WithDatabase bool
}
Data holds template variables for scaffold rendering.
type InfraConfig ¶ added in v0.2.0
type InfraConfig struct {
Platforms map[string]PlatformConfig `json:"platforms"`
Servers map[string]ServerSpec `json:"servers"`
Services map[string]ServiceSpec `json:"services,omitempty"`
Instances map[string][]Instance `json:"instances,omitempty"`
}
InfraConfig defines the complete infrastructure for a project.
Schema (infra.json):
{
"platforms": { "<name>": { provider, token?, region? } }
"servers": { "<type>": { platform, size, setup?, volumes?, services } }
"services": { "<name>": { image|source, setup?, ports, volumes?, env?, env_files?, network?, healthcheck? } }
"instances": { "<type>": [{ id, name, ip, region? }] }
}
Volume references: Service volume sources and env values support $volume-name syntax. A server volume {"name": "data", "mount": "/mnt/data"} can be referenced as "$data/app" which expands to "/mnt/data/app" at deploy time.
func LoadInfraConfig ¶ added in v0.2.0
func LoadInfraConfig(projectDir string) (*InfraConfig, error)
LoadInfraConfig reads and validates infra.json from the given directory.
func (*InfraConfig) AllInstances ¶ added in v0.2.0
func (cfg *InfraConfig) AllInstances() []Instance
func (*InfraConfig) PlatformFor ¶ added in v0.2.0
func (cfg *InfraConfig) PlatformFor(serverType string) PlatformConfig
PlatformFor returns the PlatformConfig for a server type.
func (*InfraConfig) PlatformNameFor ¶ added in v0.2.0
func (cfg *InfraConfig) PlatformNameFor(serverType string) string
PlatformNameFor returns the platform key for a server type. Falls back to the first (or only) key if the server has no explicit platform.
func (*InfraConfig) Save ¶ added in v0.2.0
func (cfg *InfraConfig) Save(projectDir string) error
type Instance ¶ added in v0.2.0
type Instance struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
IP string `json:"ip,omitempty"`
Region string `json:"region,omitempty"`
}
func CreateInstance ¶ added in v0.2.0
func CreateInstance(p *platform.Platform, name string, spec ServerSpec, region string) (*Instance, error)
CreateInstance provisions a new server and waits for SSH.
func FindInstance ¶ added in v0.2.0
func FindInstance(cfg *InfraConfig, name string) (*Instance, string, error)
FindInstance looks up an instance by name across all server types.
func FindInstanceOrDefault ¶ added in v0.2.0
func FindInstanceOrDefault(cfg *InfraConfig, name string) (*Instance, error)
FindInstanceOrDefault returns the named instance, or the only instance if name is empty.
type MultipleInstancesError ¶ added in v0.2.0
type MultipleInstancesError struct {
Instances []Instance
}
MultipleInstancesError is returned when an instance must be specified but multiple exist.
func (*MultipleInstancesError) Error ¶ added in v0.2.0
func (e *MultipleInstancesError) Error() string
type PlatformConfig ¶ added in v0.2.0
type ServerSpec ¶ added in v0.2.0
type ServerSpec struct {
Platform string `json:"platform,omitempty"` // key into Platforms map
Size string `json:"size"`
Setup string `json:"setup,omitempty"` // relative path to setup script
Volumes []VolumeSpec `json:"volumes,omitempty"`
Services []string `json:"services,omitempty"`
}
type ServiceSpec ¶ added in v0.2.0
type ServiceSpec struct {
Image string `json:"image,omitempty"`
Source string `json:"source,omitempty"`
Setup string `json:"setup,omitempty"` // relative path to setup script (runs on host before container)
Command []string `json:"command,omitempty"`
Ports []PortSpec `json:"ports,omitempty"`
Volumes []VolumeMount `json:"volumes,omitempty"`
Env map[string]string `json:"env,omitempty"`
EnvFiles map[string]string `json:"env_files,omitempty"`
Network string `json:"network,omitempty"`
Healthcheck string `json:"healthcheck,omitempty"`
Privileged bool `json:"privileged,omitempty"`
}