exec

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package exec is the single seam to external commands (orb, docker, scion, iptables). Real execution uses os/exec; tests inject FakeRunner so backend logic is verifiable offline. Mirrors the Ruby ScionClient runner pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Name string
	Args []string
	Env  map[string]string
	Dir  string
}

type FakeRunner

type FakeRunner struct {
	Calls []Call
	// contains filtered or unexported fields
}

func NewFakeRunner

func NewFakeRunner() *FakeRunner

func (*FakeRunner) Run

func (f *FakeRunner) Run(ctx context.Context, env map[string]string, name string, args ...string) (Result, error)

func (*FakeRunner) RunIn

func (f *FakeRunner) RunIn(_ context.Context, dir string, env map[string]string, name string, args ...string) (Result, error)

func (*FakeRunner) Script

func (f *FakeRunner) Script(key string, res Result)

Script registers a canned Result for a "name arg0 arg1 ..." prefix key.

type RealRunner

type RealRunner struct{}

func (RealRunner) Run

func (r RealRunner) Run(ctx context.Context, env map[string]string, name string, args ...string) (Result, error)

func (RealRunner) RunIn

func (r RealRunner) RunIn(ctx context.Context, dir string, env map[string]string, name string, args ...string) (Result, error)

type Result

type Result struct {
	Stdout string
	Stderr string
	Code   int
}

type Runner

type Runner interface {
	// Run executes name+args with optional extra env (KEY=VALUE merged over the
	// process env). A non-zero exit returns a non-nil error AND the Result.
	Run(ctx context.Context, env map[string]string, name string, args ...string) (Result, error)
	// RunIn is like Run but executes in the given working directory. An empty dir
	// uses the process cwd.
	RunIn(ctx context.Context, dir string, env map[string]string, name string, args ...string) (Result, error)
}

Jump to

Keyboard shortcuts

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