cli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli holds what strata's commands share: configuration loading through viper, opening the index, and output helpers. Commands in cmd/ stay thin and call into it.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Build information, set with -ldflags at release time.

Functions

func Close

func Close(svc *service.Service, err *error)

Close closes a service's store, keeping the first error.

func ConfigPaths

func ConfigPaths() []string

ConfigPaths returns the places a config file is looked for, in order: $XDG_CONFIG_HOME/strata/strata.yaml, ~/.config/strata/strata.yaml, ~/.strata.yaml and ./strata.yaml.

func OneOf

func OneOf(flag, value string, allowed ...string) error

OneOf checks a flag value against allowed choices.

func Out

func Out(cmd *cobra.Command) io.Writer

Out returns the command's output writer.

func Release

func Release(closeFn func() error, err *error)

Release calls a Backend close function, keeping the first error.

func Spin

func Spin(ctx context.Context, cmd *cobra.Command, title string, action func(context.Context) error) error

Spin runs action with a spinner when stderr is a terminal, and plainly otherwise. STRATA_ACCESSIBLE=1 switches to huh's screen-reader mode.

Types

type Backend

type Backend interface {
	Explain(ctx context.Context, ref, platform string, history bool) (*service.Explanation, error)
	Ancestry(ctx context.Context, ref, platform string) (*graph.Graph, error)
	Descendants(ctx context.Context, ref string, opts service.DescendantOptions) (*service.DescendantResult, error)
	Query(ctx context.Context, opts service.QueryOptions) (*service.Table, error)
	QueryGraph(ctx context.Context, filter string, budget int) (*graph.Graph, error)
	Stale(ctx context.Context, groupBy string) (*service.Table, error)
	Roots(ctx context.Context) ([]service.Root, error)
	Summary(ctx context.Context, groupBy string) (*service.Summary, error)
	Cleanup(ctx context.Context, opts service.CleanupOptions) (*service.Cleanup, error)
	Lifecycles(ctx context.Context, opts service.LifecycleOptions) ([]service.Lifecycle, error)
}

Backend answers read queries, from a local index or a running server. *service.Service satisfies it.

type Remote

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

Remote is a Backend over strata's HTTP API.

func NewRemote

func NewRemote(url, authHeader string) (*Remote, error)

NewRemote returns a client for a strata server. authHeader, if set, is sent with the current user name, for servers behind a trusted-header proxy in development.

func (*Remote) Ancestry

func (r *Remote) Ancestry(ctx context.Context, ref, platform string) (*graph.Graph, error)

Ancestry fetches an ancestry graph.

func (*Remote) Cleanup added in v0.3.0

func (r *Remote) Cleanup(ctx context.Context, opts service.CleanupOptions) (*service.Cleanup, error)

Cleanup fetches the deletion candidates.

func (*Remote) Descendants

func (r *Remote) Descendants(ctx context.Context, ref string, opts service.DescendantOptions) (*service.DescendantResult, error)

Descendants fetches a descendant graph. A versions file is local-only.

func (*Remote) Explain

func (r *Remote) Explain(ctx context.Context, ref, platform string, history bool) (*service.Explanation, error)

Explain resolves the ref, then fetches the image.

func (*Remote) Healthy

func (r *Remote) Healthy(ctx context.Context) bool

Healthy reports whether the server answers its health check.

func (*Remote) Lifecycles added in v0.3.0

func (r *Remote) Lifecycles(ctx context.Context, opts service.LifecycleOptions) ([]service.Lifecycle, error)

Lifecycles fetches generated ECR lifecycle policies.

func (*Remote) Query

func (r *Remote) Query(ctx context.Context, opts service.QueryOptions) (*service.Table, error)

Query runs a filter on the server.

func (*Remote) QueryGraph

func (r *Remote) QueryGraph(ctx context.Context, filter string, budget int) (*graph.Graph, error)

QueryGraph draws a filter's matches on the server.

func (*Remote) Roots

func (r *Remote) Roots(ctx context.Context) ([]service.Root, error)

Roots fetches the root bases.

func (*Remote) Stale

func (r *Remote) Stale(ctx context.Context, groupBy string) (*service.Table, error)

Stale fetches the staleness report.

func (*Remote) Summary

func (r *Remote) Summary(ctx context.Context, groupBy string) (*service.Summary, error)

Summary fetches footprint metrics.

type State

type State struct {
	V      *viper.Viper
	Config config.Config
	Logger *slog.Logger
}

State is the loaded configuration for one command run.

func Load

func Load(cmd *cobra.Command, cfgFile string) (*State, error)

Load reads the config file, environment and the running command's flags. Precedence is flag, then STRATA_* environment, then file, then defaults. cfgFile overrides the search path.

func (*State) Backend

func (s *State) Backend(ctx context.Context) (Backend, func() error, error)

Backend returns the local index, or a remote server when --server is set or the index is locked by a running strata serve. The returned close function releases it.

func (*State) Open

func (s *State) Open(ctx context.Context) (*service.Service, error)

Open opens the index and returns a service configured from the config. The caller closes the store.

Jump to

Keyboard shortcuts

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