package criutil
import "gvisor.dev/gvisor/pkg/test/criutil"
Package criutil contains utility functions for interacting with the Container Runtime Interface (CRI), principally via the crictl command line tool. This requires critools to be installed on the local system.
Index ¶
- func ResolvePath(executable string) string
- type Crictl
- func NewCrictl(logger testutil.Logger, endpoint string) *Crictl
- func (cc *Crictl) CleanUp()
- func (cc *Crictl) Create(podID, contSpecFile, sbSpecFile string) (string, error)
- func (cc *Crictl) Exec(contID string, args ...string) (string, error)
- func (cc *Crictl) Import(image string) error
- func (cc *Crictl) Logs(contID string, args ...string) (string, error)
- func (cc *Crictl) PodIP(podID string) (string, error)
- func (cc *Crictl) Rm(contID string) error
- func (cc *Crictl) RmPod(podID string) error
- func (cc *Crictl) RunPod(runtime, sbSpecFile string) (string, error)
- func (cc *Crictl) Start(contID string) (string, error)
- func (cc *Crictl) StartContainer(podID, image, sbSpec, contSpec string) (string, error)
- func (cc *Crictl) StartPodAndContainer(runtime, image, sbSpec, contSpec string) (string, string, error)
- func (cc *Crictl) Stop(contID string) error
- func (cc *Crictl) StopContainer(contID string) error
- func (cc *Crictl) StopPod(podID string) error
- func (cc *Crictl) StopPodAndContainer(podID, contID string) error
Functions ¶
func ResolvePath ¶
ResolvePath attempts to find binary paths. It may set the path to invalid, which will cause the execution to fail with a sensible error.
Types ¶
type Crictl ¶
type Crictl struct {
// contains filtered or unexported fields
}
Crictl contains information required to run the crictl utility.
func NewCrictl ¶
NewCrictl returns a Crictl configured with a timeout and an endpoint over which it will talk to containerd.
func (*Crictl) CleanUp ¶
func (cc *Crictl) CleanUp()
CleanUp executes cleanup functions.
func (*Crictl) Create ¶
Create creates a container within a sandbox. It corresponds to `crictl create`.
func (*Crictl) Exec ¶
Exec execs a program inside a container. It corresponds to `crictl exec`.
func (*Crictl) Import ¶
Import imports the given container from the local Docker instance.
func (*Crictl) Logs ¶
Logs retrieves the container logs. It corresponds to `crictl logs`.
func (*Crictl) PodIP ¶
PodIP returns a pod's IP address.
func (*Crictl) Rm ¶
Rm removes a container. It corresponds to `crictl rm`.
func (*Crictl) RmPod ¶
RmPod removes a container. It corresponds to `crictl rmp`.
func (*Crictl) RunPod ¶
RunPod creates a sandbox. It corresponds to `crictl runp`.
func (*Crictl) Start ¶
Start starts a container. It corresponds to `crictl start`.
func (*Crictl) StartContainer ¶
StartContainer pulls the given image ands starts the container in the sandbox with the given podID.
Note that the image will always be imported from the local docker daemon.
func (*Crictl) StartPodAndContainer ¶
func (cc *Crictl) StartPodAndContainer(runtime, image, sbSpec, contSpec string) (string, string, error)
StartPodAndContainer starts a sandbox and container in that sandbox. It returns the pod ID and container ID.
func (*Crictl) Stop ¶
Stop stops a container. It corresponds to `crictl stop`.
func (*Crictl) StopContainer ¶
StopContainer stops and deletes the container with the given container ID.
func (*Crictl) StopPod ¶
StopPod stops a pod. It corresponds to `crictl stopp`.
func (*Crictl) StopPodAndContainer ¶
StopPodAndContainer stops a container and pod.
Source Files ¶
criutil.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 4 hours ago –
Tools for package owners.