Documentation
¶
Index ¶
- Constants
- func BuildWorkspaceInitScript(base string, workdirs []string) string
- func CollectWorkspacePaths(conf *types.Config) (base string, workdirs []string)
- func EncodeAuthToBase64(authConfig types.Auth) (string, error)
- func GenerateContainerConf(commands []string, osType, workDir string) (env map[string]string, entry []string)
- func IsContainerNotFoundOrNotRunning(err error) bool
- func MakeLabels(step *types.Step, taskUUID string) map[string]string
- func ParseCPUQuota(s string) (int64, error)
- func ParseMemory(s string) (int64, error)
- func SanitizeAndTruncateName(name string, maxLen int) string
- func SplitVolumeParts(volumeParts string) ([]string, error)
- func ToContainerName(step *types.Step) string
- func ToEnv(env map[string]string) []string
- func ToVol(paths []string) map[string]struct{}
Constants ¶
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.
const MaxContainerNameLength = 64
MaxContainerNameLength is the maximum length for container names.
const MinVolumeComponents = 2
MinVolumeComponents is the minimum number of components for a valid volume path.
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
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
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 ¶
EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload.
func GenerateContainerConf ¶
func IsContainerNotFoundOrNotRunning ¶
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 ¶
MakeLabels creates the standard container labels for workflow discovery.
func ParseCPUQuota ¶
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 ¶
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 ¶
SanitizeAndTruncateName makes a name safe for Docker/Kubernetes/Podman and truncates to maxLen.
func SplitVolumeParts ¶
SplitVolumeParts splits a volume string into its constituent parts.
The parts are:
- The path on the host machine
- The path inside the container
- The read/write mode (optional)
It handles Windows and Linux style volume paths.
func ToContainerName ¶
ToContainerName generates a container name from step metadata. It uses a descriptive naming scheme by default unless explicitly set to "hash".
Types ¶
This section is empty.
Source Files
¶
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. |