bundle

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArtifactModule = "module.wasm"
	ArtifactTests  = "tests.yaml"
	// DataPrefix marks descriptor artifacts that are read-only data files
	// bundled with the rule and exposed to the guest via the data ABI.
	DataPrefix = "data/"
)
View Source
const ABIVersion = "switchboard/v4"
View Source
const DescriptorSchema = "switchboard.descriptor/v1"
View Source
const RevisionSchema = "switchboard.revision/v1"

Variables

View Source
var ErrInvalid = errors.New("invalid bundle")

ErrInvalid marks a bundle that can never activate as-is; the reconciler quarantines it instead of retrying.

Functions

func ArtifactDigest added in v0.2.0

func ArtifactDigest(data []byte) string

func CanonicalJSON added in v0.2.0

func CanonicalJSON(v any) ([]byte, error)

CanonicalJSON encodes v deterministically (sorted keys, no whitespace, no HTML escaping) so digests over the output are stable.

func DescriptorDigest added in v0.2.0

func DescriptorDigest(raw []byte) string

func IsDataArtifact added in v0.2.0

func IsDataArtifact(name string) bool

IsDataArtifact reports whether an artifact name is a bundled data file.

func ModuleChecksum

func ModuleChecksum(module []byte) string

func VerifyModuleChecksum

func VerifyModuleChecksum(module []byte, expected string) error

Types

type ArtifactRef added in v0.2.0

type ArtifactRef struct {
	Digest string `json:"digest"`
	Size   int64  `json:"size"`
}

type Bundle

type Bundle struct {
	ID            string
	Module        []byte
	Manifest      Manifest
	Checksum      string
	Tests         []byte
	Descriptor    Descriptor
	DescriptorRaw []byte
	// Data holds read-only bundled data files keyed by their descriptor
	// artifact name (e.g. "data/allowlist.txt").
	Data map[string][]byte
}

type ChannelPointer

type ChannelPointer struct {
	Namespace        string    `json:"namespace,omitempty"`
	Channel          string    `json:"channel"`
	BundleID         string    `json:"bundle_id"`
	Checksum         string    `json:"checksum"`
	Generation       uint64    `json:"generation,omitempty"`
	DescriptorDigest string    `json:"descriptor_digest,omitempty"`
	CreatedAt        time.Time `json:"created_at"`
}

func ParseChannelPointer

func ParseChannelPointer(data []byte) (ChannelPointer, error)

type Descriptor added in v0.2.0

type Descriptor struct {
	Schema     string                 `json:"schema"`
	ABI        string                 `json:"abi"`
	Manifest   ManifestIdentity       `json:"manifest"`
	Artifacts  map[string]ArtifactRef `json:"artifacts"`
	Provenance Provenance             `json:"provenance,omitempty"`
	// Signatures is reserved for future bundle signing; never verified yet.
	Signatures []json.RawMessage `json:"signatures"`
}

Descriptor's identity zone (schema, abi, manifest, artifacts) derives the bundle ID; provenance and signatures are annotations that never change it.

func NewDescriptor added in v0.2.0

func NewDescriptor(identity ManifestIdentity, artifacts map[string][]byte) Descriptor

func ParseDescriptor added in v0.2.0

func ParseDescriptor(data []byte) (Descriptor, error)

func (Descriptor) BundleID added in v0.2.0

func (d Descriptor) BundleID() (string, error)

func (Descriptor) Verify added in v0.2.0

func (d Descriptor) Verify(files map[string][]byte) error

type Manifest

type Manifest struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	ABI        string `json:"abi_version"`
	Entrypoint string `json:"entrypoint"`
	Language   string `json:"language"`
}

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

type ManifestIdentity added in v0.2.0

type ManifestIdentity struct {
	Name       string `json:"name"`
	ABI        string `json:"abi"`
	Entrypoint string `json:"entrypoint"`
	Language   string `json:"language"`
}

ManifestIdentity excludes the manifest version field because it is set to the bundle ID itself after hashing.

type Provenance added in v0.2.0

type Provenance struct {
	BuiltAt      time.Time `json:"built_at,omitempty"`
	Builder      string    `json:"builder,omitempty"`
	SourceCommit string    `json:"source_commit,omitempty"`
	SourceDirty  bool      `json:"source_dirty,omitempty"`
	CIRun        string    `json:"ci_run,omitempty"`
}

type Revision added in v0.2.0

type Revision struct {
	Schema             string    `json:"schema"`
	Namespace          string    `json:"namespace,omitempty"`
	Channel            string    `json:"channel"`
	Generation         uint64    `json:"generation"`
	BundleID           string    `json:"bundle_id"`
	DescriptorDigest   string    `json:"descriptor_digest,omitempty"`
	PreviousGeneration uint64    `json:"previous_generation,omitempty"`
	DeployedAt         time.Time `json:"deployed_at"`
	DeployedBy         string    `json:"deployed_by,omitempty"`
	SourceCommit       string    `json:"source_commit,omitempty"`
	CIRun              string    `json:"ci_run,omitempty"`
	Message            string    `json:"message,omitempty"`
}

Revision is an append-only deployment record; generations only ever grow.

func ParseRevision added in v0.2.0

func ParseRevision(data []byte) (Revision, error)

Jump to

Keyboard shortcuts

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