resource

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgDef

type ArgDef struct {
	Name        string
	Description string
	Required    bool
}

ArgDef describes one argument accepted by Create.

type Deleter

type Deleter interface {
	Delete(ctx *agentops.AppContext, id string) error
}

Deleter is an optional interface for resources that support deletion.

type Doctor added in v0.6.0

type Doctor interface {
	Doctor(ctx *agentops.AppContext) ([]DoctorCheck, error)
}

Doctor is an optional interface for resources that support health checks.

type DoctorCheck added in v0.6.0

type DoctorCheck struct {
	Name     string `json:"name"`
	Status   string `json:"status"` // ok, warn, err
	Message  string `json:"message"`
	Severity string `json:"severity"`
}

DoctorCheck represents a single health check finding.

type FieldDef

type FieldDef struct {
	Name     string
	Type     string
	Required bool
}

FieldDef describes one field in a resource schema.

type Filter

type Filter map[string]string

Filter constrains which records are returned by List.

type PruneResult added in v0.6.0

type PruneResult struct {
	Name   string `json:"name"`
	Path   string `json:"path"`
	Action string `json:"action"` // removed, would_remove, skipped
	Reason string `json:"reason"`
}

PruneResult represents a single cleanup action taken or proposed.

type Pruner added in v0.6.0

type Pruner interface {
	Prune(ctx *agentops.AppContext, confirm bool) ([]PruneResult, error)
}

Pruner is an optional interface for resources that support cleanup of stale entries.

type Record

type Record struct {
	Kind    string         `json:"kind"`
	ID      string         `json:"id"`
	Fields  map[string]any `json:"fields"`
	RawPath string         `json:"raw_path,omitempty"`
}

Record is a generic representation of a resource instance.

type Registry

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

Registry holds all registered resource kinds.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty resource registry.

func (*Registry) All

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

All returns every registered resource, sorted alphabetically by kind.

func (*Registry) Get

func (r *Registry) Get(kind string) (Resource, bool)

Get retrieves a resource by kind name.

func (*Registry) Register

func (r *Registry) Register(res Resource)

Register adds a resource to the registry, keyed by its Schema().Kind.

type Resource

type Resource interface {
	Schema() ResourceSchema
	Create(ctx *agentops.AppContext, slug string, opts map[string]string) (*Record, error)
	List(ctx *agentops.AppContext, filter Filter) ([]Record, error)
	Get(ctx *agentops.AppContext, id string) (*Record, error)
}

Resource is the core interface every agentops resource kind must implement.

type ResourceSchema

type ResourceSchema struct {
	Kind        string
	Fields      []FieldDef
	Statuses    []string
	CreateArgs  []ArgDef
	Description string
}

ResourceSchema describes the shape and rules of a resource kind.

type Syncer

type Syncer interface {
	Sync(ctx *agentops.AppContext, id string) error
}

Syncer is an optional interface for resources that support external sync.

type Transitioner

type Transitioner interface {
	Transition(ctx *agentops.AppContext, id string, action string) (*Record, error)
}

Transitioner is an optional interface for resources with state machines.

type Validator

type Validator interface {
	Validate(ctx *agentops.AppContext, id string) (*agentops.DoctorReport, error)
}

Validator is an optional interface for resources that support compliance checks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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