kern

package
v0.99.12 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package kern provides CLI-backed container execution for workflow and sandbox runners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindSpec

func BindSpec(source, target string, readOnly bool) string

BindSpec formats a host:container bind for kern -v.

func BoxName

func BoxName(id string) string

BoxName sanitizes a task or session id into a kern box name.

func LookPath

func LookPath(binary string) error

LookPath reports whether the kern binary is available.

func PrepareBindMount

func PrepareBindMount(_ context.Context, mnt *types.Mount) error

PrepareBindMount ensures the bind source exists on the host.

func ResolveBinary

func ResolveBinary(path string) string

ResolveBinary returns the configured binary or the default name.

func ValidateBindMount

func ValidateBindMount(allowed bool, mnt types.Mount) error

ValidateBindMount checks whether a bind mount is permitted under the executor policy.

Types

type BoxOptions

type BoxOptions struct {
	Name            string
	Image           string
	Command         []string
	Entrypoint      []string
	Env             []string
	Binds           []string
	Memory          string
	CPUs            string
	Network         string
	Workdir         string
	SecurityProfile string
	RequireLimits   bool
}

BoxOptions configures a one-shot kern box job.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client invokes the kern CLI.

func NewClient

func NewClient(cfg Config) *Client

NewClient creates a Client for the given config.

func (*Client) Binary

func (c *Client) Binary() string

Binary returns the resolved kern executable path.

func (*Client) BoxJob

func (c *Client) BoxJob(ctx context.Context, opts BoxOptions) (stdout, stderr string, exitCode int, err error)

BoxJob runs a one-shot kern box job and returns captured stdout/stderr and exit code.

func (*Client) Doctor

func (c *Client) Doctor(ctx context.Context) error

Doctor runs kern doctor.

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, image string) error

Pull pulls an OCI image.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, name string) error

Stop stops a named box.

type CommandRunner

type CommandRunner func(ctx context.Context, name string, args ...string) *exec.Cmd

CommandRunner runs external commands; tests may replace it.

type Config

type Config struct {
	// Binary is the kern executable path; empty uses "kern" on PATH.
	Binary string
	// SecurityProfile sets --security-profile on boxes (e.g. "untrusted").
	SecurityProfile string
	// RequireLimits maps to --require-limits when true.
	RequireLimits bool
	// BindAllowed mirrors executor.mounts.bind.allowed for user bind mounts.
	BindAllowed bool
}

Config configures the kern CLI runtime.

type Option

type Option func(*Runtime)

Option configures Runtime construction.

func WithClient

func WithClient(client *Client) Option

WithClient sets a pre-built Client (tests).

func WithConfig

func WithConfig(cfg Config) Option

WithConfig sets runtime configuration.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime executes workflow tasks via the kern CLI.

func NewRuntime

func NewRuntime(opts ...Option) (*Runtime, error)

NewRuntime creates a kern workflow runtime.

func (*Runtime) Close

func (*Runtime) Close() error

Close releases runtime resources.

func (*Runtime) HealthCheck

func (r *Runtime) HealthCheck(ctx context.Context) error

HealthCheck verifies kern is usable on the host.

func (*Runtime) Run

func (r *Runtime) Run(ctx context.Context, t *types.Task) error

Run executes the task in a one-shot kern box.

func (*Runtime) Stop

func (r *Runtime) Stop(_ context.Context, t *types.Task) error

Stop stops a running kern box for the task.

Jump to

Keyboard shortcuts

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