containerd

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package containerd extracts container inventory from containerd API.

Index

Constants

View Source
const (
	// Name is the unique name of this extractor.
	Name = "containers/containerd-runtime"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ContainerdSocketAddr is the local path to the containerd socket.
	// Used further to crete a client for containerd API.
	ContainerdSocketAddr string
}

Config is the configuration for the Extractor.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the containerd extractor.

type CtrdClient

type CtrdClient interface {
	LoadContainer(ctx context.Context, id string) (containerd.Container, error)
	NamespaceService() namespaces.Store
	TaskService() tasks.TasksClient
	Close() error
}

CtrdClient is an interface that provides an abstraction on top of the containerd client. Needed for testing purposes.

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor implements the containerd runtime extractor.

func New

func New(cfg Config) *Extractor

New creates a new containerd client and returns a containerd container inventory extractor.

func NewWithClient

func NewWithClient(cli CtrdClient, socketAddr string) *Extractor

NewWithClient creates a new extractor with the provided containerd client. Needed for testing purposes.

func (Extractor) Config

func (e Extractor) Config() Config

Config returns the configuration of the extractor.

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context, input *standalone.ScanInput) ([]*extractor.Inventory, error)

Extractor extracts containers from the containerd API.

func (Extractor) Name

func (e Extractor) Name() string

Name of the extractor.

func (Extractor) ToCPEs

func (e Extractor) ToCPEs(i *extractor.Inventory) ([]string, error)

ToCPEs is not applicable as this extractor does not infer CPEs from the Inventory.

func (Extractor) ToPURL

func (e Extractor) ToPURL(i *extractor.Inventory) (*purl.PackageURL, error)

ToPURL converts an inventory created by this extractor into a PURL.

func (Extractor) Version

func (e Extractor) Version() int

Version of the extractor.

type Metadata

type Metadata struct {
	Namespace   string
	ImageName   string
	ImageDigest string
	Runtime     string
	ID          string
	PID         int
	RootFS      string
}

Metadata holds parsing information for a container running on the containerd runtime.

Directories

Path Synopsis
Package fakeclient contains a fake implementation of the containerd client for testing purposes.
Package fakeclient contains a fake implementation of the containerd client for testing purposes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL