Documentation ¶
Index ¶
- Variables
- func DumpToJSON(ctx context.Context, address string) ([]byte, error)
- type ContainerOCISpec
- type Containerd
- func (c *Containerd) CachedContainer(containerID string) (cont facts.Container, found bool)
- func (c *Containerd) ContainerExists(id string) bool
- func (c *Containerd) ContainerLastKill(containerID string) time.Time
- func (c *Containerd) Containers(ctx context.Context, maxAge time.Duration, includeIgnored bool) (containers []facts.Container, err error)
- func (c *Containerd) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error
- func (c *Containerd) Events() <-chan facts.ContainerEvent
- func (c *Containerd) Exec(ctx context.Context, containerID string, cmd []string) ([]byte, error)
- func (c *Containerd) IsContainerNameRecentlyDeleted(name string) bool
- func (c *Containerd) IsRuntimeRunning(ctx context.Context) bool
- func (c *Containerd) LastUpdate() time.Time
- func (c *Containerd) Metrics(ctx context.Context, now time.Time) ([]types.MetricPoint, error)
- func (c *Containerd) MetricsMinute(_ context.Context, now time.Time) ([]types.MetricPoint, error)
- func (c *Containerd) ProcessWithCache() facts.ContainerRuntimeProcessQuerier
- func (c *Containerd) Run(ctx context.Context) error
- func (c *Containerd) RuntimeFact(ctx context.Context, currentFact map[string]string) map[string]string
- type MockClient
- func (m *MockClient) Close() error
- func (m *MockClient) Containers(ctx context.Context) ([]containerd.Container, error)
- func (m *MockClient) Events(context.Context) (<-chan *events.Envelope, <-chan error)
- func (m *MockClient) LoadContainer(ctx context.Context, id string) (containerd.Container, error)
- func (m *MockClient) Metrics(_ context.Context, filters []string) (*tasks.MetricsResponse, error)
- func (m *MockClient) Namespaces(context.Context) ([]string, error)
- func (m *MockClient) Version(context.Context) (containerd.Version, error)
- type MockContainer
- func (c MockContainer) Checkpoint(context.Context, string, ...containerd.CheckpointOpts) (containerd.Image, error)
- func (c MockContainer) Delete(context.Context, ...containerd.DeleteOpts) error
- func (c MockContainer) Extensions(context.Context) (map[string]typeurl.Any, error)
- func (c MockContainer) ID() string
- func (c MockContainer) Image(ctx context.Context) (containerd.Image, error)
- func (c MockContainer) Info(ctx context.Context, _ ...containerd.InfoOpts) (containers.Container, error)
- func (c MockContainer) Labels(ctx context.Context) (map[string]string, error)
- func (c MockContainer) NewTask(context.Context, cio.Creator, ...containerd.NewTaskOpts) (containerd.Task, error)
- func (c MockContainer) SetLabels(context.Context, map[string]string) (map[string]string, error)
- func (c MockContainer) Spec(ctx context.Context) (*oci.Spec, error)
- func (c MockContainer) Task(ctx context.Context, _ cio.Attach) (containerd.Task, error)
- func (c MockContainer) Update(context.Context, ...containerd.UpdateContainerOpts) error
- type MockImage
- func (i MockImage) Config(_ context.Context) (ocispec.Descriptor, error)
- func (i MockImage) ContentStore() content.Store
- func (i MockImage) IsUnpacked(context.Context, string) (bool, error)
- func (i MockImage) Labels() map[string]string
- func (i MockImage) Metadata() images.Image
- func (i MockImage) Name() string
- func (i MockImage) Platform() platforms.MatchComparer
- func (i MockImage) RootFS(_ context.Context) ([]digest.Digest, error)
- func (i MockImage) Size(_ context.Context) (int64, error)
- func (i MockImage) Spec(_ context.Context) (ocispec.Image, error)
- func (i MockImage) Target() ocispec.Descriptor
- func (i MockImage) Unpack(context.Context, string, ...containerd.UnpackOpt) error
- func (i MockImage) Usage(context.Context, ...containerd.UsageOpt) (int64, error)
- type MockJSON
- type MockNamespace
- type MockTask
- func (t MockTask) Checkpoint(context.Context, ...containerd.CheckpointTaskOpts) (containerd.Image, error)
- func (t MockTask) CloseIO(context.Context, ...containerd.IOCloserOpts) error
- func (t MockTask) Delete(context.Context, ...containerd.ProcessDeleteOpts) (*containerd.ExitStatus, error)
- func (t MockTask) Exec(context.Context, string, *specs.Process, cio.Creator) (containerd.Process, error)
- func (t MockTask) ID() string
- func (t MockTask) IO() cio.IO
- func (t MockTask) Kill(context.Context, syscall.Signal, ...containerd.KillOpts) error
- func (t MockTask) LoadProcess(context.Context, string, cio.Attach) (containerd.Process, error)
- func (t MockTask) Metrics(context.Context) (*containerdTypes.Metric, error)
- func (t MockTask) Pause(context.Context) error
- func (t MockTask) Pid() uint32
- func (t MockTask) Pids(ctx context.Context) ([]containerd.ProcessInfo, error)
- func (t MockTask) Resize(_ context.Context, _, _ uint32) error
- func (t MockTask) Resume(context.Context) error
- func (t MockTask) Spec(context.Context) (*oci.Spec, error)
- func (t MockTask) Start(context.Context) error
- func (t MockTask) Status(ctx context.Context) (containerd.Status, error)
- func (t MockTask) Update(context.Context, ...containerd.UpdateTaskOpts) error
- func (t MockTask) Wait(context.Context) (<-chan containerd.ExitStatus, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMockNotImplemented is returned when a mock does not implement a method. ErrMockNotImplemented = errors.New("mock does not implement this method") // ErrWrongNamespace is returned when the namespace is mismatched. ErrWrongNamespace = errors.New("missmatch namespace") )
Functions ¶
Types ¶
type ContainerOCISpec ¶
type ContainerOCISpec struct { containers.Container Spec *oci.Spec `json:"Spec,omitempty"` }
ContainerOCISpec contains Info() & unmarshaled oci Spec.
type Containerd ¶
type Containerd struct { Addresses []string DeletedContainersCallback func(containersID []string) IsContainerIgnored func(facts.Container) bool // contains filtered or unexported fields }
Containerd implement connector to containerd.
func FakeContainerd ¶
func FakeContainerd(client *MockClient, isContainerIgnored func(facts.Container) bool) *Containerd
FakeContainerd return a Containerd 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, ) *Containerd
New returns a new Docker runtime.
func (*Containerd) CachedContainer ¶
func (c *Containerd) CachedContainer(containerID string) (cont facts.Container, found bool)
CachedContainer return a container without querying ContainerD, it use in-memory cache which must have been filled by a call to Continers().
func (*Containerd) ContainerExists ¶
func (c *Containerd) ContainerExists(id string) bool
func (*Containerd) ContainerLastKill ¶
func (c *Containerd) ContainerLastKill(containerID string) time.Time
ContainerLastKill return the last time a container was killed or zero-time if unknown. containerd does not provide this information.
func (*Containerd) Containers ¶
func (c *Containerd) Containers(ctx context.Context, maxAge time.Duration, includeIgnored bool) (containers []facts.Container, err error)
Containers return ContainerD containers.
func (*Containerd) DiagnosticArchive ¶
func (c *Containerd) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error
func (*Containerd) Events ¶
func (c *Containerd) 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 (*Containerd) IsContainerNameRecentlyDeleted ¶
func (c *Containerd) IsContainerNameRecentlyDeleted(name string) bool
func (*Containerd) IsRuntimeRunning ¶
func (c *Containerd) IsRuntimeRunning(ctx context.Context) bool
IsRuntimeRunning returns whether or not Containerd 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 ContainerD is running but Glouton can't access it, IsRuntimeRunning will return false.
func (*Containerd) LastUpdate ¶
func (c *Containerd) LastUpdate() time.Time
LastUpdate return the last time containers list was updated.
func (*Containerd) Metrics ¶
func (c *Containerd) Metrics(ctx context.Context, now time.Time) ([]types.MetricPoint, error)
Metrics return metrics in a format similar to the one returned by Telegraf docker input. Note that Metrics will never open the connection to ContainerD and will return empty points if not connected.
func (*Containerd) MetricsMinute ¶
func (c *Containerd) MetricsMinute(_ context.Context, now time.Time) ([]types.MetricPoint, error)
func (*Containerd) ProcessWithCache ¶
func (c *Containerd) ProcessWithCache() facts.ContainerRuntimeProcessQuerier
ProcessWithCache facts.containerRuntime.
func (*Containerd) Run ¶
func (c *Containerd) Run(ctx context.Context) error
Run will run connect and listen to ContainerD event until context is cancelled
Any error (unable to connect due to permission issue or ContainerD down) are not returned by Run but could be retrieved with LastError.
func (*Containerd) RuntimeFact ¶
func (c *Containerd) RuntimeFact(ctx context.Context, currentFact map[string]string) map[string]string
RuntimeFact will return facts from the ContainerD runtime, like containerd_version.
type MockClient ¶
type MockClient struct { Data MockJSON EventChanMaker func() <-chan *events.Envelope // contains filtered or unexported fields }
MockClient is a fake containerd client.
func NewMockFromFile ¶
func NewMockFromFile(filename string) (*MockClient, error)
NewMockFromFile create a MockClient from JSON file. Use DumpToJSON to build such JSON.
func (*MockClient) Containers ¶
func (m *MockClient) Containers(ctx context.Context) ([]containerd.Container, error)
Containers do Containers.
func (*MockClient) LoadContainer ¶
func (m *MockClient) LoadContainer(ctx context.Context, id string) (containerd.Container, error)
LoadContainer do LoadContainer.
func (*MockClient) Metrics ¶
func (m *MockClient) Metrics(_ context.Context, filters []string) (*tasks.MetricsResponse, error)
Metrics do metrics.
func (*MockClient) Namespaces ¶
func (m *MockClient) Namespaces(context.Context) ([]string, error)
Namespaces do namespaces.
func (*MockClient) Version ¶
func (m *MockClient) Version(context.Context) (containerd.Version, error)
Version do version.
type MockContainer ¶
type MockContainer struct { MockInfo ContainerOCISpec MockImageOCI ocispec.Descriptor MockTask MockTask // contains filtered or unexported fields }
MockContainer contains information about a container.
func (MockContainer) Checkpoint ¶
func (c MockContainer) Checkpoint(context.Context, string, ...containerd.CheckpointOpts) (containerd.Image, error)
Checkpoint implement containerd.Container.
func (MockContainer) Delete ¶
func (c MockContainer) Delete(context.Context, ...containerd.DeleteOpts) error
Delete implement containerd.Container.
func (MockContainer) Extensions ¶
func (c MockContainer) Extensions(context.Context) (map[string]typeurl.Any, error)
Extensions implement containerd.Container.
func (MockContainer) Image ¶
func (c MockContainer) Image(ctx context.Context) (containerd.Image, error)
Image implement containerd.Container.
func (MockContainer) Info ¶
func (c MockContainer) Info(ctx context.Context, _ ...containerd.InfoOpts) (containers.Container, error)
Info implement containerd.Container.
func (MockContainer) NewTask ¶
func (c MockContainer) NewTask(context.Context, cio.Creator, ...containerd.NewTaskOpts) (containerd.Task, error)
NewTask implement containerd.Container.
func (MockContainer) Task ¶
func (c MockContainer) Task(ctx context.Context, _ cio.Attach) (containerd.Task, error)
Task implement containerd.Container.
func (MockContainer) Update ¶
func (c MockContainer) Update(context.Context, ...containerd.UpdateContainerOpts) error
Update implement containerd.Container.
type MockImage ¶
type MockImage struct { MockName string MockTarget ocispec.Descriptor }
MockImage is an implementation of containerd.Image.
func (MockImage) ContentStore ¶
ContentStore implement containerd.Image.
func (MockImage) IsUnpacked ¶
IsUnpacked implement containerd.Image.
func (MockImage) Platform ¶
func (i MockImage) Platform() platforms.MatchComparer
Platform implement containerd.Image.
func (MockImage) Target ¶
func (i MockImage) Target() ocispec.Descriptor
Target implement containerd.Image.
type MockJSON ¶
type MockJSON struct { Namespaces []MockNamespace Version containerd.Version }
MockJSON store all information that MockClient can provide.
type MockNamespace ¶
type MockNamespace struct { MockNamespace string MockContainers []MockContainer }
MockNamespace contains namespaced information.
type MockTask ¶
type MockTask struct { MockID string MockPID uint32 MockStatus containerd.Status MockPids []containerd.ProcessInfo // contains filtered or unexported fields }
MockTask is an implementation of containerd.Task.
func (MockTask) Checkpoint ¶
func (t MockTask) Checkpoint(context.Context, ...containerd.CheckpointTaskOpts) (containerd.Image, error)
Checkpoint implements containerd.Task.
func (MockTask) CloseIO ¶
func (t MockTask) CloseIO(context.Context, ...containerd.IOCloserOpts) error
CloseIO implements containerd.Task.
func (MockTask) Delete ¶
func (t MockTask) Delete(context.Context, ...containerd.ProcessDeleteOpts) (*containerd.ExitStatus, error)
Delete implements containerd.Task.
func (MockTask) Exec ¶
func (t MockTask) Exec(context.Context, string, *specs.Process, cio.Creator) (containerd.Process, error)
Exec implements containerd.Task.
func (MockTask) LoadProcess ¶
LoadProcess implements containerd.Task.
func (MockTask) Pids ¶
func (t MockTask) Pids(ctx context.Context) ([]containerd.ProcessInfo, error)
Pids implements containerd.Task.
func (MockTask) Update ¶
func (t MockTask) Update(context.Context, ...containerd.UpdateTaskOpts) error
Update implements containerd.Task.
func (MockTask) Wait ¶
func (t MockTask) Wait(context.Context) (<-chan containerd.ExitStatus, error)
Wait implements containerd.Task.