explorers

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileSHA256Sum

func FileSHA256Sum(path string) (string, error)

FileSHA256Sum calculates SHA256 hash of the specified file.

func GetTaskPID

func GetTaskPID(path string) int

GetTaskPID returns process ID of the containers

func GetTaskStatus

func GetTaskStatus(cgrouppath string) (string, error)

GetTaskStatus returns task status

func PathExists

func PathExists(path string, isfile bool) bool

PathExists returns true if the path exists

func ReadCgroupEvents

func ReadCgroupEvents(path string) (int, int, error)

ReadCgroupEvents returns populated and frozen status

Types

type Container

type Container struct {
	Namespace        string
	Hostname         string
	ImageBase        string
	SupportContainer bool
	ContainerType    string
	ProcessID        int
	Status           string

	// containerd specific fields
	containers.Container

	// docker specific fields
	Running      bool
	ExposedPorts []string
}

Container provides information about a container.

type ContainerExplorer

type ContainerExplorer interface {
	// Close releases the internal resources
	Close() error

	// ContainerDrift identifies container filesystem changes
	ContainerDrift(ctx context.Context, filter string, skipsupportcontainers bool, containerID string) ([]Drift, error)

	// ExportAllContainers exports all Docker and containerd containers.
	ExportAllContainers(ctx context.Context, outputDir string, exportOption map[string]bool, filter map[string]string, exportSupportContainers bool) error

	// ExportContainer exports a container as an image or archive.
	ExportContainer(ctx context.Context, containerID string, outputDir string, exportOption map[string]bool) error

	// InfoContainer returns container internal information
	InfoContainer(ctx context.Context, containerid string, spec bool) (interface{}, error)

	// ListContainers returns all the containers in all the namespaces.
	//
	// ListContainers returns the ContainerExplorer's Containers structure
	// that holds additional information about the containers.
	ListContainers(ctx context.Context) ([]Container, error)

	// ListContent returns information about content
	ListContent(ctx context.Context) ([]Content, error)

	// ListImages returns content information
	ListImages(ctx context.Context) ([]Image, error)

	// ListNamespaces returns all the namespaces in the metadata file i.e.
	// meta.db
	ListNamespaces(ctx context.Context) ([]string, error)

	// ListSnapshots returns the snapshot information
	ListSnapshots(ctx context.Context) ([]SnapshotKeyInfo, error)

	// ListTasks returns the container task status
	ListTasks(ctx context.Context) ([]Task, error)

	// MountAllContainer mounts all containers to the specfied path
	MountAllContainers(ctx context.Context, mountpoint string, filter string, skipsupportcontainers bool) error

	// MountContainer mounts a container to the specified path
	MountContainer(ctx context.Context, containerid string, mountpoint string) error

	// SnapshotRoot returns the directory containing snapshots and snapshot
	// database i.e. metadata.db
	//
	// SnapshotRoot is required for the containers managed using containerd.
	SnapshotRoot(snapshotter string) string
}

ContainerExplorer defines the methods required to explore a container.

type Content

type Content struct {
	Namespace string
	content.Info
}

Content provides information about containers' content

type Drift

type Drift struct {
	ContainerID       string
	ContainerType     string
	AddedOrModified   []FileInfo
	InaccessibleFiles []FileInfo
}

Drift provides information about container drift.

type FileInfo

type FileInfo struct {
	FileName     string    `json:"file_name"`
	FullPath     string    `json:"full_path"`
	FileSize     int64     `json:"file_size"`
	FileModified time.Time `json:"file_modified"`
	FileAccessed time.Time `json:"file_accessed"`
	FileChanged  time.Time `json:"file_changed"`
	FileBirth    time.Time `json:"file_birth"`
	FileUid      string    `json:"file_uid,omitempty"`
	FileOwner    string    `json:"file_owner,omitempty"`
	FileGid      string    `json:"file_gid,omitempty"`
	FileType     string    `json:"file_type,omitempty"`
	FileSHA256   string    `json:"file_sha256,omitempty"`
}

func GetFileInfo

func GetFileInfo(info os.FileInfo, path string, diffDir string) (*FileInfo, error)

GetFileInfo returns file information in drift detection.

func (*FileInfo) AsJSON

func (f *FileInfo) AsJSON() ([]byte, error)

type Image

type Image struct {
	Namespace             string
	SupportContainerImage bool
	images.Image
}

Image provides information about a container image.

type SnapshotKeyInfo

type SnapshotKeyInfo struct {
	Namespace   string            // namespace only used in meta.db
	Snapshotter string            // only used in meta.db
	Key         string            // snapshot key
	ID          uint64            // File system ID. Only used in metadata.db
	Name        string            // snapshot name. Only used in meta.db
	Parent      string            // snapshot parent
	Kind        snapshots.Kind    // snapshot kind
	Inodes      []int64           // Inode numbers. Only in metadata.db
	Size        uint64            // Only in metadata.db
	OverlayPath string            // Custom field added by container explorer
	Labels      map[string]string // mapped labels
	Children    []string          // array of <snapshot key>. Only in meta.db
	CreatedAt   time.Time         // created timestamp
	UpdatedAt   time.Time         // updated timestamp
}

SnapshotKeyInfo provides information about snapshots.

SnapshotKeyInfo contains information found in containerd metadata (meta.db) and snapshot database (metadata.db).

type State

type State struct {
	ID                  string                 `json:"state,omitempty"`
	InitProcessPid      int                    `json:"init_process_pid"`
	InitProcessstart    int                    `json:"init_process_start"`
	Created             time.Time              `json:"created"`
	Config              map[string]interface{} `json:"config"`
	Rootless            bool                   `json:"rootless"`
	CgroupPaths         map[string]string      `json:"cgroup_paths"`
	NamespacePaths      map[string]string      `json:"namespace_paths"`
	ExternalDescriptors []string               `json:"external_descriptors"`
	IntelRdtPath        string                 `json:"intel_rdt_path"`
}

State holds runc state information.

runc state file is located at `/run/containerd/runc/<namespace>/<container_id>/state.json`.

The State structure only maps the required attributes form state.json.

type SupportContainer

type SupportContainer struct {
	ContainerNames []string `json:"names" yaml:"names"`
	ImageNames     []string `json:"images" yaml:"images"`
	Labels         []string `json:"labels" yaml:"labels"`
}

SupportContainer contains information about support container.

A support container can be identified by: - Container or pod hostname - Image name - Container labels or annotations

func LoadSupportContainerFromFile

func LoadSupportContainerFromFile(path string) (SupportContainer, error)

LoadSupportContainerFromFile loads the support container information from a yaml file on disk.

func NewSupportContainer

func NewSupportContainer(path string) (*SupportContainer, error)

NewSupportContainer returns the support container instance.

func (*SupportContainer) IsSupportContainer

func (sc *SupportContainer) IsSupportContainer(ctr Container) bool

IsSupportContainer returns if the support container

func (*SupportContainer) JSON

func (sc *SupportContainer) JSON() string

JSON returns the data in json

func (*SupportContainer) SupportContainerImage

func (sc *SupportContainer) SupportContainerImage(image string) bool

SupportContainerImage returns true if the supplied image is a known support container image.

func (*SupportContainer) SupportContainerLabel

func (sc *SupportContainer) SupportContainerLabel(label string) bool

SupportContainerLabel returns true if the supplied name is a known support container label

func (*SupportContainer) SupportContainerName

func (sc *SupportContainer) SupportContainerName(name string) bool

SupportContainerName returns true if the supplied name is a known support container name.

type Task

type Task struct {
	Namespace     string
	Name          string
	PID           int
	ContainerType string
	Status        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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