watchtower: github.com/containrrr/watchtower/pkg/container Index | Files | Directories

package container

import "github.com/containrrr/watchtower/pkg/container"

Index

Package Files

client.go container.go filters.go metadata.go sort.go trust.go

func BuildFilter Uses

func BuildFilter(names []string, enableLabel bool) t.Filter

BuildFilter creates the needed filter of containers

func ContainsWatchtowerLabel Uses

func ContainsWatchtowerLabel(labels map[string]string) bool

ContainsWatchtowerLabel takes a map of labels and values and tells the consumer whether it contains a valid watchtower instance label

func CredentialsStore Uses

func CredentialsStore(configFile configfile.ConfigFile) credentials.Store

CredentialsStore returns a new credentials store based on the settings provided in the configuration file.

func DefaultAuthHandler Uses

func DefaultAuthHandler() (string, error)

DefaultAuthHandler will be invoked if an AuthConfig is rejected It could be used to return a new value for the "X-Registry-Auth" authentication header, but there's no point trying again with the same value as used in AuthConfig

func EncodeAuth Uses

func EncodeAuth(auth types.AuthConfig) (string, error)

EncodeAuth Base64 encode an AuthConfig struct for transmission over HTTP

func EncodedAuth Uses

func EncodedAuth(ref string) (string, error)

EncodedAuth returns an encoded auth config for the given registry loaded from environment variables or docker config as available in that order

func EncodedConfigAuth Uses

func EncodedConfigAuth(ref string) (string, error)

EncodedConfigAuth returns an encoded auth config for the given registry loaded from the docker config Returns an empty string if credentials cannot be found for the referenced server The docker config must be mounted on the container

func EncodedEnvAuth Uses

func EncodedEnvAuth(ref string) (string, error)

EncodedEnvAuth returns an encoded auth config for the given registry loaded from environment variables Returns an error if authentication environment variables have not been set

func ParseServerAddress Uses

func ParseServerAddress(ref string) (string, error)

ParseServerAddress extracts the server part from a container image ref

func WatchtowerContainersFilter Uses

func WatchtowerContainersFilter(c t.FilterableContainer) bool

WatchtowerContainersFilter filters only watchtower containers

type ByCreated Uses

type ByCreated []Container

ByCreated allows a list of Container structs to be sorted by the container's created date.

func (ByCreated) Len Uses

func (c ByCreated) Len() int

func (ByCreated) Less Uses

func (c ByCreated) Less(i, j int) bool

Less will compare two elements (identified by index) in the Container list by created-date.

func (ByCreated) Swap Uses

func (c ByCreated) Swap(i, j int)

type Client Uses

type Client interface {
    ListContainers(t.Filter) ([]Container, error)
    GetContainer(containerID string) (Container, error)
    StopContainer(Container, time.Duration) error
    StartContainer(Container) (string, error)
    RenameContainer(Container, string) error
    IsContainerStale(Container) (bool, error)
    ExecuteCommand(containerID string, command string) error
    RemoveImage(Container) error
}

A Client is the interface through which watchtower interacts with the Docker API.

func NewClient Uses

func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client

NewClient returns a new Client instance which can be used to interact with the Docker API. The client reads its configuration from the following environment variables:

* DOCKER_HOST			the docker-engine host to send api requests to
* DOCKER_TLS_VERIFY		whether to verify tls certificates
* DOCKER_API_VERSION	the minimum docker api version to work with

type Container Uses

type Container struct {
    Linked bool
    Stale  bool
    // contains filtered or unexported fields
}

Container represents a running Docker container.

func NewContainer Uses

func NewContainer(containerInfo *types.ContainerJSON, imageInfo *types.ImageInspect) *Container

NewContainer returns a new Container instance instantiated with the specified ContainerInfo and ImageInfo structs.

func SortByDependencies Uses

func SortByDependencies(containers []Container) ([]Container, error)

SortByDependencies will sort the list of containers taking into account any links between containers. Container with no outgoing links will be sorted to the front of the list while containers with links will be sorted after all of their dependencies. This sort order ensures that linked containers can be started in the correct order.

func (Container) Enabled Uses

func (c Container) Enabled() (bool, bool)

Enabled returns the value of the container enabled label and if the label was set.

func (Container) GetLifecyclePostCheckCommand Uses

func (c Container) GetLifecyclePostCheckCommand() string

GetLifecyclePostCheckCommand returns the post-check command set in the container metadata or an empty string

func (Container) GetLifecyclePostUpdateCommand Uses

func (c Container) GetLifecyclePostUpdateCommand() string

GetLifecyclePostUpdateCommand returns the post-update command set in the container metadata or an empty string

func (Container) GetLifecyclePreCheckCommand Uses

func (c Container) GetLifecyclePreCheckCommand() string

GetLifecyclePreCheckCommand returns the pre-check command set in the container metadata or an empty string

func (Container) GetLifecyclePreUpdateCommand Uses

func (c Container) GetLifecyclePreUpdateCommand() string

GetLifecyclePreUpdateCommand returns the pre-update command set in the container metadata or an empty string

func (Container) ID Uses

func (c Container) ID() string

ID returns the Docker container ID.

func (Container) ImageID Uses

func (c Container) ImageID() string

ImageID returns the ID of the Docker image that was used to start the container.

func (Container) ImageName Uses

func (c Container) ImageName() string

ImageName returns the name of the Docker image that was used to start the container. If the original image was specified without a particular tag, the "latest" tag is assumed.

func (Container) IsRunning Uses

func (c Container) IsRunning() bool

IsRunning returns a boolean flag indicating whether or not the current container is running. The status is determined by the value of the container's "State.Running" property.

func (Container) IsWatchtower Uses

func (c Container) IsWatchtower() bool

IsWatchtower returns a boolean flag indicating whether or not the current container is the watchtower container itself. The watchtower container is identified by the presence of the "com.centurylinklabs.watchtower" label in the container metadata.

func (c Container) Links() []string

Links returns a list containing the names of all the containers to which this container is linked.

func (Container) Name Uses

func (c Container) Name() string

Name returns the Docker container name.

func (Container) StopSignal Uses

func (c Container) StopSignal() string

StopSignal returns the custom stop signal (if any) that is encoded in the container's metadata. If the container has not specified a custom stop signal, the empty string "" is returned.

func (Container) ToRestart Uses

func (c Container) ToRestart() bool

ToRestart return whether the container should be restarted, either because is stale or linked to another stale container.

Directories

PathSynopsis
mocks

Package container imports 22 packages (graph) and is imported by 4 packages. Updated 2019-09-17. Refresh now. Tools for package owners.