Documentation
¶
Index ¶
- Constants
- func ClusterContext(project *types.Project) string
- func HasCommandSecretRefs(project *types.Project) bool
- func LoadProject(ctx context.Context, paths []string, opts ...composecli.ProjectOptionsFn) (*types.Project, error)
- func LoadProjectFromContent(ctx context.Context, content string, opts ...composecli.ProjectOptionsFn) (*types.Project, error)
- func ProcessImageTemplates(project *types.Project) (*types.Project, error)
- func ResolveSecrets(ctx context.Context, project *types.Project) error
- func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.ServiceSpec, error)
- type Caddy
- type Client
- type Deployment
- type ImageTemplateContext
- type MachinesSource
- type Plan
- type PortsSource
- type PreDeployHook
Constants ¶
const ( // DefaultTagTemplate is the default tag template appended to images without a tag when building locally. // Format: // If the project workdir is a git repo: "2025-08-16-130734.84d33bb" or "2025-08-16-130734.84d33bb.dirty" // If not a git repo: "2025-08-16-130734" which is the current date and time. DefaultTagTemplate = `` /* 137-byte string literal not displayed */ // DefaultImageTemplate is the default image template used when no image is specified. DefaultImageTemplate = "{{.Project}}/{{.Service}}:" + DefaultTagTemplate )
const ( // SecretRefPrefix prefixes a reference to a secret defined in the top-level 'secrets' section, // e.g. 'secret://my_secret'. SecretRefPrefix = "secret://" // SecretCommandExtensionKey is the short-form secret extension providing the command to run, // equivalent to 'driver: exec' with 'driver_opts.command'. SecretCommandExtensionKey = "x-command" )
const CaddyExtensionKey = "x-caddy"
const ContextExtensionKey = "x-context"
ContextExtensionKey is the top-level Compose extension key for specifying the cluster context.
const MachinesExtensionKey = "x-machines"
const PortsExtensionKey = "x-ports"
const PreDeployHookExtensionKey = "x-pre_deploy"
Variables ¶
This section is empty.
Functions ¶
func ClusterContext ¶ added in v0.18.0
ClusterContext extracts the x-context value from the project's top-level extensions. Returns an empty string if x-context is not set.
func HasCommandSecretRefs ¶ added in v0.20.0
HasCommandSecretRefs reports whether any service environment references a secret that is resolved by running a command.
func LoadProject ¶
func LoadProject(ctx context.Context, paths []string, opts ...composecli.ProjectOptionsFn) (*types.Project, error)
LoadProject loads a Compose project from the default locations or the given paths.
func LoadProjectFromContent ¶ added in v0.15.0
func LoadProjectFromContent( ctx context.Context, content string, opts ...composecli.ProjectOptionsFn, ) (*types.Project, error)
LoadProjectFromContent loads a Compose project from the given YAML content.
func ProcessImageTemplates ¶ added in v0.14.0
ProcessImageTemplates processes image names in services to expand Go template expressions using git metadata. If a service has no image specified, uses the default template {{.Project}}/{{.Service}}:{{.Tag}}. If a service has a build section and an image without a tag, appends the default tag template. Fully specified images are left unchanged.
Template context: ImageTemplateContext Template functions: gitsha(length?), gitdate(format, timezone?), date(format, timezone?)
Examples:
image: myapp:{{.Tag}} → myapp:2025-08-16-130734.84d33bb
image: registry.io/api:v1.0-{{gitsha 7}} → registry.io/api:v1.0-84d33bb
image: worker:{{gitdate "2006-01-02"}} → worker:2025-08-16
build: . / image: mybackend → mybackend:2025-08-16-130734.84d33bb
build: . / (no image) → myproject/myservice:2025-08-16-130734.84d33bb
image: postgres → postgres (unchanged)
func ResolveSecrets ¶ added in v0.20.0
ResolveSecrets resolves 'secret://name' references in the services' environment to actual secret values, setting each referenced variable to the secret's value in place. Each referenced secret is resolved at most once, even if referenced by multiple services. Secrets that are not referenced are never resolved.
func ServiceSpecFromCompose ¶
Types ¶
type Caddy ¶ added in v0.11.1
type Caddy struct {
Config string `yaml:"config" json:"config"`
}
func (*Caddy) DecodeMapstructure ¶ added in v0.11.1
DecodeMapstructure decodes x-caddy extension from either a string or an object. When x-caddy is a string, it's mapped directly to the Config field.
type Deployment ¶
type Deployment struct {
Client Client
Project *types.Project
SpecResolver *deploy.ServiceSpecResolver
Strategy deploy.Strategy
// contains filtered or unexported fields
}
func NewDeployment ¶
func NewDeploymentWithStrategy ¶ added in v0.11.0
func (*Deployment) ServiceSpec ¶
func (d *Deployment) ServiceSpec(name string) (api.ServiceSpec, error)
ServiceSpec returns the service specification for the given compose service that is ready for deployment.
type ImageTemplateContext ¶ added in v0.14.0
type ImageTemplateContext struct {
// Project is the project name.
Project string
// Service is the service name where the image is defined.
Service string
// Git is the git repo state.
Git gitutil.GitState
// Tag is the rendered DefaultTagTemplate used for images without a tag.
Tag string
}
ImageTemplateContext contains structured data for image template processing.
type MachinesSource ¶ added in v0.10.0
type MachinesSource []string
MachinesSource represents the parsed x-machines extension data as slice of strings
func (*MachinesSource) DecodeMapstructure ¶ added in v0.10.0
func (m *MachinesSource) DecodeMapstructure(value any) error
DecodeMapstructure implements custom decoding for multiple input types
type Plan ¶ added in v0.18.0
type Plan struct {
Volumes []*operation.CreateVolumeOperation
Services []*deploy.ServicePlan
}
Plan holds the compose-level deployment plan with volume and service operations.
func (*Plan) Execute ¶ added in v0.18.0
Execute runs all volume operations followed by all service operations.
type PortsSource ¶
type PortsSource []string
type PreDeployHook ¶ added in v0.18.0
type PreDeployHook struct {
Command types.ShellCommand `yaml:"command" json:"command"`
Environment types.MappingWithEquals `yaml:"environment,omitempty" json:"environment,omitempty"`
Privileged *bool `yaml:"privileged,omitempty" json:"privileged,omitempty"`
Timeout *types.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
User string `yaml:"user,omitempty" json:"user,omitempty"`
}
PreDeployHook represents the parsed x-pre_deploy extension config.
func (*PreDeployHook) Validate ¶ added in v0.18.0
func (p *PreDeployHook) Validate() error
Validate checks that the pre-deploy hook configuration is valid.