docker

package
v0.0.0-...-b2e0f1d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Root = UIDGID{UID: 0, GID: 0}

Root is a root:root user.

Functions

func CheckVersion

func CheckVersion(ctx context.Context) error

CheckVersion is used to check if docker is running. We use this method instead of checkExecutable (https://sourcegraph.com/github.com/sourcegraph/src-cli@main/-/blob/cmd/src/batch_common.go?L547%3A6=&popover=pinned) to prevent a case where docker commands take too long and results in `src-cli` freezing for some users.

func CurrentContext

func CurrentContext(ctx context.Context) (string, error)

CurrentContext returns the name of the current Docker context (not to be confused with a Go context).

func NCPU

func NCPU(ctx context.Context) (int, error)

NCPU returns the number of CPU cores available to Docker.

Types

type Image

type Image interface {
	Digest(context.Context) (string, error)
	Ensure(context.Context) error
	UIDGID(context.Context) (UIDGID, error)
}

Image represents a Docker image, hopefully stored in the local cache.

type ImageCache

type ImageCache interface {
	Get(name string) Image
	Ensure(ctx context.Context, name string) (Image, error)
}

func NewImageCache

func NewImageCache() ImageCache

NewImageCache creates a new image cache.

type Info

type Info struct {
	Host struct {
		CPUs int `json:"cpus"`
	} `json:"host"` // Podman engine
	NCPU int `json:"NCPU"` // Docker Engine
}

type UIDGID

type UIDGID struct {
	UID int
	GID int
}

UIDGID represents a UID:GID pair.

func (UIDGID) String

func (ug UIDGID) String() string

Jump to

Keyboard shortcuts

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