common

package
v6.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelTaskUUID identifies which workflow/task a container belongs to.
	// Used by DiscoverWorkflows to find orphaned containers for adoption.
	LabelTaskUUID = "crowci/task-uuid"

	// LabelStepUUID identifies the specific step within a workflow.
	LabelStepUUID = "crowci/step-uuid"

	// LabelStepName is the human-readable step name.
	LabelStepName = "crowci/step"
)

Container label constants for workflow discovery and adoption. Used by both Docker and Podman backends.

View Source
const MaxContainerNameLength = 64

MaxContainerNameLength is the maximum length for container names.

View Source
const MinVolumeComponents = 2

MinVolumeComponents is the minimum number of components for a valid volume path.

View Source
const WorkspaceInitPrefix = "crow-workspace-init-"

WorkspaceInitPrefix is the container name prefix for the workspace-init helper used by the Docker and Podman backends.

Variables

This section is empty.

Functions

func BuildWorkspaceInitScript added in v6.1.0

func BuildWorkspaceInitScript(base string, workdirs []string) string

BuildWorkspaceInitScript creates the working directories and makes the whole workspace tree world-writable with the sticky bit set (1777, like /tmp). The volume is empty when this runs, so the recursive chmod only ever touches the directories we just created.

Running this agent-controlled script before any pipeline step or plugin makes workspace ownership deterministic: it no longer depends on whether the first item to write into the fresh named volume is a (non-root) command step or a (root) plugin.

func CollectWorkspacePaths added in v6.1.0

func CollectWorkspacePaths(conf *types.Config) (base string, workdirs []string)

CollectWorkspacePaths returns the shared workspace base to mount the volume at, plus the distinct working directories that should be pre-created. Every step shares the same base (DefaultWorkspaceBase / pluginWorkspaceBase), so the first non-empty base wins.

func EncodeAuthToBase64

func EncodeAuthToBase64(authConfig types.Auth) (string, error)

EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload.

func GenerateContainerConf

func GenerateContainerConf(commands []string, osType, workDir string) (env map[string]string, entry []string)

func IsContainerNotFoundOrNotRunning

func IsContainerNotFoundOrNotRunning(err error) bool

IsContainerNotFoundOrNotRunning checks if an error indicates that a container was not found or is not running. This handles error messages from Docker, Podman, and containerd.

func MakeLabels

func MakeLabels(step *types.Step, taskUUID string) map[string]string

MakeLabels creates the standard container labels for workflow discovery.

func ParseCPUQuota

func ParseCPUQuota(s string) (int64, error)

ParseCPUQuota parses a CPU string and returns the quota in microseconds. Docker CPU quota is specified in microseconds per 100ms period. 100000 = 1 CPU core, 200000 = 2 cores, 50000 = 0.5 cores Supports: "2" (2 cores), "1000m" (1 core in millicores), "0.5" (0.5 cores) Also accepts quoted strings like "'3'" or '"3"' from config files Returns 0 for empty string or "0".

func ParseMemory

func ParseMemory(s string) (int64, error)

ParseMemory parses a memory string with optional units and returns bytes. Supports: "2Gi", "512Mi", "1G", "100M", "1024" (plain numbers are bytes) Also accepts quoted strings like "'6Gi'" or '"512Mi"' from config files Returns 0 for empty string or "0".

func SanitizeAndTruncateName

func SanitizeAndTruncateName(name string, maxLen int) string

SanitizeAndTruncateName makes a name safe for Docker/Kubernetes/Podman and truncates to maxLen.

func SplitVolumeParts

func SplitVolumeParts(volumeParts string) ([]string, error)

SplitVolumeParts splits a volume string into its constituent parts.

The parts are:

  1. The path on the host machine
  2. The path inside the container
  3. The read/write mode (optional)

It handles Windows and Linux style volume paths.

func ToContainerName

func ToContainerName(step *types.Step) string

ToContainerName generates a container name from step metadata. It uses a descriptive naming scheme by default unless explicitly set to "hash".

func ToEnv

func ToEnv(env map[string]string) []string

ToEnv converts a key-value map of environment variables to a string slice in key=value format.

func ToVol

func ToVol(paths []string) map[string]struct{}

ToVol converts a slice of volume paths to a set of unique volume names.

Types

This section is empty.

Directories

Path Synopsis
Package clone exposes the bits the local and docker backends both need to run the crow-plugins/clone binary natively on the agent host: env-var preparation, netrc generation, and downloading the plugin binary if it isn't already on PATH.
Package clone exposes the bits the local and docker backends both need to run the crow-plugins/clone binary natively on the agent host: env-var preparation, netrc generation, and downloading the plugin binary if it isn't already on PATH.

Jump to

Keyboard shortcuts

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