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

source

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0, MIT Imports: 50 Imported by: 0

Documentation

Overview

Package source resolves opaque declarations into immutable cached content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputSchema added in v0.2.0

func InputSchema(t reflect.Type) *jsonschema.Schema

InputSchema describes native inputs. The catalog composer adds installed resolvers.

func NativeResolver added in v0.3.0

func NativeResolver(name string) bool

NativeResolver reports whether a built-in registration reserves the name.

func ResolverSchema added in v0.4.0

func ResolverSchema(name string) *jsonschema.Schema

ResolverSchema returns the schema owned by a built-in registration.

func Resolvers added in v0.4.0

func Resolvers() []string

Resolvers lists built-in resolver registrations.

func ValidateInput added in v0.3.0

func ValidateInput(input plugin.Input) error

ValidateInput validates a built-in declaration without acquisition.

Types

type Acquisition added in v0.9.0

type Acquisition struct {
	Download *Download
	Artifact *plugin.Artifact
	File     *fileRequest
	Evidence map[string]json.RawMessage
}

Acquisition describes exactly one transfer. Requests are transient; only the resolver's observation and the resulting content belong in durable state.

type Content added in v0.2.0

type Content struct {
	SHA256   string `json:"sha256" yaml:"sha256"`
	Filename string `json:"filename" yaml:"filename"`
	Tree     bool   `json:"tree,omitempty" yaml:"tree,omitempty"`
	Mode     uint32 `json:"mode" yaml:"mode"`
}

Content identifies bytes and their filesystem representation. Tree bytes are a canonical TAR retaining file and directory modes and confined symlink targets.

type Discovery added in v0.4.0

type Discovery struct {
	Content     *Content
	Version     string
	ContentRoot string
	Evidence    map[string]json.RawMessage
	Observation json.RawMessage
	Immutable   bool
}

Discovery is a resolver's current observation. Immutable promises that the observation always fetches the same bytes.

type Download added in v0.9.0

type Download struct {
	plugin.Download

	Do func(*http.Request) (*http.Response, error)

	// AllowHTTPRedirect permits public mirrors only with an independently pinned SHA-256.
	AllowHTTPRedirect bool
}

Download allows an in-process resolver to supply a transport, such as an OCI challenge client. Ordinary requests use the manager's redirect-safe client.

type Entry

type Entry struct {
	Version         int                        `json:"version" yaml:"version"`
	Resolver        string                     `json:"resolver" yaml:"resolver"`
	ResolverVersion string                     `json:"resolver_version" yaml:"resolver_version"`
	Declaration     string                     `json:"declaration" yaml:"declaration"`
	Observation     json.RawMessage            `json:"observation" yaml:"observation"`
	Content         Content                    `json:"content" yaml:"content"`
	InputVersion    string                     `json:"input_version,omitempty" yaml:"input_version,omitempty"`
	ContentRoot     string                     `json:"content_root,omitempty" yaml:"content_root,omitempty"`
	Evidence        map[string]json.RawMessage `json:"evidence,omitempty" yaml:"evidence,omitempty"`
}

Entry is the common lock envelope. Observation belongs to the named resolver; Evidence is reviewed JSON passed to consumers. Both must be nonsecret.

func (Entry) Equal added in v0.2.0

func (entry Entry) Equal(other Entry) bool

Equal compares semantic lock state, including JSON observations and evidence.

func (Entry) MarshalYAML added in v0.2.0

func (entry Entry) MarshalYAML() (any, error)

MarshalYAML preserves resolver JSON as ordinary YAML objects, including exact integer values, rather than serializing RawMessage as a byte array.

func (*Entry) UnmarshalYAML added in v0.2.0

func (entry *Entry) UnmarshalYAML(node *yaml.Node) error

func (Entry) Validate added in v0.2.0

func (entry Entry) Validate() error

Validate checks only the shared lock envelope; resolver-owned observations are interpreted by their resolver when content must be fetched again.

type Manager

type Manager struct {
	Store   *cas.Store
	Root    string
	Client  *http.Client
	Offline bool
	// GitHubToken authenticates the release lookups of GitHub sources that
	// declare no token. Downloads never carry it.
	GitHubToken string
	// GitHubAppToken is the renewing github.com App credential used for
	// release lookups when neither the source nor the run supplies a token.
	GitHubAppToken oauth2.TokenSource
	// contains filtered or unexported fields
}

Manager owns acquisition and cached content, independently of resource kinds.

func New

func New(store *cas.Store, root string, offline bool) *Manager

New creates a manager with bounded HTTP lifetimes and credential-safe redirects.

func (*Manager) Declaration added in v0.2.0

func (m *Manager) Declaration(input plugin.Input) (string, string, error)

Declaration validates the declaration and returns its resolver version and credential-independent hash, without resolving or acquiring content.

func (*Manager) FetchLocked added in v0.2.0

func (m *Manager) FetchLocked(ctx context.Context, input plugin.Input, entry Entry) (bool, error)

FetchLocked ensures locked content is available, fetching it when absent. Cached bytes are verified when consumed. Remote discovery is not refreshed; local inputs are always rehashed. The source index keeps whatever the fetch returned, so a source that moved on is proposed by the next refresh without another download.

func (*Manager) InputChanged added in v0.9.0

func (m *Manager) InputChanged(input plugin.Input, changed []string) (bool, error)

InputChanged asks the resolver about project changes. Local executable resolvers without declared dependencies conservatively depend on the project.

func (*Manager) IsLocal added in v0.2.0

func (m *Manager) IsLocal(name string) bool

IsLocal reports whether the resolver must reobserve filesystem or other local inputs rather than trusting a previously cached object.

func (*Manager) Refresh added in v0.3.0

func (m *Manager) Refresh(ctx context.Context, input plugin.Input, locked Entry) (Entry, bool, error)

Refresh observes a declaration again and reports whether the cache already held its content. An immutable observation takes its content from the source index, or from the reviewed entry when it records the same observation; anything else is fetched, and a mutable HTTP source is asked conditionally with the validators the index kept. Local inputs are read in full every time.

func (*Manager) Register added in v0.2.0

func (m *Manager) Register(name string, resolver Resolver) error

Register adds a resolver without shadowing native or previously registered inputs.

func (*Manager) Resolve

func (m *Manager) Resolve(ctx context.Context, input plugin.Input) (Entry, error)

Resolve observes a declaration without a reviewed entry.

type Resolver added in v0.2.0

type Resolver struct {
	Version     string
	Identity    string
	Local       bool
	Fingerprint func(plugin.Input) (string, error)
	Discover    func(context.Context, plugin.Input) (Discovery, error)
	Schema      *jsonschema.Schema
	Acquire     func(context.Context, plugin.Input, json.RawMessage) (Acquisition, error)
	Changed     func(plugin.Input, []string) (bool, error)
}

Resolver owns its declaration and stable observation. Local resolvers are reobserved even with a warm cache. Fingerprint must exclude credentials. Identity names the implementation in the source index and defaults to Version. Acquire keeps returned artifact paths available until the manager returns.

Jump to

Keyboard shortcuts

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