Documentation
¶
Index ¶
- Variables
- func CheckContext(ctx context.Context) error
- func FormatDockerID(id string) string
- func GetDockerEnvVar(env []string, key string) string
- func HasManageableContainersInNetwork(ctx context.Context, dockerClient *client.Client, ...) (bool, error)
- func Retry(ctx context.Context, config RetryConfig, fn RetryableFunc) error
- func RetryContainerInspect(ctx context.Context, dockerClient *client.Client, containerID string) (types.ContainerJSON, error)
- func RetryContainerList(ctx context.Context, dockerClient *client.Client, ...) ([]types.Container, error)
- func RetryNetworkConnect(ctx context.Context, dockerClient *client.Client, ...) error
- func RetryNetworkInspect(ctx context.Context, dockerClient *client.Client, networkID string, ...) (network.Inspect, error)
- func ShouldManageContainer(env []string, labels map[string]string) bool
- func SliceToSet(slice []string) map[string]struct{}
- func ValidateLogLevel(level string) error
- type RetryConfig
- type RetryableFunc
Constants ¶
This section is empty.
Variables ¶
var ValidLogLevels = map[string]bool{ "debug": true, "info": true, "warn": true, "error": true, }
ValidLogLevels contains the set of valid log levels
Functions ¶
func CheckContext ¶
CheckContext returns an error if the context is cancelled This is useful for long-running operations that should respect cancellation
func FormatDockerID ¶
FormatDockerID returns a shortened version of a Docker ID for logging This can be used for container IDs, network IDs, or any Docker resource ID
func GetDockerEnvVar ¶
GetDockerEnvVar extracts an environment variable value from a Docker container's env slice This is commonly used when inspecting containers to get specific environment variables
func HasManageableContainersInNetwork ¶
func HasManageableContainersInNetwork(ctx context.Context, dockerClient *client.Client, networkID, excludeContainerName string) (bool, error)
HasManageableContainersInNetwork checks if a network has any manageable containers, optionally excluding a specific container
func Retry ¶
func Retry(ctx context.Context, config RetryConfig, fn RetryableFunc) error
Retry executes a function with retry logic and exponential backoff It respects context cancellation and returns the last error encountered
func RetryContainerInspect ¶
func RetryContainerInspect(ctx context.Context, dockerClient *client.Client, containerID string) (types.ContainerJSON, error)
RetryContainerInspect wraps ContainerInspect with retry logic
func RetryContainerList ¶
func RetryContainerList(ctx context.Context, dockerClient *client.Client, options container.ListOptions) ([]types.Container, error)
RetryContainerList wraps ContainerList with retry logic
func RetryNetworkConnect ¶
func RetryNetworkConnect(ctx context.Context, dockerClient *client.Client, networkID, containerName string, config *network.EndpointSettings) error
RetryNetworkConnect wraps NetworkConnect with retry logic
func RetryNetworkInspect ¶
func RetryNetworkInspect(ctx context.Context, dockerClient *client.Client, networkID string, options network.InspectOptions) (network.Inspect, error)
RetryNetworkInspect wraps NetworkInspect with retry logic
func ShouldManageContainer ¶
ShouldManageContainer checks if a container should be managed based on dinghy env vars or traefik labels Returns true if the container has VIRTUAL_HOST environment variable or traefik labels
func SliceToSet ¶
SliceToSet converts a slice of strings to a map[string]struct{} for O(1) lookups This is useful for creating sets from slices where you only need to check existence
func ValidateLogLevel ¶
ValidateLogLevel checks if the provided log level is valid
Types ¶
type RetryConfig ¶
type RetryConfig struct {
// MaxAttempts is the maximum number of attempts (including the first one)
MaxAttempts int
// InitialDelay is the delay before the first retry
InitialDelay time.Duration
// MaxDelay is the maximum delay between retries
MaxDelay time.Duration
// BackoffMultiplier is the factor by which the delay increases after each retry
BackoffMultiplier float64
}
RetryConfig configures retry behavior for operations
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns a sensible default retry configuration for Docker operations
type RetryableFunc ¶
RetryableFunc is a function that can be retried. It should return an error if the operation should be retried, or nil if successful. The context can be used to cancel the operation.