Documentation
¶
Overview ¶
Package lifecycle manages execution of lifecycle hooks for Watchtower containers. It runs pre-check, post-check, pre-update, and post-update commands during updates.
Key components:
- Execute Functions: Handle lifecycle hook execution (e.g., ExecutePreUpdateCommand).
- Client Integration: Uses container.Client for command execution.
Usage example:
// log is the process *zerolog.Logger. ctx is the request/operation context.
lifecycle.ExecutePreChecks(log, ctx, client, params, listed)
success, err := lifecycle.ExecutePreUpdateCommand(log, ctx, client, container, uid, gid)
if err != nil {
log.Error().Err(err).Msg("Pre-update failed")
}
The package integrates with container.Client, supports error handling, and uses zerolog for logging.
Index ¶
- func ExecutePostCheckCommand(log *zerolog.Logger, ctx context.Context, client container.Client, ...)
- func ExecutePostChecks(log *zerolog.Logger, ctx context.Context, client container.Client, ...)
- func ExecutePostUpdateCommand(log *zerolog.Logger, ctx context.Context, client container.Client, ...)
- func ExecutePreCheckCommand(log *zerolog.Logger, ctx context.Context, client container.Client, ...)
- func ExecutePreChecks(log *zerolog.Logger, ctx context.Context, client container.Client, ...)
- func ExecutePreUpdateCommand(log *zerolog.Logger, ctx context.Context, client container.Client, ...) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecutePostCheckCommand ¶
func ExecutePostCheckCommand(log *zerolog.Logger, ctx context.Context, client container.Client, container types.Container, uid, gid int)
ExecutePostCheckCommand executes the post-check hook for a container.
Parameters:
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- container: Container to process.
- uid: Default UID to run command as.
- gid: Default GID to run command as.
func ExecutePostChecks ¶
func ExecutePostChecks(log *zerolog.Logger, ctx context.Context, client container.Client, params types.UpdateParams, listed []types.Container)
ExecutePostChecks runs post-check lifecycle hooks for filtered containers.
When listed is non-nil, those containers are used and ListContainers is skipped. A non-nil empty slice is a valid filtered snapshot. Nil falls back to listing.
Parameters:
- log: Logger for debug output.
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- params: Update parameters with filter.
- listed: Already-listed containers from the current scan, or nil.
func ExecutePostUpdateCommand ¶
func ExecutePostUpdateCommand(log *zerolog.Logger, ctx context.Context, client container.Client, newContainerID types.ContainerID, uid int, gid int, )
ExecutePostUpdateCommand executes the post-update hook for a container.
Parameters:
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- newContainerID: ID of the updated container.
- uid: UID to run command as.
- gid: GID to run command as.
func ExecutePreCheckCommand ¶
func ExecutePreCheckCommand(log *zerolog.Logger, ctx context.Context, client container.Client, container types.Container, uid, gid int)
ExecutePreCheckCommand executes the pre-check hook for a container.
Parameters:
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- container: Container to process.
- uid: Default UID to run command as.
- gid: Default GID to run command as.
func ExecutePreChecks ¶
func ExecutePreChecks(log *zerolog.Logger, ctx context.Context, client container.Client, params types.UpdateParams, listed []types.Container)
ExecutePreChecks runs pre-check lifecycle hooks for filtered containers.
When listed is non-nil, those containers are used and ListContainers is skipped. A non-nil empty slice is a valid filtered snapshot. Nil falls back to listing.
Parameters:
- log: Logger for debug output.
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- params: Update parameters with filter.
- listed: Already-listed containers from the current scan, or nil.
func ExecutePreUpdateCommand ¶
func ExecutePreUpdateCommand(log *zerolog.Logger, ctx context.Context, client container.Client, container types.Container, uid int, gid int, ) (bool, error)
ExecutePreUpdateCommand executes the pre-update hook for a container.
Parameters:
- ctx: Context for cancellation and timeout.
- client: Container client for execution.
- container: Container to process.
- uid: UID to run command as.
- gid: GID to run command as.
Returns:
- bool: True if command ran, false if skipped.
- error: Non-nil if execution fails, nil otherwise.
Types ¶
This section is empty.