chart

package
v0.2.10 Latest Latest
Warning

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

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

Documentation

Overview

Package chart knows the agent chart: where it lives, which version a Flux OCIRepository tracking the configured semver range resolves to right now, and the values.schema.json of that version — the contract every agent's values are validated against before anything is applied. The registry is the source of truth; an embedded copy of the schema (the chart version the service was built against) is the fallback when the registry cannot be reached, and the API says which one is in use.

Index

Constants

View Source
const (
	SourceRegistry = "registry"
	SourceEmbedded = "embedded"
)

Source names where a schema came from.

View Source
const EmbeddedSchemaVersion = "0.5.2"

EmbeddedSchemaVersion is the agent chart version whose values.schema.json is compiled into the binary (internal/chart/embedded/).

Variables

This section is empty.

Functions

func Latest

func Latest(tags []string, constraint string) (string, error)

Latest picks the highest stable version among tags that satisfies the constraint, the way Flux's OCIRepository ref.semver does (Masterminds semver; pre-releases are excluded unless the range names one).

Types

type Info

type Info struct {
	// OCIURL is the chart's OCI URL as the OCIRepository carries it.
	OCIURL string `json:"ociUrl"`
	// Semver is the range the OCIRepository tracks (x.x.x: every release).
	Semver string `json:"semver"`
	// LatestVersion is the newest published version inside that range, or ""
	// when the registry could not be read.
	LatestVersion string `json:"latestVersion,omitempty"`
	// SchemaVersion is the chart version whose values.schema.json validates
	// agent values right now.
	SchemaVersion string `json:"schemaVersion"`
	// SchemaSource is registry or embedded.
	SchemaSource string `json:"schemaSource"`
	// ResolvedAt is when the registry was last read successfully.
	ResolvedAt *time.Time `json:"resolvedAt,omitempty"`
	// Error is the last registry error, when the embedded fallback is in use.
	Error string `json:"error,omitempty"`
}

Info is what GET /info reports about the chart.

type Reference

type Reference struct {
	// Host is the registry host, e.g. gsoci.azurecr.io.
	Host string
	// Repository is the path within the registry, e.g. charts/giantswarm/agent.
	Repository string
	// Insecure selects plain HTTP (tests).
	Insecure bool
}

Reference is a parsed oci:// chart URL.

func ParseReference

func ParseReference(ociURL string) (Reference, error)

ParseReference parses oci://<host>/<repository>.

func (Reference) Name

func (r Reference) Name() string

Name is the chart name: the last path segment of the repository.

type Registry

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

Registry talks to one OCI registry.

func NewRegistry

func NewRegistry(client *http.Client) *Registry

NewRegistry builds a client with sensible timeouts.

func (*Registry) ListTags

func (c *Registry) ListTags(ctx context.Context, ref Reference) ([]string, error)

ListTags returns the repository's tags.

func (*Registry) ReadChartFile

func (c *Registry) ReadChartFile(ctx context.Context, ref Reference, tag, file string) ([]byte, error)

ReadChartFile pulls the chart at tag and returns the named file from the archive (relative to the chart root, e.g. values.schema.json).

type Resolver

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

Resolver reads the chart from the registry and caches the result.

func NewResolver

func NewResolver(ociURL, semverRange string, refresh time.Duration, registry *Registry, log *slog.Logger) (*Resolver, error)

NewResolver builds a resolver for ociURL tracking semverRange, re-reading the registry every refresh.

func (*Resolver) Info

func (r *Resolver) Info(ctx context.Context) Info

Info reports the resolution state without forcing a registry read.

func (*Resolver) Name

func (r *Resolver) Name() string

Name is the chart name (the OCIRepository is named after it).

func (*Resolver) OCIURL

func (r *Resolver) OCIURL() string

OCIURL is the configured chart URL.

func (*Resolver) Schema

func (r *Resolver) Schema(ctx context.Context) Schema

Schema returns the current schema: the registry's for the latest version in range when it can be read (cached for the refresh period), else the embedded copy. It never fails: validation must work offline.

func (*Resolver) SemverRange

func (r *Resolver) SemverRange() string

SemverRange is the configured range.

type Schema

type Schema struct {
	Document any
	Version  string
	Source   string
}

Schema is a parsed values.schema.json with its provenance.

func EmbeddedSchema

func EmbeddedSchema() Schema

EmbeddedSchema is the compiled-in values.schema.json of the agent chart at EmbeddedSchemaVersion — the offline fallback, and what tests validate with.

Jump to

Keyboard shortcuts

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