Help us shape the future of Go! Take the 2026 Go Developer Survey

probe

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package probe resolves OS aliases to AMI IDs and produces BaseCapabilities for the resolver's Stage 1 (base resolution).

The key design principle: layers declare requirements against capabilities, not OS names. "glibc@>=2.34" not "al2023". A single layer artifact runs on AL2023, Rocky 9, Rocky 10, and RHEL 9 because they share the "rhel" family and all ship glibc >= 2.34.

Probes are cached by AMI ID. The same AMI probed twice returns the cached result. Probing a new AMI requires an EC2 launch (integration-only).

Index

Constants

This section is empty.

Variables

View Source
var OSABI = map[string]string{
	"al2023":   "linux-gnu-2.34",
	"rocky9":   "linux-gnu-2.34",
	"rocky10":  "linux-gnu-2.34",
	"ubuntu24": "linux-gnu-2.35",
}

OSABI maps a Strata OS name to its C runtime ABI identifier. The ABI encodes the libc family and minimum version that binaries built for this OS require. Layers tagged with a given abi are compatible with any OS that provides that ABI or newer.

Functions

func DetectSystemCompiler

func DetectSystemCompiler(abi string) (string, error)

DetectSystemCompiler returns the exact package identifier of the system C compiler, using the package manager appropriate for the ABI.

This is called by the probe script running on the actual AMI. The result is stored in BaseCapabilities.SystemCompiler and later copied to LayerManifest.BootstrapCompiler for Tier 0 bootstrap builds.

Output format by ABI:

linux-gnu-2.34 (rpm):  "gcc-11.4.1-2.amzn2023.0.1.x86_64"
linux-gnu-2.35 (dpkg): "gcc-11-11.4.0-1ubuntu1~22.04-amd64"

func KnownBaseCapabilities

func KnownBaseCapabilities(os, arch, amiID string) (*spec.BaseCapabilities, error)

KnownBaseCapabilities returns realistic BaseCapabilities for well-known Strata base OS images. Used to bootstrap the registry's probe cache and for testing without running actual probes.

func ResolveSSMParam

func ResolveSSMParam(os, arch string) (string, error)

ResolveSSMParam is the SSM parameter path for a given OS and arch. Returns an error if the OS or arch is not recognized.

Types

type AMIResult

type AMIResult struct {
	// AMIID is the resolved EC2 AMI ID.
	AMIID string
	// Capabilities are the probed capabilities of the AMI.
	Capabilities *spec.BaseCapabilities
}

AMIResult is the full result of resolving an OS alias, including both the AMI ID and the probed capabilities.

type Cache

type Cache interface {
	// Get returns the cached capabilities for amiID, if present.
	Get(ctx context.Context, amiID string) (*spec.BaseCapabilities, bool)

	// Set stores capabilities for amiID.
	Set(ctx context.Context, amiID string, caps *spec.BaseCapabilities) error
}

Cache stores and retrieves BaseCapabilities keyed by AMI ID. The real implementation is S3-backed. Use MemoryCache for testing.

type CapabilityStore

type CapabilityStore interface {
	GetBaseCapabilities(ctx context.Context, amiID string) (*spec.BaseCapabilities, error)
	StoreBaseCapabilities(ctx context.Context, caps *spec.BaseCapabilities) error
}

CapabilityStore is the subset of registry.Client used for probe caching. The real *registry.S3Client satisfies this interface.

type Client

type Client struct {
	Resolver Resolver
	Runner   Runner
	Cache    Cache
}

Client is the high-level probe client used by the resolver. It combines Resolver, Runner, and Cache into a single interface.

func (*Client) GetCapabilities

func (c *Client) GetCapabilities(ctx context.Context, os, arch string) (*spec.BaseCapabilities, error)

GetCapabilities returns the BaseCapabilities for the given OS alias and arch. It first resolves the OS alias to an AMI ID, then checks the cache, and only runs a probe if there is no cache hit.

func (*Client) Resolve

func (c *Client) Resolve(ctx context.Context, os, arch string) (*AMIResult, error)

Resolve is a convenience wrapper that resolves and probes in one call, returning the combined AMIResult for lockfile assembly.

type FakeRunner

type FakeRunner struct {
	// Capabilities maps AMI ID → BaseCapabilities.
	Capabilities map[string]*spec.BaseCapabilities
}

FakeRunner implements Runner with pre-configured capability results. It does not launch any EC2 instances.

func (*FakeRunner) ProbeAMI

func (r *FakeRunner) ProbeAMI(_ context.Context, amiID, _ string) (*spec.BaseCapabilities, error)

ProbeAMI returns the pre-configured capabilities for amiID.

type MemoryCache

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

MemoryCache implements Cache with an in-memory map. Safe for concurrent use only when accessed from a single goroutine. For testing.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache returns an empty MemoryCache.

func (*MemoryCache) Get

Get returns the cached capabilities for amiID.

func (*MemoryCache) Set

func (c *MemoryCache) Set(_ context.Context, amiID string, caps *spec.BaseCapabilities) error

Set stores capabilities for amiID.

type Resolver

type Resolver interface {
	// ResolveAMI resolves os + arch to an AMI ID.
	ResolveAMI(ctx context.Context, os, arch string) (amiID string, err error)
}

Resolver resolves an OS alias and arch to an AMI ID. The real implementation queries AWS SSM; use StaticResolver for testing.

type Runner

type Runner interface {
	// ProbeAMI launches a probe instance for amiID and returns the
	// discovered capabilities. The probe must complete within 90 seconds.
	ProbeAMI(ctx context.Context, amiID, arch string) (*spec.BaseCapabilities, error)
}

Runner executes a probe on a base AMI and returns its capabilities. The real implementation launches a t3.micro on EC2, runs the probe script, and terminates the instance. Use FakeRunner for testing.

type S3Cache

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

S3Cache implements Cache via a CapabilityStore. Cache entries are stored at s3://<bucket>/probes/<amiID>/capabilities.yaml (managed by registry.S3Client).

func NewS3Cache

func NewS3Cache(store CapabilityStore) *S3Cache

NewS3Cache returns an S3Cache backed by the given CapabilityStore.

func (*S3Cache) Get

func (c *S3Cache) Get(ctx context.Context, amiID string) (*spec.BaseCapabilities, bool)

Get returns the cached BaseCapabilities for amiID. Returns nil, false on a cache miss or any error — a missing entry is not treated as a fatal error.

func (*S3Cache) Set

func (c *S3Cache) Set(ctx context.Context, _ string, caps *spec.BaseCapabilities) error

Set stores caps in the backing CapabilityStore.

type SSMResolver

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

SSMResolver implements Resolver by querying AWS SSM Parameter Store. Each OS/arch pair maps to an SSM parameter path defined in osAliasSSM.

func NewSSMResolver

func NewSSMResolver(ctx context.Context) (*SSMResolver, error)

NewSSMResolver creates an SSMResolver using the default AWS credential chain.

func (*SSMResolver) ResolveAMI

func (r *SSMResolver) ResolveAMI(ctx context.Context, os, arch string) (string, error)

ResolveAMI queries SSM Parameter Store for the current AMI ID for the given OS and arch. Returns an error if the OS/arch pair is not recognized or if the SSM call fails.

type StaticResolver

type StaticResolver struct {
	// AMIs maps "os/arch" → AMI ID.
	AMIs map[string]string
}

StaticResolver implements Resolver with a fixed map of OS→AMI. Used for testing and for offline scenarios where SSM is unavailable.

func (*StaticResolver) ResolveAMI

func (r *StaticResolver) ResolveAMI(_ context.Context, os, arch string) (string, error)

ResolveAMI returns the AMI ID from the static map.

Jump to

Keyboard shortcuts

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