Documentation
¶
Index ¶
- Constants
- Variables
- func CheckDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) (bool, error)
- func CheckMountPointWriteable(mountPoint container.MountPoint) error
- func ConnectToSocket() (net.Conn, error)
- func CreateDockerCli(quiet, verifyTLS bool) (command.Cli, error)
- func DeployStack(jobLog *slog.Logger, internalRepoPath, externalRepoPath string, ...) error
- func DeploySwarmStack(ctx context.Context, dockerCli command.Cli, project *types.Project, ...) error
- func DestroyStack(jobLog *slog.Logger, ctx *context.Context, dockerCli *command.Cli, ...) error
- func Exec(client client.APIClient, containerID string, cmd ...string) (out string, err error)
- func GetContainerID(client client.APIClient, name string) (id string, err error)
- func GetLabeledConfigs(ctx context.Context, cli *client.Client, key, value string) (configs []swarm.Config, err error)
- func GetLabeledContainers(ctx context.Context, cli *client.Client, key, value string) (containers []container.Summary, err error)
- func GetLabeledSecrets(ctx context.Context, cli *client.Client, key, value string) (secrets []swarm.Secret, err error)
- func GetLabeledVolumes(ctx context.Context, cli *client.Client, key, value string) (volumes []*volume.Volume, err error)
- func GetModuleVersion(module string) (string, error)
- func GetMountPointByDestination(cli *client.Client, containerID, destination string) (container.MountPoint, error)
- func HasChangedBindMounts(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
- func HasChangedConfigs(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
- func HasChangedSecrets(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
- func LoadCompose(ctx context.Context, workingDir, projectName string, composeFiles []string) (*types.Project, error)
- func MountedFilesHaveChanges(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
- func NewHttpClient() *http.Client
- func PruneStackConfigs(ctx context.Context, client *client.Client, namespace string) error
- func PruneStackSecrets(ctx context.Context, client *client.Client, namespace string) error
- func RemoveLabeledVolumes(ctx context.Context, dockerClient *client.Client, ...) error
- func RemoveSwarmStack(ctx context.Context, dockerCli command.Cli, deployConfig *config.DeployConfig) error
- func SetConfigHashPrefixes(stack *composetypes.Config, namespace string) error
- func SetSecretHashPrefixes(stack *composetypes.Config, namespace string) error
- func VerifySocketConnection() error
- func VerifySocketRead(httpClient *http.Client) error
Constants ¶
const (
StackNamespaceLabel = "com.docker.stack.namespace"
)
Variables ¶
var ( ErrDockerSocketConnectionFailed = errors.New("failed to connect to docker socket") ErrNoContainerToStart = errors.New("no container to start") ErrIsInUse = errors.New("is in use") ComposeVersion string // Version of the docker compose module, will be set at runtime )
var ( ErrMountPointNotFound = errors.New("mount point not found") ErrMountPointNotWriteable = errors.New("mount point is not writeable") ErrContainerIDNotFound = errors.New("container ID not found") ErrModuleNotFound = errors.New("module not found in build info") )
var DocoCDLabels = docoCdLabelNames{
Metadata: docoCDLabelNamesMetadata{
Manager: "cd.doco.metadata.manager",
Version: "cd.doco.metadata.version",
},
Deployment: docoCdLabelNamesDeployment{
Name: "cd.doco.deployment.name",
Timestamp: "cd.doco.deployment.timestamp",
WorkingDir: "cd.doco.deployment.working_dir",
TargetRef: "cd.doco.deployment.target.ref",
CommitSHA: "cd.doco.deployment.target.sha",
Trigger: "cd.doco.deployment.trigger",
},
Repository: docoCdLabelNamesRepository{
Name: "cd.doco.repository.name",
URL: "cd.doco.repository.url",
},
}
DocoCDLabels contains the label key names used by DocoCD to identify deployed containers and their metadata.
var SwarmModeEnabled bool // Whether the docker host is running in swarm mode
Functions ¶
func CheckDaemonIsSwarmManager ¶ added in v0.31.0
func CheckMountPointWriteable ¶ added in v0.13.0
func CheckMountPointWriteable(mountPoint container.MountPoint) error
CheckMountPointWriteable checks if a mount point is writable by attempting to create a file in it.
func ConnectToSocket ¶
ConnectToSocket connects to the docker socket.
func DeployStack ¶ added in v0.14.0
func DeployStack( jobLog *slog.Logger, internalRepoPath, externalRepoPath string, ctx *context.Context, dockerCli *command.Cli, dockerClient *client.Client, payload *webhook.ParsedPayload, deployConfig *config.DeployConfig, changedFiles []gitInternal.ChangedFile, latestCommit, appVersion string, forceDeploy bool, ) error
DeployStack deploys the stack using the provided deployment configuration.
func DeploySwarmStack ¶ added in v0.31.0
func DeploySwarmStack(ctx context.Context, dockerCli command.Cli, project *types.Project, deployConfig *config.DeployConfig, payload webhook.ParsedPayload, repoDir, latestCommit, appVersion string, ) error
DeploySwarmStack deploys a Docker Swarm stack using the provided project and deploy configuration.
func DestroyStack ¶ added in v0.14.0
func DestroyStack( jobLog *slog.Logger, ctx *context.Context, dockerCli *command.Cli, deployConfig *config.DeployConfig, ) error
DestroyStack destroys the stack using the provided deployment configuration.
func GetContainerID ¶ added in v0.13.0
GetContainerID retrieves the container ID for a given service name.
func GetLabeledConfigs ¶ added in v0.31.0
func GetLabeledConfigs(ctx context.Context, cli *client.Client, key, value string) (configs []swarm.Config, err error)
GetLabeledConfigs retrieves all configs with a specific label key and value.
func GetLabeledContainers ¶ added in v0.13.0
func GetLabeledContainers(ctx context.Context, cli *client.Client, key, value string) (containers []container.Summary, err error)
GetLabeledContainers retrieves all containers with a specific label key and value.
func GetLabeledSecrets ¶ added in v0.31.0
func GetLabeledSecrets(ctx context.Context, cli *client.Client, key, value string) (secrets []swarm.Secret, err error)
GetLabeledSecrets retrieves all secrets with a specific label key and value.
func GetLabeledVolumes ¶ added in v0.31.0
func GetLabeledVolumes(ctx context.Context, cli *client.Client, key, value string) (volumes []*volume.Volume, err error)
GetLabeledVolumes retrieves all volumes with a specific label key and value.
func GetModuleVersion ¶ added in v0.30.0
GetModuleVersion retrieves the version of a specified module from the build info.
func GetMountPointByDestination ¶ added in v0.13.0
func GetMountPointByDestination(cli *client.Client, containerID, destination string) (container.MountPoint, error)
GetMountPointByDestination retrieves the mount point of a container volume/bind mount by its destination (mount point inside the container).
func HasChangedBindMounts ¶ added in v0.29.0
func HasChangedBindMounts(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
HasChangedBindMounts checks if any files used in docker compose `volumes:` definitions with type `bind` have changed using the Git status.
func HasChangedConfigs ¶ added in v0.29.0
func HasChangedConfigs(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
HasChangedConfigs checks if any files used in docker compose `configs:` definitions have changed using the Git status.
func HasChangedSecrets ¶ added in v0.29.0
func HasChangedSecrets(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
HasChangedSecrets checks if any files used in docker compose `secrets:` definitions have changed using the Git status.
func LoadCompose ¶
func LoadCompose(ctx context.Context, workingDir, projectName string, composeFiles []string) (*types.Project, error)
LoadCompose parses and loads Compose files as specified by the Docker Compose specification.
func MountedFilesHaveChanges ¶ added in v0.29.0
func MountedFilesHaveChanges(changedFiles []gitInternal.ChangedFile, project *types.Project) (bool, error)
MountedFilesHaveChanges checks if any files from config, secret or bind mounts have changed in the project.
func NewHttpClient ¶
func PruneStackConfigs ¶ added in v0.31.0
func PruneStackSecrets ¶ added in v0.31.0
func RemoveLabeledVolumes ¶ added in v0.31.0
func RemoveSwarmStack ¶ added in v0.31.0
func RemoveSwarmStack(ctx context.Context, dockerCli command.Cli, deployConfig *config.DeployConfig) error
RemoveSwarmStack removes a Docker Swarm stack using the provided deploy configuration.
func SetConfigHashPrefixes ¶ added in v0.31.0
func SetConfigHashPrefixes(stack *composetypes.Config, namespace string) error
SetConfigHashPrefixes generates hashes for the config definitions in the stack config and adds them to the config names as suffixes to trigger a redeployment when they change (Only works in Docker Swarm mode).
func SetSecretHashPrefixes ¶ added in v0.31.0
func SetSecretHashPrefixes(stack *composetypes.Config, namespace string) error
SetSecretHashPrefixes generates hashes for the secret definitions in the stack config and adds them to the secret names as suffixes to trigger a redeployment when they change (Only works in Docker Swarm mode).
func VerifySocketConnection ¶
func VerifySocketConnection() error
VerifySocketConnection verifies whether the application can connect to the docker socket.
func VerifySocketRead ¶
VerifySocketRead verifies whether the application can read from the docker socket.
Types ¶
This section is empty.