Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeployStack ¶
func DeployStack(ctx context.Context, dockerClient *dockerclient.Client, opts StackDeployOptions) error
DeployStack deploys a Compose-defined stack to Docker Swarm using the Engine API.
It validates the stack name, loads the Compose project with environment interpolation, ensures required swarm-scoped networks, configs, and secrets exist, creates or updates services to match the desired state, optionally prunes services no longer declared by the stack, and removes stale managed configs and secrets after reconciliation.
ctx controls cancellation for Compose loading and Docker API calls. dockerClient must target a swarm manager capable of creating and updating stack resources. opts provides the stack name, compose content, optional env content, registry-auth behavior, pruning, and image-resolution mode.
Returns nil when the stack has been reconciled successfully. Returns an error if the stack name is empty, the compose or env content is invalid, a referenced resource cannot be inspected or created, or any Docker API call required to reconcile the stack fails.
Types ¶
type StackDeployOptions ¶
type StackDeployOptions struct {
Name string
ComposeContent string
EnvContent string
WithRegistryAuth bool
RegistryAuthForImage func(context.Context, string) (string, error)
Prune bool
ResolveImage string
}
StackDeployOptions controls how a swarm stack is deployed.
type StackRenderOptions ¶
type StackRenderResult ¶
type StackRenderResult struct {
Name string
RenderedCompose string
Services []string
Networks []string
Volumes []string
Configs []string
Secrets []string
}
func RenderStackConfig ¶
func RenderStackConfig(ctx context.Context, opts StackRenderOptions) (*StackRenderResult, error)
RenderStackConfig renders a Compose-defined stack without deploying it.
It validates the stack name, loads and interpolates the Compose project using the provided environment content, marshals the normalized project back to YAML, and reports the discovered service, network, volume, config, and secret names that would participate in deployment.
ctx controls cancellation for Compose loading. opts provides the stack name, compose content, and optional env content to render.
Returns the rendered compose YAML and related resource names. Returns an error if the stack name is empty, the compose or env content is invalid, or the normalized Compose project cannot be marshaled.