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

agentidentity

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package agentidentity keeps a host-side record of ERC-8004 AgentIdentity CRs. The CR (and in particular status.registrations — the per-chain agentId) lives only in etcd; losing it on cluster recreation means the next registration mints a NEW on-chain identity instead of updating the existing one. The record at $OBOL_CONFIG_DIR/identity/<ns>__<name>.json is the single source of truth across recreation: the CLI writes it on every AgentIdentity write, `obol stack export` refreshes it from the cluster (picking up controller-side registrations) and ships it inside the config tree, and record replay (internal/replay) re-applies it.

Index

Constants

This section is empty.

Variables

View Source
var NewKube = func(cfg *config.Config) Kube {
	bin, kc := kubectl.Paths(cfg)
	return kubectlKube{bin: bin, kubeconfig: kc}
}

NewKube returns the kubectl-backed client for cfg's cluster.

Functions

func ApplySpec

func ApplySpec(k Kube, rec *Record) error

ApplySpec creates/updates the CR from rec's spec (status is a subresource and is never persisted by apply). Stamps the obol managed-by label.

func Mirror

func Mirror(cfg *config.Config, k Kube, ns, name string) error

Mirror copies the live CR ns/name to its record. A missing CR leaves any existing record untouched (the record is what restores it).

func MirrorAll

func MirrorAll(cfg *config.Config, k Kube) (int, error)

MirrorAll records every AgentIdentity in the cluster. Used by `obol stack export` so the archive's config tree carries registrations the serviceoffer-controller wrote since the last CLI write. CRD absent or no CRs => nothing recorded, no error.

func PatchStatus

func PatchStatus(k Kube, rec *Record) error

PatchStatus merge-patches status.registrations. An empty slice is sent explicitly so a patch can clear the field.

func Path

func Path(cfg *config.Config, ns, name string) string

Path returns the record path for ns/name.

func Save

func Save(cfg *config.Config, rec *Record) error

Save writes the record (spec + status only; no server-managed metadata).

Types

type Kube

type Kube interface {
	Output(args ...string) (string, error)
	Run(args ...string) error
	// Apply applies a JSON/YAML manifest.
	Apply(data []byte) error
}

Kube is the slice of kubectl this package needs; swapped in tests.

type Metadata

type Metadata struct {
	Name      string            `json:"name"`
	Namespace string            `json:"namespace"`
	Labels    map[string]string `json:"labels,omitempty"`
}

Metadata is the subset of ObjectMeta the CLI reads and writes.

type Outcome

type Outcome string

Outcome describes what Reconcile did for one record.

const (
	OutcomeCreated   Outcome = "created"   // CR was missing; spec applied + status seeded
	OutcomeSeeded    Outcome = "seeded"    // CR existed without registrations; status seeded
	OutcomeRefreshed Outcome = "refreshed" // cluster had newer registrations; record updated
	OutcomeUnchanged Outcome = "unchanged"
)

func ReconcileOne

func ReconcileOne(cfg *config.Config, k Kube, rec *Record) (Outcome, error)

ReconcileOne converges one record with the cluster:

  • CR missing: apply spec, seed status from the record.
  • CR present without registrations: seed status from the record.
  • CR present with registrations: the cluster wins (the controller may have registered on another chain since the last CLI write) and the record is refreshed from it.

type Record

type Record struct {
	APIVersion string                          `json:"apiVersion"`
	Kind       string                          `json:"kind"`
	Metadata   Metadata                        `json:"metadata"`
	Spec       monetizeapi.AgentIdentitySpec   `json:"spec"`
	Status     monetizeapi.AgentIdentityStatus `json:"status,omitempty"`
}

Record is the JSON-shaped view of an AgentIdentity used both for kubectl round-trips and as the on-disk record.

func Get

func Get(k Kube, ns, name string) (*Record, error)

Get reads the live CR; (nil, nil) when it does not exist.

func List

func List(cfg *config.Config) ([]*Record, error)

List returns every recorded identity, sorted by file name.

func Load

func Load(cfg *config.Config, ns, name string) (*Record, error)

Load reads the record for ns/name; (nil, nil) when none exists.

func New

func New(ns, name string) *Record

New returns an empty record for ns/name.

Jump to

Keyboard shortcuts

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