scheme

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scheme is the CLI dispatch layer over v1alpha1: it owns the alias-flexible Kind lookup table (so `arctl get mcp` and `arctl get mcpserver` both resolve), per-kind table-render metadata, and the per-kind cobra→registry-client callbacks (`Get`, `List`, `Delete`, `ToYAMLFunc`). YAML decode itself flows through pkg/api/v1alpha1.Scheme — this package holds only CLI-specific concerns.

Kinds are registered at package init by the declarative package. The table is global, populated once, and never mutated afterwards (no SetRegistry hook — there is no current caller that needs to swap it). Aliases collide → panic at boot.

Index

Constants

View Source
const APIVersion = v1alpha1.GroupVersion

APIVersion is the canonical apiVersion string for arctl declarative YAML files.

Variables

View Source
var ErrUnknownKind = errors.New("unknown kind")

ErrUnknownKind is returned by Lookup when no Kind is registered under the given name or alias.

Functions

func DecodeBytes

func DecodeBytes(b []byte) ([]v1alpha1.Object, error)

DecodeBytes parses one or more declarative YAML documents into typed v1alpha1.Object envelopes. Returns an error if any document has an unknown Scheme kind or fails to decode. Kinds do not need a CLI dispatch entry here: downstream builds can register server-side-only kinds with v1alpha1.Default and still use `arctl apply -f`.

Status is reset to nil before returning so `arctl get -o yaml | apply -f -` stays apply-safe even when the source YAML contained server-managed status.

func DecodeFile

func DecodeFile(path string) ([]v1alpha1.Object, error)

DecodeFile reads a YAML file and decodes it into v1alpha1.Object envelopes.

func IsEnvelopeYAML

func IsEnvelopeYAML(data []byte) bool

IsEnvelopeYAML reports whether the given bytes look like a declarative ar.dev/v1alpha1 envelope. Malformed YAML returns false so callers can surface the real parse error from a downstream loader.

Pins on the canonical apiVersion (ar.dev/v1alpha1) — generic K8s-style manifests with an unrelated apiVersion (kagent CRDs, k8s core types, etc.) would otherwise misclassify as envelopes and route to the wrong loader.

func Register

func Register(k *Kind)

Register adds a Kind to the global lookup table. Panics if any of Kind / Plural / Aliases collides with an already-registered entry — callers are expected to register at package init, where a panic is the right fail-fast behavior.

Types

type Column

type Column struct {
	Header string
}

type DeleteAllTagsFunc

type DeleteAllTagsFunc func(ctx context.Context, c *client.Client, name string) error

DeleteAllTagsFunc soft-deletes every live tag of a single (name) in one server round-trip. Set only on taggable artifact kinds. Nil for kinds whose identity is not tagged.

type DeleteFunc

type DeleteFunc func(ctx context.Context, c *client.Client, name, tag string) error

DeleteFunc deletes a single (name, tag) of the kind.

type GetFunc

type GetFunc func(ctx context.Context, c *client.Client, name, tag string) (any, error)

type Kind

type Kind struct {
	Kind          string
	Plural        string
	Aliases       []string
	ListFunc      ListFunc
	RowFunc       RowFunc
	ToYAMLFunc    ToYAMLFunc
	Get           GetFunc
	Delete        DeleteFunc
	ListTags      ListTagsFunc
	DeleteAllTags DeleteAllTagsFunc

	TableColumns []Column
}

func All

func All() []*Kind

All returns every registered Kind in registration order.

func Lookup

func Lookup(name string) (*Kind, error)

Lookup resolves a user-typed name (canonical Kind, plural, or alias — case-insensitive) to its registered *Kind, or ErrUnknownKind.

type ListFunc

type ListFunc func(context.Context, *client.Client, ListOpts) ([]any, error)

type ListOpts

type ListOpts struct {
	// Tag, when set, restricts the list to rows with this tag value
	// (tagged content kinds only). Mutually exclusive with LatestOnly.
	Tag string
	// LatestOnly restricts the list to the literal "latest" tag (tagged
	// content kinds) or the latest mutable-object row.
	LatestOnly bool
	// Origin filters Deployment rows by provenance. Recognized values:
	// "managed", "discovered", "all" (both), and "" (unset — the Deployment
	// list defaults to managed to preserve historical behavior). The
	// Deployment ListFunc translates these to the server filter; only the
	// Deployment kind honors this — other kinds ignore it.
	Origin string
}

ListOpts are CLI-facing filters forwarded to the per-kind ListFunc. Empty fields mean "no filter" — the default `arctl get <plural>` lists every row of the kind.

type ListTagsFunc

type ListTagsFunc func(ctx context.Context, c *client.Client, name string) ([]any, error)

ListTagsFunc returns every live tag row for a single (name). Set only on taggable artifact kinds (Agent, MCPServer, Skill, etc.). Nil for kinds whose identity is not tagged (Deployment, Runtime) — callers must check for nil and reject `--all-tags` cleanly.

type Registry

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

Registry is an isolated Kind lookup table.

func NewRegistry

func NewRegistry(kinds ...*Kind) *Registry

NewRegistry returns an isolated registry populated with the given kinds.

func (*Registry) All

func (r *Registry) All() []*Kind

All returns every Kind in registration order.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (*Kind, error)

Lookup resolves a user-typed name in this registry.

func (*Registry) Register

func (r *Registry) Register(k *Kind)

Register adds a Kind to the registry. Panics if any of Kind / Plural / Aliases collides with an already-registered entry.

type RowFunc

type RowFunc func(any) []string

type ToYAMLFunc

type ToYAMLFunc func(any) any

Jump to

Keyboard shortcuts

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