Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func ApplyEnvironment(containerConfig *container.Config, environment map[string]string)
- func ApplyNonRootUser(containerConfig *container.Config, uid, gid int)
- func ApplyResourceLimits(hostConfig *container.HostConfig, limits *loomv1.ResourceLimits)
- func ApplySecurityOptions(hostConfig *container.HostConfig)
- func ApplyVolumeMounts(hostConfig *container.HostConfig, volumeMounts []*loomv1.VolumeMount)
- func GetNodeTraceLibrary() string
- func GetPythonTraceLibrary() string
- type BaseRuntime
- type CustomRuntime
- func (cr *CustomRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
- func (cr *CustomRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
- func (cr *CustomRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
- func (cr *CustomRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
- func (cr *CustomRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
- type NodeRuntime
- func (nr *NodeRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
- func (nr *NodeRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
- func (nr *NodeRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
- func (nr *NodeRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
- func (nr *NodeRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
- type PythonRuntime
- func (pr *PythonRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
- func (pr *PythonRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
- func (pr *PythonRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
- func (pr *PythonRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
- func (pr *PythonRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEnvironment ¶
ApplyEnvironment applies environment variables to ContainerConfig.
func ApplyNonRootUser ¶
ApplyNonRootUser configures container to run as non-root user. - Sets User to UID:GID format (default: 1000:1000) - Creates /workspace and /tmp with proper ownership - Prevents privilege escalation
Security Benefits:
- Limits damage from container escape
- Prevents unauthorized file access on host
- Compliance with security best practices
func ApplyResourceLimits ¶
func ApplyResourceLimits(hostConfig *container.HostConfig, limits *loomv1.ResourceLimits)
ApplyResourceLimits applies CPU/memory limits to HostConfig.
func ApplySecurityOptions ¶
func ApplySecurityOptions(hostConfig *container.HostConfig)
ApplySecurityOptions applies security settings to HostConfig. - Read-only rootfs (except /tmp) - Capability dropping (all caps except NET_BIND_SERVICE) - No privileged mode
func ApplyVolumeMounts ¶
func ApplyVolumeMounts(hostConfig *container.HostConfig, volumeMounts []*loomv1.VolumeMount)
ApplyVolumeMounts applies user-defined volume mounts to HostConfig.
func GetNodeTraceLibrary ¶
func GetNodeTraceLibrary() string
GetNodeTraceLibrary returns the Node.js trace library source code.
func GetPythonTraceLibrary ¶
func GetPythonTraceLibrary() string
GetPythonTraceLibrary returns the Python trace library source code.
Types ¶
type BaseRuntime ¶
type BaseRuntime struct {
// contains filtered or unexported fields
}
BaseRuntime provides common functionality for all runtimes. Individual runtime implementations can embed this struct and override methods.
func (*BaseRuntime) Type ¶
func (br *BaseRuntime) Type() loomv1.RuntimeType
Type implements Runtime.Type.
type CustomRuntime ¶
type CustomRuntime struct {
BaseRuntime
}
CustomRuntime configures containers with arbitrary images and entrypoints.
Use Cases:
- Ruby, Rust, Go, Java containers
- Custom-built images with specific toolchains
- Legacy applications with complex setups
- Multi-language environments
Configuration:
- base_image: Any Docker image (e.g., "rust:1.75", "ruby:3.2", custom registry)
- entrypoint_cmd: Custom entrypoint (e.g., ["./my-binary", "--flag"])
- labels: Container labels for organization
Features:
- No package management (handled in base image or Dockerfile)
- Flexible entrypoint configuration
- Full resource limit support
- Security hardening (read-only rootfs, capability drops)
Example Custom Configurations:
Rust container: base_image: "rust:1.75-slim" entrypoint_cmd: ["cargo", "run"]
Go container: base_image: "golang:1.21-alpine" entrypoint_cmd: ["./app"]
Custom toolchain: base_image: "gcr.io/my-project/custom-toolchain:latest" entrypoint_cmd: ["./tool", "--config", "/config.yaml"]
func NewCustomRuntime ¶
func NewCustomRuntime() *CustomRuntime
NewCustomRuntime creates a new Custom runtime.
func (*CustomRuntime) BuildContainerConfig ¶
func (cr *CustomRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
BuildContainerConfig implements Runtime.BuildContainerConfig.
func (*CustomRuntime) BuildHostConfig ¶
func (cr *CustomRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
BuildHostConfig implements Runtime.BuildHostConfig.
func (*CustomRuntime) GetCacheMounts ¶
func (cr *CustomRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
GetCacheMounts implements Runtime.GetCacheMounts. For custom runtime: No standard cache mounts. User can specify cache mounts via volume_mounts in config.
func (*CustomRuntime) InstallPackages ¶
func (cr *CustomRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
InstallPackages implements Runtime.InstallPackages. For custom runtime: No standard package management. User is responsible for baking dependencies into base image or Dockerfile.
func (*CustomRuntime) PrepareImage ¶
func (cr *CustomRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
PrepareImage implements Runtime.PrepareImage.
type NodeRuntime ¶
type NodeRuntime struct {
BaseRuntime
}
NodeRuntime configures Node.js containers with npm package management.
Features:
- Multiple Node versions (16 LTS, 18 LTS, 20 LTS, 21)
- npm caching via Docker volume (/root/.npm)
- package.json support
- Preinstalled packages (express, axios, etc.)
Base Images (official Node):
- node:20-slim (default, ~60MB compressed, 180MB uncompressed)
- node:18-slim (LTS)
- node:16-slim (older LTS)
Package Installation:
- Preinstalled packages: npm install <pkg1> <pkg2> ...
- package.json: npm install
- npm cache persisted to volume for fast reinstalls
Security:
- Read-only rootfs (except /tmp and /root/.npm)
- Non-root user (future: create 'loom' user)
- Capability dropping
func NewNodeRuntime ¶
func NewNodeRuntime() *NodeRuntime
NewNodeRuntime creates a new Node.js runtime.
func (*NodeRuntime) BuildContainerConfig ¶
func (nr *NodeRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
BuildContainerConfig implements Runtime.BuildContainerConfig.
func (*NodeRuntime) BuildHostConfig ¶
func (nr *NodeRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
BuildHostConfig implements Runtime.BuildHostConfig.
func (*NodeRuntime) GetCacheMounts ¶
func (nr *NodeRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
GetCacheMounts implements Runtime.GetCacheMounts.
func (*NodeRuntime) InstallPackages ¶
func (nr *NodeRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
InstallPackages implements Runtime.InstallPackages.
func (*NodeRuntime) PrepareImage ¶
func (nr *NodeRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
PrepareImage implements Runtime.PrepareImage.
type PythonRuntime ¶
type PythonRuntime struct {
BaseRuntime
}
PythonRuntime configures Python containers with pip package management.
Features:
- Multiple Python versions (3.9, 3.10, 3.11, 3.12)
- Pip caching via Docker volume (/root/.cache/pip)
- Requirements.txt support
- Preinstalled packages (numpy, pandas, etc.)
- Virtual environment support (optional)
Base Images (official Python):
- python:3.11-slim (default, ~45MB compressed, 120MB uncompressed)
- python:3.10-slim
- python:3.12-slim
Package Installation:
- Preinstalled packages: pip install <pkg1> <pkg2> ...
- Requirements file: pip install -r requirements.txt
- Pip cache persisted to volume for fast reinstalls
Security:
- Read-only rootfs (except /tmp and /root/.cache/pip)
- Non-root user (future: create 'loom' user)
- Capability dropping
func NewPythonRuntime ¶
func NewPythonRuntime() *PythonRuntime
NewPythonRuntime creates a new Python runtime.
func (*PythonRuntime) BuildContainerConfig ¶
func (pr *PythonRuntime) BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
BuildContainerConfig implements Runtime.BuildContainerConfig.
func (*PythonRuntime) BuildHostConfig ¶
func (pr *PythonRuntime) BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
BuildHostConfig implements Runtime.BuildHostConfig.
func (*PythonRuntime) GetCacheMounts ¶
func (pr *PythonRuntime) GetCacheMounts(ctx context.Context) []mount.Mount
GetCacheMounts implements Runtime.GetCacheMounts.
func (*PythonRuntime) InstallPackages ¶
func (pr *PythonRuntime) InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
InstallPackages implements Runtime.InstallPackages.
func (*PythonRuntime) PrepareImage ¶
func (pr *PythonRuntime) PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
PrepareImage implements Runtime.PrepareImage.
type Runtime ¶
type Runtime interface {
// Type returns the runtime type (PYTHON, NODE, CUSTOM, etc.)
Type() loomv1.RuntimeType
// BuildContainerConfig creates Docker container configuration.
// Includes:
// - Image selection (base image or custom Dockerfile)
// - Environment variables
// - Working directory
// - Entrypoint/command
// - Volume mounts for package caching
BuildContainerConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.Config, error)
// BuildHostConfig creates Docker host configuration (resource limits, mounts).
// Includes:
// - CPU/memory limits
// - Volume mounts (cache volumes, user volumes)
// - Security options (read-only rootfs, capability drops)
BuildHostConfig(ctx context.Context, config *loomv1.DockerBackendConfig) (*container.HostConfig, error)
// PrepareImage ensures the required image is available.
// For base images: Pull if not present
// For Dockerfiles: Build custom image
// For ImageBuildConfig: Generate and build Dockerfile
PrepareImage(ctx context.Context, config *loomv1.DockerBackendConfig) (string, error)
// InstallPackages installs runtime-specific packages inside container.
// For Python: pip install -r requirements.txt or pip install <packages>
// For Node: npm install or npm install <packages>
// For Custom: Runs custom_runtime_config.entrypoint_cmd
//
// Returns commands to execute inside container.
InstallPackages(ctx context.Context, config *loomv1.DockerBackendConfig) ([][]string, error)
// GetCacheMounts returns volume mounts for package caching.
// For Python: /root/.cache/pip
// For Node: /root/.npm
// Enables fast package reinstallation across container rotations.
GetCacheMounts(ctx context.Context) []mount.Mount
}
Runtime defines how to configure and manage containers for a specific runtime type. Each runtime (Python, Node, Custom) has different requirements for:
- Base images
- Package management (pip, npm, etc.)
- Environment configuration
- Volume mounts for caching
This interface enables pluggable runtime strategies without changing the executor.