Documentation ¶
Index ¶
- Variables
- type Docker
- func (d *Docker) CachedContainer(containerID string) (c facts.Container, found bool)
- func (d *Docker) ContainerExists(id string) bool
- func (d *Docker) ContainerLastKill(containerID string) time.Time
- func (d *Docker) Containers(ctx context.Context, maxAge time.Duration, includeIgnored bool) (containers []facts.Container, err error)
- func (d *Docker) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error
- func (d *Docker) Events() <-chan facts.ContainerEvent
- func (d *Docker) Exec(ctx context.Context, containerID string, cmd []string) ([]byte, error)
- func (d *Docker) IsContainerNameRecentlyDeleted(name string) bool
- func (d *Docker) IsRuntimeRunning(ctx context.Context) bool
- func (d *Docker) LastUpdate() time.Time
- func (d *Docker) Metrics(_ context.Context, now time.Time) ([]types.MetricPoint, error)
- func (d *Docker) MetricsMinute(_ context.Context, now time.Time) ([]types.MetricPoint, error)
- func (d *Docker) ProcessWithCache() facts.ContainerRuntimeProcessQuerier
- func (d *Docker) Run(ctx context.Context) error
- func (d *Docker) RuntimeFact(ctx context.Context, currentFact map[string]string) map[string]string
- func (d *Docker) ServerAddress() string
- type MockDockerClient
- func (cl *MockDockerClient) Close() error
- func (cl *MockDockerClient) ContainerExecAttach(context.Context, string, containerTypes.ExecAttachOptions) (dockerTypes.HijackedResponse, error)
- func (cl *MockDockerClient) ContainerExecCreate(context.Context, string, containerTypes.ExecOptions) (dockerTypes.IDResponse, error)
- func (cl *MockDockerClient) ContainerInspect(_ context.Context, container string) (dockerTypes.ContainerJSON, error)
- func (cl *MockDockerClient) ContainerList(_ context.Context, options containerTypes.ListOptions) ([]dockerTypes.Container, error)
- func (cl *MockDockerClient) ContainerTop(_ context.Context, container string, arguments []string) (containerTypes.ContainerTopOKBody, error)
- func (cl *MockDockerClient) Events(context.Context, events.ListOptions) (<-chan events.Message, <-chan error)
- func (cl *MockDockerClient) NetworkInspect(context.Context, string, network.InspectOptions) (network.Inspect, error)
- func (cl *MockDockerClient) NetworkList(context.Context, network.ListOptions) ([]network.Inspect, error)
- func (cl *MockDockerClient) Ping(context.Context) (dockerTypes.Ping, error)
- func (cl *MockDockerClient) ServerVersion(context.Context) (dockerTypes.Version, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrDockerUnexcepted = errors.New("unexcepted data")
)
errors of Docker runtime.
Functions ¶
This section is empty.
Types ¶
type Docker ¶
type Docker struct { DockerSockets []string DeletedContainersCallback func(containersID []string) IsContainerIgnored func(facts.Container) bool // contains filtered or unexported fields }
Docker implement a method to query Docker runtime. It try to connect to the first valid DockerSockets. Empty string is a special value: it means use default.
func FakeDocker ¶
func FakeDocker(client *MockDockerClient, isContainerIgnored func(facts.Container) bool) *Docker
FakeDocker return a Docker runtime connector that use a mock client.
func New ¶
func New( runtime config.ContainerRuntimeAddresses, hostRoot string, deletedContainersCallback func(containersID []string), isContainerIgnored func(facts.Container) bool, ) *Docker
New returns a new Docker runtime.
func (*Docker) CachedContainer ¶
CachedContainer return a container without querying Docker, it use in-memory cache which must have been filled by a call to Continers().
func (*Docker) ContainerExists ¶
func (*Docker) ContainerLastKill ¶
ContainerLastKill return the last time a container was killed or zero-time if unknown.
func (*Docker) Containers ¶
func (d *Docker) Containers(ctx context.Context, maxAge time.Duration, includeIgnored bool) (containers []facts.Container, err error)
Containers return Docker containers.
func (*Docker) DiagnosticArchive ¶
func (*Docker) Events ¶
func (d *Docker) Events() <-chan facts.ContainerEvent
Events return the channel used to send events. There is only one shared channel (so multiple consumer should be implemented by caller).
func (*Docker) IsContainerNameRecentlyDeleted ¶
func (*Docker) IsRuntimeRunning ¶
IsRuntimeRunning returns whether or not Docker is available
IsRuntimeRunning will try to open a new connection if it never tried. It will also check that connection is still working (do a ping). Note: if Docker is running but Glouton can't access it, IsRuntimeRunning will return false.
func (*Docker) LastUpdate ¶
LastUpdate return the last time containers list was updated.
func (*Docker) MetricsMinute ¶
func (*Docker) ProcessWithCache ¶
func (d *Docker) ProcessWithCache() facts.ContainerRuntimeProcessQuerier
ProcessWithCache facts.containerRuntime.
func (*Docker) Run ¶
Run will run connect and listen to Docker event until context is cancelled
Any error (unable to connect due to permission issue or Docker down) are not returned by Run but could be retrieved with LastError.
func (*Docker) RuntimeFact ¶
RuntimeFact will return facts from the Docker runtime, like docker_version.
func (*Docker) ServerAddress ¶
ServerAddress will return the last server address for which connection succeeded. Note that empty string could be "docker default" or no valid connection. You should use this after call to IsRuntimeRunning().
type MockDockerClient ¶
type MockDockerClient struct { EventChanMaker func() <-chan events.Message Containers []dockerTypes.ContainerJSON Version dockerTypes.Version Top map[string]containerTypes.ContainerTopOKBody TopWaux map[string]containerTypes.ContainerTopOKBody ReturnError error TopCallCount int }
MockDockerClient is a fake Docker client that could be used during test.
func NewDockerMock ¶
func NewDockerMock(dirname string) (*MockDockerClient, error)
NewDockerMock create new MockDockerClient from a directory which may contains docker-version & docker-containers.json.
func NewDockerMockFromFile ¶
func NewDockerMockFromFile(filename string) (*MockDockerClient, error)
NewDockerMockFromFile create a MockDockerClient from JSON file which contains containers.
func (*MockDockerClient) ContainerExecAttach ¶
func (cl *MockDockerClient) ContainerExecAttach(context.Context, string, containerTypes.ExecAttachOptions) (dockerTypes.HijackedResponse, error)
ContainerExecAttach is not implemented.
func (*MockDockerClient) ContainerExecCreate ¶
func (cl *MockDockerClient) ContainerExecCreate(context.Context, string, containerTypes.ExecOptions) (dockerTypes.IDResponse, error)
ContainerExecCreate is not implemented.
func (*MockDockerClient) ContainerInspect ¶
func (cl *MockDockerClient) ContainerInspect(_ context.Context, container string) (dockerTypes.ContainerJSON, error)
ContainerInspect return inspect for in-memory list of containers.
func (*MockDockerClient) ContainerList ¶
func (cl *MockDockerClient) ContainerList(_ context.Context, options containerTypes.ListOptions) ([]dockerTypes.Container, error)
ContainerList list containers from in-memory list.
func (*MockDockerClient) ContainerTop ¶
func (cl *MockDockerClient) ContainerTop(_ context.Context, container string, arguments []string) (containerTypes.ContainerTopOKBody, error)
ContainerTop return hard-coded value for top.
func (*MockDockerClient) Events ¶
func (cl *MockDockerClient) Events(context.Context, events.ListOptions) (<-chan events.Message, <-chan error)
Events do events.
func (*MockDockerClient) NetworkInspect ¶
func (cl *MockDockerClient) NetworkInspect(context.Context, string, network.InspectOptions) (network.Inspect, error)
NetworkInspect is not implemented.
func (*MockDockerClient) NetworkList ¶
func (cl *MockDockerClient) NetworkList(context.Context, network.ListOptions) ([]network.Inspect, error)
NetworkList is not implemented.
func (*MockDockerClient) Ping ¶
func (cl *MockDockerClient) Ping(context.Context) (dockerTypes.Ping, error)
Ping do nothing.
func (*MockDockerClient) ServerVersion ¶
func (cl *MockDockerClient) ServerVersion(context.Context) (dockerTypes.Version, error)
ServerVersion do server version.