tinfoilconfig

package module
v0.1.9 Latest Latest
Warning

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

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

README

tinfoil-config

Canonical Go types and validation for the measured Tinfoil workload YAML format.

This repository owns the current v1 YAML contract shared by cvmimage, tinfoild, and measure-image-action. It deliberately does not own launcher metadata or perform translation to a future runtime format.

Go API

cfg, err := tinfoilconfig.Decode(data, tinfoilconfig.Options{})

Use HostDebugMode only after trusted tinfoild debug injection. It permits the reserved debug toolbox's two runtime socket mounts; all other validation still applies.

CLI

go run ./cmd/tinfoil-config config.yml

The command exits non-zero and prints the exact schema or policy violation for invalid input.

Plaintext models without a containers[].models grant retain the legacy shared mount behavior. Granted models use isolated named mounts; encrypted models always require at least one explicit container grant.

Documentation

Overview

Package tinfoilconfig defines and validates the measured Tinfoil workload configuration format.

Index

Constants

View Source
const (
	ReservedDebugContainerName = "tinfoil-debug-toolbox"
	ReservedDebugPort          = "2222/tcp"
	ReservedDebugHostPort      = 2222
)
View Source
const MaxConfigBytes = 1 << 20
View Source
const (
	MaxModelDisks = 24
)

Variables

This section is empty.

Functions

func HasReservedDebugContainer

func HasReservedDebugContainer(config *Config) bool

func ModelIsIsolated added in v0.1.3

func ModelIsIsolated(config *Config, name string) bool

func ReservedDebugRuntimeEnabled

func ReservedDebugRuntimeEnabled(containerName string, options Options) bool

func ShimUpstreamSet

func ShimUpstreamSet(config *Config) bool

func Validate

func Validate(config *Config, options Options) error

func ValidateBytes

func ValidateBytes(data []byte, options Options) error

Types

type CVMNetworkConfig

type CVMNetworkConfig struct {
	InboundPorts []int `yaml:"inbound-ports"`
}

type Config

type Config struct {
	CVMVersion   string                  `yaml:"cvm-version"`
	ShimRaw      yaml.Node               `yaml:"shim"`
	ShimCfg      *ShimConfig             `yaml:"-"`
	CVMNetwork   CVMNetworkConfig        `yaml:"cvm-network"`
	Networks     map[string]*NetworkSpec `yaml:"networks"`
	CPUs         int                     `yaml:"cpus"`
	Memory       int                     `yaml:"memory"`
	GPUs         int                     `yaml:"gpus"`
	Models       []ModelSpec             `yaml:"models"`
	Volumes      []VolumeSpec            `yaml:"volumes"`
	Containers   []Container             `yaml:"containers"`
	KeyserverURL string                  `yaml:"keyserver-url,omitempty"`
}

func Decode

func Decode(data []byte, options Options) (*Config, error)

type Container

type Container struct {
	Name        string            `yaml:"name"`
	Image       string            `yaml:"image"`
	Command     []string          `yaml:"command,omitempty"`
	Entrypoint  []string          `yaml:"entrypoint,omitempty"`
	WorkingDir  string            `yaml:"working_dir,omitempty"`
	User        string            `yaml:"user,omitempty"`
	Env         []interface{}     `yaml:"env,omitempty"`
	Secrets     []string          `yaml:"secrets,omitempty"`
	Models      []string          `yaml:"models,omitempty"`
	Volumes     []string          `yaml:"volumes,omitempty"`
	Devices     []string          `yaml:"devices,omitempty"`
	CapAdd      []string          `yaml:"cap_add,omitempty"`
	Runtime     string            `yaml:"runtime,omitempty"`
	Networks    []string          `yaml:"networks,omitempty"`
	Ports       []string          `yaml:"ports,omitempty"`
	IPC         string            `yaml:"ipc,omitempty"`
	PidMode     string            `yaml:"pid,omitempty"`
	GPUs        interface{}       `yaml:"gpus,omitempty"`
	ShmSize     string            `yaml:"shm_size,omitempty"`
	Memory      string            `yaml:"memory,omitempty"`
	CPUs        float64           `yaml:"cpus,omitempty"`
	Tmpfs       map[string]string `yaml:"tmpfs,omitempty"`
	ReadOnly    *bool             `yaml:"read_only,omitempty"`
	PidsLimit   *int64            `yaml:"pids_limit,omitempty"`
	Restart     string            `yaml:"restart,omitempty"`
	StopSignal  string            `yaml:"stop_signal,omitempty"`
	StopTimeout *int              `yaml:"stop_timeout,omitempty"`
	Healthcheck *Healthcheck      `yaml:"healthcheck,omitempty"`
	// contains filtered or unexported fields
}

func (*Container) UnmarshalYAML

func (c *Container) UnmarshalYAML(node *yaml.Node) error

type Healthcheck

type Healthcheck struct {
	Test        []string `yaml:"test"`
	Interval    string   `yaml:"interval,omitempty"`
	Timeout     string   `yaml:"timeout,omitempty"`
	Retries     int      `yaml:"retries,omitempty"`
	StartPeriod string   `yaml:"start_period,omitempty"`
}

func (*Healthcheck) UnmarshalYAML

func (h *Healthcheck) UnmarshalYAML(node *yaml.Node) error

type ModelSpec

type ModelSpec struct {
	Name      string `yaml:"name,omitempty"`
	Repo      string `yaml:"repo,omitempty"`
	MPK       string `yaml:"mpk,omitempty"`
	MWP       string `yaml:"mwp,omitempty"`
	EMWP      string `yaml:"emwp,omitempty"`
	KeySecret string `yaml:"key-secret,omitempty"`
	// Weights are never programs, so a pack is noexec unless declared otherwise.
	Exec bool `yaml:"exec,omitempty"`
	// Schema is the pack schema the pinned artifact was built with (0 = schema 1,
	// the original layout). Declarative for now; no consumer reads it yet.
	Schema int `yaml:"schema,omitempty"`
}

type NetworkSpec

type NetworkSpec struct {
	Egress string   `yaml:"egress"`
	Allow  []string `yaml:"allow"`
}

func (*NetworkSpec) UnmarshalYAML

func (n *NetworkSpec) UnmarshalYAML(node *yaml.Node) error

type Options

type Options struct {
	Mode ValidationMode
}

type PortMapping added in v0.1.4

type PortMapping struct {
	Host      int
	Container int
}

func ParsePorts added in v0.1.4

func ParsePorts(ports []string) ([]PortMapping, error)

ParsePorts parses compose-style "<host>:<container>" entries, so no host-IP prefix, no ranges, no /udp suffix.

type ShimConfig

type ShimConfig struct {
	UpstreamPort      int      `yaml:"upstream-port"`
	UpstreamContainer string   `yaml:"upstream-container,omitempty"`
	Paths             []string `yaml:"paths"`
	OriginDomains     []string `yaml:"origins"`

	TLSMode          string `yaml:"tls-mode" default:"cert-proxy"`
	TLSEnv           string `yaml:"tls-env" default:"production"`
	TLSChallengeMode string `yaml:"tls-challenge" default:"dns"`
	TLSWildcard      bool   `yaml:"tls-wildcard" default:"false"`
	TLSOwnSANDomain  bool   `yaml:"tls-own-san-domain" default:"false"`

	ControlPlane           string    `yaml:"control-plane" default:"https://api.tinfoil.sh"`
	ATC                    string    `yaml:"atc" default:"https://atc.tinfoil.sh"`
	Authenticated          bool      `yaml:"authenticated" default:"false"`
	AuthenticatedEndpoints *[]string `yaml:"authenticated-endpoints"`
	RateLimit              float64   `yaml:"rate-limit"`
	RateBurst              int       `yaml:"rate-burst"`
	Email                  string    `yaml:"email" default:"tls@tinfoil.sh"`
	PublishAttestation     bool      `yaml:"publish-attestation" default:"true"`
	DummyAttestation       bool      `yaml:"dummy-attestation" default:"false"`
	ExpectedGPUs           int       `yaml:"expected-gpus" default:"0"`
}

func DecodeShim

func DecodeShim(node *yaml.Node) (*ShimConfig, error)

func (*ShimConfig) Validate

func (c *ShimConfig) Validate() error

type ValidationMode

type ValidationMode uint8

ValidationMode selects which producer is allowed to construct the config. WorkloadMode is for user-supplied measured YAML. HostDebugMode is only for YAML after tinfoild has injected its reserved debug toolbox.

const (
	WorkloadMode ValidationMode = iota
	HostDebugMode
)

type VolumeOverlay added in v0.1.8

type VolumeOverlay struct {
	Model  string `yaml:"model"`
	Source string `yaml:"source"`
	Target string `yaml:"target"`
}

VolumeOverlay stacks a model pack under a writable directory on the volume: Source is a subtree of the Model pack, taken as the read-only lower layer, and the merged tree appears at Target inside the volume. Both paths are measured here rather than chosen at unlock, so no runtime caller can steer the mount.

type VolumeSpec added in v0.1.7

type VolumeSpec struct {
	Name      string          `yaml:"name"`
	Exec      bool            `yaml:"exec,omitempty"`
	Owner     int             `yaml:"owner,omitempty"`
	KeySecret string          `yaml:"key-secret,omitempty"`
	Overlays  []VolumeOverlay `yaml:"overlays,omitempty"`
}

Directories

Path Synopsis
cmd
tinfoil-config command

Jump to

Keyboard shortcuts

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