client

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AzureDiscoveryFingerprint

func AzureDiscoveryFingerprint(key schemas.Key, account AzureAccount) [32]byte

AzureDiscoveryFingerprint binds a snapshot to the effective authentication and account. Policies are applied when listing, so policy edits need no new ARM request.

Types

type AzureAccount

type AzureAccount struct {
	SubscriptionID string `json:"azure_subscription_id,omitempty"`
	ResourceGroup  string `json:"azure_resource_group,omitempty"`
	AccountName    string `json:"azure_account_name,omitempty"`
}

AzureAccount identifies the account used for management-plane deployment discovery.

func (AzureAccount) ResourceID

func (a AzureAccount) ResourceID() string

type AzureDiscoverySnapshot

type AzureDiscoverySnapshot struct {
	// RefreshID makes identical successes distinct, fencing delayed responses without a reservation.
	RefreshID   string `json:",omitempty"`
	Fingerprint [32]byte
	Names       []string
	BaseModels  map[string]string
}

AzureDiscoverySnapshot records only successful discovery, including a confirmed empty result. Keeping it with the key allows another replica to retain deployments during an ARM outage.

type Client

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

func New

func New(storage kclient.Client, codec ConfigCodec) (*Client, error)

New requires a codec so every client follows the configured credential policy. The codec may allow plaintext when application encryption is disabled.

func (*Client) CreateProvider

func (s *Client) CreateProvider(ctx context.Context, name string, provider Provider) error

CreateProvider creates an aggregate without replacing an existing provider or its keys. Callers handling concurrent creation must reload and mutate the winning aggregate.

func (*Client) DeleteKey

func (s *Client) DeleteKey(ctx context.Context, name, id string) error

DeleteKey requires an existing provider. An already-absent key is a successful no-op, but a missing provider or one removed during the update returns NotFound.

func (*Client) DeleteProvider

func (s *Client) DeleteProvider(ctx context.Context, name string) error

DeleteProvider removes the provider and its keys but retains referencing rules. Reconcilers must tolerate missing targets without silently bypassing routing policy.

func (*Client) DeleteRule

func (s *Client) DeleteRule(ctx context.Context, id string) error

func (*Client) GetProvider

func (s *Client) GetProvider(ctx context.Context, name string) (Provider, error)

func (*Client) GetProviderWithVersion

func (s *Client) GetProviderWithVersion(ctx context.Context, name string) (Provider, string, error)

GetProviderWithVersion binds discovery to the configuration observed before fetching ARM.

func (*Client) GetRule

func (s *Client) GetRule(ctx context.Context, id string) (tables.TableRoutingRule, error)

func (*Client) GetSettings

func (s *Client) GetSettings(ctx context.Context) (map[string]json.RawMessage, error)

func (*Client) Load

func (s *Client) Load(ctx context.Context) (LoadResult, error)

Load assembles independently versioned resources. It does not provide a transactional snapshot; runtime reconciliation must tolerate temporary missing dependencies and retry until the desired configuration converges. Resource watches drive reconciliation; the engine compares desired state against what it has successfully applied. Unreadable providers are omitted together with all their keys and reported in ProviderErrors. Collection, routing-rule, and settings errors are blocking: callers must discard the result when the returned error is non-nil.

func (*Client) MutateProvider

func (s *Client) MutateProvider(ctx context.Context, name string, change func(*Provider) error) error

MutateProvider attempts one atomic edit of the latest provider and its keys. Conflicts are returned to the caller, which can explicitly retry the operation. The callback must not have side effects because its write may fail.

func (*Client) MutateRule

func (s *Client) MutateRule(ctx context.Context, id string, change func(*tables.TableRoutingRule) error) error

MutateRule attempts one partial edit of the latest rule and returns conflicts to the caller. The callback must have no external side effects.

func (*Client) MutateSettings

func (s *Client) MutateSettings(ctx context.Context, change func(map[string]json.RawMessage) error) error

MutateSettings attempts one edit of the global settings singleton. Conflicts and concurrent creation (AlreadyExists) are returned for the caller to handle. The callback must not have externally visible side effects.

func (*Client) PutKey

func (s *Client) PutKey(ctx context.Context, name string, key schemas.Key) error

func (*Client) PutRule

func (s *Client) PutRule(ctx context.Context, rule tables.TableRoutingRule) error

PutRule replaces or creates a complete routing rule in one attempt. Callers decide whether to retry conflicts or concurrent creation (AlreadyExists).

func (*Client) SaveAzureDiscoveries

func (s *Client) SaveAzureDiscoveries(ctx context.Context, name, version string, snapshots map[string]AzureDiscoverySnapshot) error

SaveAzureDiscoveries publishes successful keys only if their pre-fetch resource version still matches. Never retry this write against a newer version: the controller must re-fetch ARM instead.

type Config

Config is a decoded desired configuration assembled from independent resources.

type ConfigCodec

type ConfigCodec interface {
	SealGatewayConfig(context.Context, string, []byte) ([]byte, error)
	OpenGatewayConfig(context.Context, string, []byte) ([]byte, error)
}

ConfigCodec protects complete configuration documents with Obot's credential encryption.

type LoadResult

type LoadResult struct {
	Config         Config
	ProviderErrors []ProviderLoadError
}

LoadResult separates usable desired state from providers that could not be read. A non-nil error from Load makes the entire result unusable.

type Provider

type Provider struct {
	AzureAccounts    map[string]AzureAccount           `json:",omitempty"`
	AzureDiscoveries map[string]AzureDiscoverySnapshot `json:",omitempty"`
	Config           schemas.ProviderConfig
	Keys             []schemas.Key
}

Provider is one atomic configuration aggregate: provider settings and its keys.

type ProviderLoadError

type ProviderLoadError struct {
	Provider     schemas.ModelProvider
	Namespace    string
	ResourceName string
	Err          error
}

ProviderLoadError identifies an unavailable aggregate and preserves its underlying error. It is distinct from an absent provider, whose resource was successfully observed missing.

func (ProviderLoadError) Error

func (e ProviderLoadError) Error() string

func (ProviderLoadError) Unwrap

func (e ProviderLoadError) Unwrap() error

Jump to

Keyboard shortcuts

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