container

package
v0.15.20 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DOCKER_COMMAND = "docker"
	PODMAN_COMMAND = "podman"
)
View Source
const LABEL_PREFIX = "dev.openrun."
View Source
const UNNAMED_VOLUME = "<UNNAMED>"

Variables

This section is empty.

Functions

func BuildHTTPTransport

func BuildHTTPTransport(r *types.RegistryConfig) (*http.Transport, error)

func CreateOrUpdateSecret

func CreateOrUpdateSecret(ctx context.Context, cs *kubernetes.Clientset, ns, name string, data map[string][]byte, typ corev1.SecretType) error

func DelegateHandler

func DelegateHandler(w http.ResponseWriter, r *http.Request, config *types.ServerConfig, logger *types.Logger)

DelegateHandler is the handler for the delegated build API

func GenerateDockerConfigJSON

func GenerateDockerConfigJSON(r *types.RegistryConfig) ([]byte, error)

func GetDockerConfig

func GetDockerConfig(ctx context.Context, imageRef string, registryConfig *types.RegistryConfig) (name.Reference, []remote.Option, error)

func ImageExists

func ImageExists(ctx context.Context, logger *types.Logger, imageRef string, r *types.RegistryConfig) (bool, error)

func KanikoJob

func KanikoJob(ctx context.Context, logger *types.Logger, cs *kubernetes.Clientset, cfg *rest.Config, r *types.RegistryConfig, dockerCfgJSON []byte, kb KanikoBuild) error

func LookupContainerCommand

func LookupContainerCommand(checkKubernetes bool) string

Types

type Container

type Container struct {
	ID         string `json:"ID"`
	Names      string `json:"Names"`
	Image      string `json:"Image"`
	State      string `json:"State"`
	Status     string `json:"Status"`
	PortString string `json:"Ports"`
	Port       int
}

type ContainerCommand

type ContainerCommand struct {
	*types.Logger
	// contains filtered or unexported fields
}

func NewContainerCommand

func NewContainerCommand(logger *types.Logger, config *types.ServerConfig, appId types.AppId, appRunDir string) *ContainerCommand

func (*ContainerCommand) BuildImage

func (c *ContainerCommand) BuildImage(ctx context.Context, imgName ImageName, sourceUrl, containerFile string, containerArgs map[string]string) error

func (*ContainerCommand) ExecTailN

func (c *ContainerCommand) ExecTailN(ctx context.Context, command string, args []string, n int) ([]string, error)

ExecTailN executes a command and returns the last n lines of output

func (*ContainerCommand) GetContainerLogs

func (c *ContainerCommand) GetContainerLogs(ctx context.Context, name ContainerName) (string, error)

func (*ContainerCommand) GetContainerState

func (c *ContainerCommand) GetContainerState(ctx context.Context, name ContainerName) (string, bool, error)

GetContainerState returns the host:port of the running container, "" if not running. running is true if the container is running.

func (*ContainerCommand) ImageExists

func (c *ContainerCommand) ImageExists(ctx context.Context, name ImageName) (bool, error)

func (*ContainerCommand) RemoveContainer

func (c *ContainerCommand) RemoveContainer(ctx context.Context, name ContainerName) error

func (*ContainerCommand) RemoveImage

func (c *ContainerCommand) RemoveImage(ctx context.Context, name ImageName) error

func (*ContainerCommand) RunContainer

func (c *ContainerCommand) RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, containerName ContainerName,
	imageName ImageName, port int64, envMap map[string]string, volumes []*VolumeInfo,
	containerOptions map[string]string, paramMap map[string]string) error

func (*ContainerCommand) StartContainer

func (c *ContainerCommand) StartContainer(ctx context.Context, name ContainerName) error

func (*ContainerCommand) StopContainer

func (c *ContainerCommand) StopContainer(ctx context.Context, name ContainerName) error

func (ContainerCommand) VolumeCreate

func (c ContainerCommand) VolumeCreate(ctx context.Context, name VolumeName) error

func (ContainerCommand) VolumeExists

func (c ContainerCommand) VolumeExists(ctx context.Context, name VolumeName) bool

type ContainerManager

type ContainerManager interface {
	BuildImage(ctx context.Context, name ImageName, sourceUrl, containerFile string, containerArgs map[string]string) error
	ImageExists(ctx context.Context, name ImageName) (bool, error)
	GetContainerState(ctx context.Context, name ContainerName) (string, bool, error)
	StartContainer(ctx context.Context, name ContainerName) error
	StopContainer(ctx context.Context, name ContainerName) error
	RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, containerName ContainerName,
		imageName ImageName, port int64, envMap map[string]string, volumes []*VolumeInfo,
		containerOptions map[string]string, paramMap map[string]string) error
	GetContainerLogs(ctx context.Context, name ContainerName) (string, error)
	VolumeExists(ctx context.Context, name VolumeName) bool
	VolumeCreate(ctx context.Context, name VolumeName) error
}

ContainerManager is the interface for managing containers

type ContainerName

type ContainerName string

func GenContainerName

func GenContainerName(appId types.AppId, cm ContainerManager, contentHash string) ContainerName

type DelegateRequest

type DelegateRequest struct {
	ImageTag       string
	ContainerFile  string
	ContainerArgs  map[string]string
	RegistryConfig *types.RegistryConfig
}

type DevContainerManager

type DevContainerManager interface {
	ContainerManager
	RemoveImage(ctx context.Context, name ImageName) error
	RemoveContainer(ctx context.Context, name ContainerName) error
}

DevContainerManager is the interface for managing containers in dev mode

type ExistsResult

type ExistsResult struct {
	Exists bool
	Digest string
}

func CheckImagesExists

func CheckImagesExists(ctx context.Context, logger *types.Logger, imageRef string, registryConfig *types.RegistryConfig) (ExistsResult, error)

type ImageName

type ImageName string

func GenImageName

func GenImageName(appId types.AppId, contentHash string) ImageName

type KanikoBuild

type KanikoBuild struct {
	Namespace   string
	JobName     string
	Image       string // e.g. "cgr.dev/chainguard/kaniko:latest"
	SourceDir   string // Local directory to tar up and send to Kaniko
	Dockerfile  string
	Destination string
	ExtraArgs   []string
}

type KubernetesContainerManager

type KubernetesContainerManager struct {
	*types.Logger
	// contains filtered or unexported fields
}

func NewKubernetesContainerManager

func NewKubernetesContainerManager(logger *types.Logger, config *types.ServerConfig) (*KubernetesContainerManager, error)

func (*KubernetesContainerManager) BuildImage

func (k *KubernetesContainerManager) BuildImage(ctx context.Context, imgName ImageName, sourceUrl, containerFile string, containerArgs map[string]string) error

func (*KubernetesContainerManager) GetContainerLogs

func (k *KubernetesContainerManager) GetContainerLogs(ctx context.Context, name ContainerName) (string, error)

func (*KubernetesContainerManager) GetContainerState

func (k *KubernetesContainerManager) GetContainerState(ctx context.Context, name ContainerName) (string, bool, error)

func (*KubernetesContainerManager) ImageExists

func (k *KubernetesContainerManager) ImageExists(ctx context.Context, name ImageName) (bool, error)

func (*KubernetesContainerManager) RunContainer

func (k *KubernetesContainerManager) RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, containerName ContainerName,
	imageName ImageName, port int64, envMap map[string]string, volumes []*VolumeInfo,
	containerOptions map[string]string, paramMap map[string]string) error

func (*KubernetesContainerManager) StartContainer

func (k *KubernetesContainerManager) StartContainer(ctx context.Context, name ContainerName) error

func (*KubernetesContainerManager) StopContainer

func (k *KubernetesContainerManager) StopContainer(ctx context.Context, name ContainerName) error

func (*KubernetesContainerManager) VolumeCreate

func (k *KubernetesContainerManager) VolumeCreate(ctx context.Context, name VolumeName) error

func (*KubernetesContainerManager) VolumeExists

func (k *KubernetesContainerManager) VolumeExists(ctx context.Context, name VolumeName) bool

type VolumeInfo

type VolumeInfo struct {
	IsSecret   bool
	VolumeName string
	SourcePath string
	TargetPath string
	ReadOnly   bool
}

type VolumeName

type VolumeName string

func GenVolumeName

func GenVolumeName(appId types.AppId, dirName string) VolumeName

Jump to

Keyboard shortcuts

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