Documentation
¶
Overview ¶
Package runtime contains the logic for reconciling a directory of manifests with a store and status.
Index ¶
- func DecodeSpec[T any](m map[string]any) (T, error)
- func HashSpec(m map[string]any) string
- func NewCondition(t, status, reason, msg string) map[string]any
- func ParseYAML(data []byte) ([]api.Unstructured, error)
- func ReconcileDirAndPersist(ctx context.Context, scheme *Scheme, dir string, store *Store, ...) error
- func Register[T api.Spec](s *Scheme, kind string, bind func(api.Unstructured) (T, error), ...)
- func ShortSummary(phase string, drifted, outOfSync bool) string
- type ListItem
- type Plan
- type Scheme
- func (s *Scheme) Delete(ctx context.Context, kind string, meta api.ResourceMeta) (map[string]any, error)
- func (s *Scheme) Diff(ctx context.Context, u api.Unstructured, observed map[string]any) (bool, map[string]any, error)
- func (s *Scheme) Observe(ctx context.Context, kind string, meta api.ResourceMeta) (map[string]any, error)
- func (s *Scheme) Reconcile(ctx context.Context, u api.Unstructured) (map[string]any, error)
- func (s *Scheme) Register(kind string, bind binder, ctrl controllerAny)
- func (s *Scheme) SupportedKinds() []string
- type Status
- type StatusStore
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeSpec ¶
DecodeSpec decodes a map to a struct of type T. It uses the mapstructure library.
func NewCondition ¶
NewCondition creates a new condition map.
func ParseYAML ¶
func ParseYAML(data []byte) ([]api.Unstructured, error)
ParseYAML parses YAML data into a slice of api.Unstructured objects. It uses the yaml library.
func ReconcileDirAndPersist ¶
func ReconcileDirAndPersist(ctx context.Context, scheme *Scheme, dir string, store *Store, status *StatusStore) error
ReconcileDirAndPersist applies manifests AND persists canonical manifests and status. It also prunes resources that are tracked in the Store but no longer present in `dir`.
func Register ¶
func Register[T api.Spec](s *Scheme, kind string, bind func(api.Unstructured) (T, error), ctrl api.Controller[T])
Register registers a controller and binder for a given kind, where the spec is of type T.
func ShortSummary ¶
ShortSummary returns a short summary of the status phase, considering drift and out-of-sync status.
Types ¶
type ListItem ¶
type ListItem struct{ Kind, Name, Path string }
ListItem lists all resources in the store.
type Plan ¶
type Plan struct {
Order []api.Unstructured // topo-ordered resources
}
Plan constructs a DAG using explicit dependsOn edges plus implicit waves.
type Scheme ¶
type Scheme struct {
// contains filtered or unexported fields
}
Scheme is a registry of controllers and binders.
func NewScheme ¶
func NewScheme() *Scheme
NewScheme creates a new Scheme with no registered controllers or binders.
func (*Scheme) Delete ¶
func (s *Scheme) Delete(ctx context.Context, kind string, meta api.ResourceMeta) (map[string]any, error)
Delete deletes a resource using the registered controller and binder.
func (*Scheme) Diff ¶
func (s *Scheme) Diff(ctx context.Context, u api.Unstructured, observed map[string]any) (bool, map[string]any, error)
Diff diffs a resource using the registered controller and binder.
func (*Scheme) Observe ¶
func (s *Scheme) Observe(ctx context.Context, kind string, meta api.ResourceMeta) (map[string]any, error)
Observe observes a resource using the registered controller and binder.
func (*Scheme) Reconcile ¶
Reconcile reconciles a resource using the registered controller and binder.
func (*Scheme) SupportedKinds ¶
SupportedKinds returns a list of all supported kinds.
type Status ¶
type Status struct { ObservedGeneration int64 `json:"observedGeneration"` LastReconciled time.Time `json:"lastReconciled,omitempty"` Phase string `json:"phase,omitempty"` // Ready|Reconciling|Degraded|Error|Deleted|Unknown Conditions []map[string]any `json:"conditions,omitempty"` Summary string `json:"summary,omitempty"` Sync struct { DesiredHash string `json:"desiredHash,omitempty"` LastAppliedHash string `json:"lastAppliedHash,omitempty"` OutOfSync bool `json:"outOfSync"` } `json:"sync"` Drift struct { Drifted bool `json:"drifted"` Details map[string]any `json:"details,omitempty"` } `json:"drift"` Extra map[string]any `json:"extra,omitempty"` }
Status is a representation of the status of a resource.
type StatusStore ¶
type StatusStore struct {
Root string
}
StatusStore is a store for resource statuses.
func NewStatusStore ¶
func NewStatusStore(root string) *StatusStore
NewStatusStore creates a new StatusStore with the specified root directory.
func (*StatusStore) Delete ¶
func (s *StatusStore) Delete(kind, name string) error
Delete deletes the status of a resource from the store.
func (*StatusStore) Ensure ¶
func (s *StatusStore) Ensure(kind string) error
Ensure ensures that the directory for the given kind exists.
type Store ¶
type Store struct{ Root string }
Store is a store for resource manifests.
func (*Store) EnsureKindDir ¶
EnsureKindDir ensures that the directory for the given kind exists.