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

targetmanager

package
v0.0.60 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLookup = errors.New("target lookup error")

Functions

func ConvertSdcpbDeviations2Deviations added in v0.0.57

func ConvertSdcpbDeviations2Deviations(ctx context.Context, devs []*sdcpb.WatchDeviationResponse) []configv1alpha1.ConfigDeviation

func NewTransactionError

func NewTransactionError(err error, recoverable bool) error

NewTransactionError creates a new TransactionError

func RunDryRunTransaction

func RunDryRunTransaction(
	ctx context.Context,
	c *config.Config,
	target *configv1alpha1.Target,
	intents []*sdcpb.TransactionIntent,
	dryrun bool,
) (runtime.Object, error)

runDryRunTransaction opens a short-lived data-server client, executes a TransactionSet dry-run with the provided intents, processes the result, and updates the Config status/conditions.

Types

type Collector

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

func NewCollector

func NewCollector(targetKey storebackend.Key, subscriptions *Subscriptions) *Collector

func (*Collector) GetPort

func (r *Collector) GetPort() uint

func (*Collector) IsRunning

func (r *Collector) IsRunning() bool

func (*Collector) NotifySubscriptionChanged

func (r *Collector) NotifySubscriptionChanged()

func (*Collector) SetPort

func (r *Collector) SetPort(port uint)

func (*Collector) Start

func (*Collector) Stop

func (r *Collector) Stop(ctx context.Context)

func (*Collector) StopSubscription

func (r *Collector) StopSubscription(ctx context.Context)

type DatastoreHandle

type DatastoreHandle struct {
	Key           storebackend.Key
	DatastoreName string
	Client        dsclient.Client
	Schema        *configv1alpha1.ConfigStatusLastKnownGoodSchema
	MarkRecovered func(bool) // callback into runtime
	Status        RuntimeStatus
}

type DeviationWatcher

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

func NewDeviationWatcher

func NewDeviationWatcher(
	key storebackend.Key,
	client client.Client,
	dsclient dsclient.Client,
) *DeviationWatcher

func (*DeviationWatcher) Start

func (r *DeviationWatcher) Start(ctx context.Context)

func (*DeviationWatcher) Stop

func (r *DeviationWatcher) Stop(ctx context.Context)

type LookupError

type LookupError struct {
	Message      string
	WrappedError error
}
var TargetLookupErr *LookupError

func (*LookupError) Error

func (e *LookupError) Error() string

func (*LookupError) Unwrap

func (e *LookupError) Unwrap() error

type Path

type Path struct {
	Path     string
	Interval int
}

type PathSubscriptions

type PathSubscriptions struct {
	Current *Subscription
	// AllSubscriptions list all the subscriptions that are in the system, the key is name of the subscription CR
	AllSubscriptions map[string]*Subscription
}

type RuntimeStatus

type RuntimeStatus struct {
	Phase        TargetPhase
	DSReady      bool
	DSStoreReady bool
	RunningHash  string
	Recovered    bool
	LastError    string
}

type Subscription

type Subscription struct {
	NSN         string // namespacedname of the CR that originated this subscription
	Name        string // name of the subscription
	Description *string
	Labels      map[string]string
	Enabled     bool
	Interval    int // 0 = onChange
	Encoding    invv1alpha1.Encoding
}

type Subscriptions

type Subscriptions struct {
	Paths store.Storer[*PathSubscriptions]
}

func NewSubscriptions

func NewSubscriptions() *Subscriptions

func (*Subscriptions) AddSubscription

func (r *Subscriptions) AddSubscription(subscription *invv1alpha1.Subscription) error

Add or update a subscription

func (*Subscriptions) DelSubscription

func (r *Subscriptions) DelSubscription(subscription *invv1alpha1.Subscription) error

func (*Subscriptions) GetPaths

func (r *Subscriptions) GetPaths() map[invv1alpha1.Encoding][]Path

func (*Subscriptions) HasSubscriptions

func (r *Subscriptions) HasSubscriptions() bool

type TargetManager

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

func NewTargetManager

func NewTargetManager(ds *dsmanager.DSConnManager, k8s client.Client) *TargetManager

func (*TargetManager) ApplyDesired

ApplyDesired is what your reconciler calls on each reconcile.

func (*TargetManager) ApplySubscription

func (m *TargetManager) ApplySubscription(ctx context.Context, sub *invv1alpha1.Subscription) ([]string, error)

func (*TargetManager) ClearDesired

func (m *TargetManager) ClearDesired(_ context.Context, key storebackend.Key)

ClearDesired is useful when the Target is being deleted or disabled.

func (*TargetManager) Delete

func (m *TargetManager) Delete(_ context.Context, key storebackend.Key)

func (*TargetManager) ForEachRuntime

func (m *TargetManager) ForEachRuntime(fn func(runtimeview.TargetRuntimeView))

func (*TargetManager) GetClient

GetClient returns a datastore-scoped DS client for this target, only if DS is ready AND datastore is ready.

func (*TargetManager) GetDatastore

func (m *TargetManager) GetDatastore(_ context.Context, key storebackend.Key) (*DatastoreHandle, bool)

func (*TargetManager) GetOrCreate

func (m *TargetManager) GetOrCreate(key storebackend.Key) *TargetRuntime

func (*TargetManager) GetRuntimeForTarget

func (m *TargetManager) GetRuntimeForTarget(_ context.Context, key storebackend.Key) *TargetRuntime

GetRuntimeForTarget returns the runtime if it exists (does NOT create one).

func (*TargetManager) RemoveSubscription

func (m *TargetManager) RemoveSubscription(ctx context.Context, sub *invv1alpha1.Subscription) error

type TargetPhase

type TargetPhase string
const (
	PhasePending           TargetPhase = "Pending"
	PhaseWaitingForDS      TargetPhase = "WaitingForDS"
	PhaseEnsuringDatastore TargetPhase = "EnsuringDatastore"
	PhaseRunning           TargetPhase = "Running"
	PhaseDegraded          TargetPhase = "Degraded"
	PhaseDeleting          TargetPhase = "Deleting"
)

type TargetRuntime

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

func (*TargetRuntime) Cache

func (t *TargetRuntime) Cache() cache.Cache

func (*TargetRuntime) DeleteSubscription

func (t *TargetRuntime) DeleteSubscription(ctx context.Context, sub *invv1alpha1.Subscription) error

func (*TargetRuntime) GetSchema

func (*TargetRuntime) Key

func (t *TargetRuntime) Key() storebackend.Key

func (*TargetRuntime) PromLabels

func (t *TargetRuntime) PromLabels() []prompb.Label

func (*TargetRuntime) SetDesired

func (*TargetRuntime) Start

func (r *TargetRuntime) Start(ctx context.Context)

func (*TargetRuntime) Status

func (t *TargetRuntime) Status() RuntimeStatus

func (*TargetRuntime) Stop

func (r *TargetRuntime) Stop()

func (*TargetRuntime) UpsertSubscription

func (t *TargetRuntime) UpsertSubscription(ctx context.Context, sub *invv1alpha1.Subscription) error

type TransactionError

type TransactionError struct {
	Recoverable bool
	Err         error
}

TransactionError represents an error with recoverability classification

func (*TransactionError) Error

func (e *TransactionError) Error() string

type TransactionResult

type TransactionResult struct {
	GlobalError    error
	IntentErrors   error
	GlobalWarnings []string
	Recoverable    bool
}

type Transactor

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

func NewTransactor

func NewTransactor(client client.Client, fieldManager string) *Transactor

func (*Transactor) ListConfigsPerTarget

func (r *Transactor) ListConfigsPerTarget(ctx context.Context, target *configv1alpha1.Target) (*config.ConfigList, error)

func (*Transactor) RecoverConfigs

func (r *Transactor) RecoverConfigs(ctx context.Context, target *configv1alpha1.Target, dsctx *DatastoreHandle) (*string, error)

func (*Transactor) SetConfigsTargetConditionForTarget

func (r *Transactor) SetConfigsTargetConditionForTarget(
	ctx context.Context,
	target *configv1alpha1.Target,
	targetCond condv1alpha1.Condition,
) error

func (*Transactor) Transact

func (r *Transactor) Transact(
	ctx context.Context,
	target *configv1alpha1.Target,
	dsctx *DatastoreHandle,
	targetCond condv1alpha1.Condition,
) (bool, error)

func (*Transactor) TransactionSet

func (r *Transactor) TransactionSet(
	ctx context.Context,
	dsctx *DatastoreHandle,
	req *sdcpb.TransactionSetRequest,
) (string, error)

Jump to

Keyboard shortcuts

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