data

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package data is the TUI's read-path data seam. It exposes a small, provider- neutral Source interface that the browser and diff pages depend on, plus concrete implementations backed by the internal/usecase/{param,secret} use cases over a provider.Store. Keeping the pages behind this interface lets a test drive them with a providermock-backed Source (mirroring how production resolves a store from the registry+scope) without touching a real cloud.

The neutral output types here are deliberately pre-formatted for display (type labels, dates as strings) so a page renders them verbatim and never reaches back into the usecase/domain packages.

Index

Constants

This section is empty.

Variables

View Source
var ErrRestoreUnsupported = stringError("restore is not supported by this provider")

ErrRestoreUnsupported is returned by Restore when the resolved store does not implement provider.Restorer (the capability gate should prevent reaching it).

Functions

This section is empty.

Types

type ApplyEntryResult

type ApplyEntryResult struct {
	Name      string
	Namespace string
	// Status is "created" / "updated" / "deleted" / "failed".
	Status string
	// Error is the cloud-write failure (empty on success).
	Error string
	// UnstageError is set when the cloud write succeeded but the entry could not
	// be cleared from staging afterwards — the page must always surface it.
	UnstageError string
}

ApplyEntryResult is one entry's apply outcome.

type ApplyTagResult

type ApplyTagResult struct {
	Name         string
	Namespace    string
	Adds         []Tag
	Removes      []string
	Error        string
	UnstageError string
}

ApplyTagResult is one item's tag-apply outcome.

type Detail

type Detail struct {
	Name  string
	Value string
	// Secret reports whether Value must be masked by default.
	Secret bool
	// Meta are the capability-gated metadata rows (version/type/dates/etc.),
	// pre-built so the pane renders them verbatim.
	Meta []MetaRow
	// State is the per-version lifecycle state (Google Cloud / Azure Key Vault),
	// empty when the version carries staging labels instead.
	State string
	// StagingLabels are the AWS staging labels of the current version, empty when
	// the version carries a State instead. Never infer one from the other (#419).
	StagingLabels []string
	Description   string
	Tags          []Tag
	Namespace     string
	// TypeLabel is the entry's display value type (e.g. "SecureString"), so the
	// edit dialog can preserve the type on an update. Empty for services with no
	// value type (secret, App Configuration).
	TypeLabel string
	// ARN is the Secrets Manager ARN surfaced from the entry's Extra metadata,
	// empty for providers that expose none.
	ARN string
}

Detail is the current-version detail of one entry.

type DiffContent

type DiffContent struct {
	OldLabel string
	NewLabel string
	OldValue string
	NewValue string
	// Secret reports whether the two values are secrets and must be masked before
	// diffing, so a secret diff never renders a revealed value. The source is the
	// authority on secret-ness (the browser's OpenDiff carries no such flag).
	Secret bool
}

DiffContent carries the two raw version values and their labels so the diff page can compute (and re-compute, for parse-json) the unified diff itself.

type HistoryRow

type HistoryRow struct {
	// Version is the raw provider version identifier used to re-fetch/diff (a
	// numeric string for param, a version id for secret).
	Version string
	// Label is the display form ("#14" for param, a shortened id for secret).
	Label string
	// Date is the pre-formatted creation/modification date, empty when unknown.
	Date          string
	IsCurrent     bool
	State         string
	StagingLabels []string
	// Value is this version's raw value, fetched alongside the metadata so the
	// history can show what the value was at each revision (GUI parity). Empty when
	// the value could not be fetched. It is masked in the UI when Secret is set.
	Value string
	// Secret reports whether Value is secret material and must be masked by default
	// (a secret-service value, or a SecureString param value).
	Secret bool
	// Tags are this version's tags (Azure Key Vault per-version tags only).
	Tags []Tag
}

HistoryRow is one version row in the detail history.

type Item

type Item struct {
	Name string
	// Value is the entry's value when the list was loaded WithValue; nil otherwise.
	Value *string
	// TypeLabel is the display value type (e.g. "SecureString"); empty when the
	// provider has no value type or the value was not fetched.
	TypeLabel string
	// Secret reports whether the value must be masked in the UI.
	Secret bool
	// Namespace is the entry's Azure App Configuration namespace (empty for the
	// null namespace and every other provider).
	Namespace string
}

Item is one row in the entry list.

type ListParams

type ListParams struct {
	Prefix    string
	Filter    string
	Recursive bool
	WithValue bool
	// Namespace filters an Azure App Configuration listing. Empty means the null
	// namespace, aznamespace.AllNamespacesFilter ("*") means every namespace, and
	// any other value is a single concrete namespace. Ignored for other providers.
	Namespace string
}

ListParams are the list inputs a browser header collects.

type ListResult

type ListResult struct {
	Items []Item
	// NextToken is the secret-service paging cursor; empty when there are no more
	// pages (every provider today lists all names, so it is always empty, but the
	// field keeps the load-more wiring honest).
	NextToken string
}

ListResult is a page of list items plus the paging cursor.

type MetaRow

type MetaRow struct {
	Label string
	Value string
}

MetaRow is one capability-gated label/value line in the detail pane.

type Mutator

type Mutator interface {
	// Capability returns the service capability so a dialog can gate its controls
	// (mode toggle, type select, force/recovery rows, restore).
	Capability() capability.ServiceCapability
	// Create stages or applies a create for a new entry. typeLabel is the SSM type
	// display name for a typed param service (ignored elsewhere).
	Create(ctx context.Context, key StagedKey, value, typeLabel, description string, staged bool) (WriteOutcome, error)
	// Update stages or applies an update to an existing entry.
	Update(ctx context.Context, key StagedKey, value, typeLabel, description string, staged bool) (WriteOutcome, error)
	// Delete stages or applies a delete. force/recoveryWindow apply only to a
	// service with HasForceDelete/HasRecoveryWindow (AWS secret).
	Delete(ctx context.Context, key StagedKey, force bool, recoveryWindow int, staged bool) (WriteOutcome, error)
	// AddTag stages or applies a tag add/update.
	AddTag(ctx context.Context, key StagedKey, tagKey, tagValue string, staged bool) (WriteOutcome, error)
	// RemoveTag stages or applies a tag removal.
	RemoveTag(ctx context.Context, key StagedKey, tagKey string, staged bool) (WriteOutcome, error)
	// Restore applies an immediate restore of a soft-deleted entry (there is no
	// staged restore); it errors when the provider offers none.
	Restore(ctx context.Context, name string) (WriteOutcome, error)
}

Mutator is the write-path seam the mutation dialogs depend on. Every method is provider-neutral and routes to either the direct param/secret use cases (immediate) or the internal/usecase/staging use cases (staged), per the staged flag. The concrete param/secret mutators pair a per-scope-cached staging store with a scope-paired strategy, mirroring the GUI's serviceStrategyScoped discipline. Keeping the dialogs behind this interface lets a test drive them with a providermock-backed Mutator without touching a real cloud or keychain.

func NewParamMutator

func NewParamMutator(
	svcCap capability.ServiceCapability,
	resolveStore StoreResolver,
	newStrategy StrategyBuilder,
	stagingStore StagingStoreResolver,
) Mutator

NewParamMutator builds a param Mutator. resolveStore returns the param store for a namespace (namespace ignored for non-App-Configuration providers); newStrategy builds the staged-write strategy over a store; stagingStore resolves the cached staging store (nil when the service has no staging).

func NewSecretMutator

func NewSecretMutator(
	svcCap capability.ServiceCapability,
	store provider.Store,
	newStrategy StrategyBuilder,
	stagingStore StagingStoreResolver,
) Mutator

NewSecretMutator builds a secret Mutator over a resolved secret store.

type Source

type Source interface {
	// Capability returns the service's capability descriptor so a page can gate
	// its controls (history, namespaces, tags-per-version, …).
	Capability() capability.ServiceCapability
	// List returns the entries matching params.
	List(ctx context.Context, params ListParams) (ListResult, error)
	// Show returns the current-version detail of name (namespace applies only to
	// Azure App Configuration).
	Show(ctx context.Context, name, namespace string) (Detail, error)
	// History returns name's version history (empty when the service is
	// unversioned).
	History(ctx context.Context, name, namespace string) ([]HistoryRow, error)
	// VersionContents fetches the two versions' raw values for a diff.
	VersionContents(ctx context.Context, name, oldVersion, newVersion, namespace string) (DiffContent, error)
	// Namespaces lists the discovered Azure App Configuration namespaces (nil for
	// every other provider), so the header can offer them in its filter.
	Namespaces(ctx context.Context) ([]string, error)
}

Source is the read-path seam the browser and diff pages depend on. Every method is provider-neutral; the concrete param/secret sources map the usecase outputs onto these types and capability-gate the metadata.

func NewParamSource

func NewParamSource(svcCap capability.ServiceCapability, resolve StoreResolver) Source

NewParamSource builds a param Source. resolve returns the param store for a given App Configuration namespace; for other providers it must ignore the namespace and return the single resolved store.

func NewSecretSource

func NewSecretSource(svcCap capability.ServiceCapability, store provider.Store) Source

NewSecretSource builds a secret Source over a resolved secret store.

type StagedDiffRow

type StagedDiffRow struct {
	Name        string
	Namespace   string
	Type        StagedDiffType
	Operation   string // "create" / "update" / "delete"
	RemoteValue string
	StagedValue string
	Warning     string
	// Secret reports whether this row's values are secret material (a secret
	// service, or a SecureString param), so the page masks them per-row rather
	// than keying off the section's service axis alone (#677).
	Secret bool
}

StagedDiffRow is one staged entry rendered as a Remote-vs-Staged diff. The page shows RemoteValue/StagedValue in diff view and StagedValue in value view; a delete carries an empty StagedValue.

type StagedDiffType

type StagedDiffType int

StagedDiffType classifies a staged entry's diff row (mirrors the staging DiffUseCase's DiffEntryType), so the page can color/label auto-unstaged and warning rows distinctly.

const (
	StagedDiffNormal StagedDiffType = iota
	StagedDiffCreate
	StagedDiffAutoUnstaged
	StagedDiffWarning
)

StagedDiffType values.

type StagedKey

type StagedKey struct {
	Name      string
	Namespace string
}

StagedKey identifies a staged item by its (name, namespace) composite, so a name staged under several App Configuration namespaces is tracked per namespace (empty namespace for the null namespace and every other provider).

type StagedTagRow

type StagedTagRow struct {
	Name      string
	Namespace string
	// Adds are the staged tag adds/updates (key=value).
	Adds []Tag
	// Removes are the staged tag removals: the tag key plus the current remote
	// value (empty when unknown), so the row reads "−key (was value)".
	Removes []TagRemoval
}

StagedTagRow is one item's staged tag changes: independent +add and −remove deltas the page renders as separate cancellable rows.

type StagingApplyResult

type StagingApplyResult struct {
	// ServiceLabel is the service's display name for the results header.
	ServiceLabel string
	Entries      []ApplyEntryResult
	Tags         []ApplyTagResult
	// Conflicts are the labels of entries rejected because remote changed after
	// staging (empty unless conflict detection tripped).
	Conflicts []string
}

StagingApplyResult is the aggregated result of applying a service's staged changes.

type StagingProbe

type StagingProbe interface {
	// Staged returns the staged snapshot (badge keys, delete-staged subset, and
	// entry/tag counts) for the service.
	Staged(ctx context.Context) (StagingSnapshot, error)
}

StagingProbe reports which items in the current service have staged changes (an entry or a tag change), so the browser can show a [staged] badge and the detail pane a staged-changes banner. It is read-only — the parity of the GUI's StagingCheckStatus/StagingStatus reads (the staging page owns the mutations).

func NewStagingProbe

func NewStagingProbe(strategy staging.ServiceStrategy, store store.ReadOperator) StagingProbe

NewStagingProbe builds a StagingProbe over a staging strategy (parser) and a read-only staging store, both resolved for the same scope (the invariant the GUI's getStagingStoreScoped/getParserScoped pairing keeps).

type StagingResetResult

type StagingResetResult struct {
	Type         StagingResetType
	Count        int
	ServiceLabel string
}

StagingResetResult is the outcome of resetting a service.

type StagingResetType

type StagingResetType int

StagingResetType mirrors the staging ResetUseCase's ResetResultType so the page can voice the exact outcome.

const (
	StagingResetUnstaged StagingResetType = iota
	StagingResetUnstagedAll
	StagingResetRestored
	StagingResetNotStaged
	StagingResetNothingStaged
	StagingResetSkipped
	StagingResetUnstagedTag
)

StagingResetType values (mirror stagingusecase.ResetResultType).

type StagingResolver

type StagingResolver func(ctx context.Context) (StagingResources, error)

StagingResolver lazily builds a service's staging resources. It is invoked inside the async Review/Apply/Reset commands (never at page construction), so touching the keychain/registry never blocks the update loop; a key-loss hard-fail surfaces as the returned error.

type StagingResources

type StagingResources struct {
	Store    store.ReadWriteOperator
	Strategy staging.FullStrategy
	// StrategyFor resolves a per-namespace strategy for Azure App Configuration,
	// whose settings share one staging store across namespaces; nil for every
	// other provider/service (the single Strategy handles all).
	StrategyFor func(namespace string) (staging.FullStrategy, error)
}

StagingResources bundle the resolved staging store and strategy for one service. Store and Strategy MUST be paired to the same scope (the serviceStrategyScoped discipline).

type StagingReview

type StagingReview struct {
	Entries []StagedDiffRow
	Tags    []StagedTagRow
}

StagingReview is the full staged picture for one service — entries (as diffs) plus independent tag changes.

func (StagingReview) AutoUnstaged

func (r StagingReview) AutoUnstaged() []StagedKey

AutoUnstaged returns the keys of entries auto-unstaged during the review (staged value equalled remote, or the target vanished), for the dismissible notice.

func (StagingReview) EntryCount

func (r StagingReview) EntryCount() int

EntryCount is the number of still-staged entry rows (auto-unstaged rows are excluded — they were removed from the store during the review).

func (StagingReview) TagCount

func (r StagingReview) TagCount() int

TagCount is the number of staged tag-change rows.

type StagingService

type StagingService interface {
	// Service is the internal key ("param" / "secret").
	Service() string
	// Label is the display name for the section/results header (e.g. "Key Vault").
	Label() string
	// Capability gates the section's controls.
	Capability() capability.ServiceCapability
	// Review returns the staged entries (as diffs) and tag changes; it may
	// auto-unstage entries whose staged value now equals remote.
	Review(ctx context.Context) (StagingReview, error)
	// Apply applies the service's staged changes. A conflict rejection or a
	// per-entry failure returns a POPULATED result (the detail is in its fields),
	// not an error; only a hard store failure returns a non-nil error.
	Apply(ctx context.Context, ignoreConflicts bool) (StagingApplyResult, error)
	// Reset unstages every staged change for the service.
	Reset(ctx context.Context) (StagingResetResult, error)
	// Unstage removes one item's staged entry and its staged tags.
	Unstage(ctx context.Context, key StagedKey) error
	// CancelAddTag drops one staged tag add.
	CancelAddTag(ctx context.Context, key StagedKey, tagKey string) error
	// CancelRemoveTag drops one staged tag removal.
	CancelRemoveTag(ctx context.Context, key StagedKey, tagKey string) error
}

StagingService is the review/apply/reset seam the staging page depends on for one service. It wraps the internal/usecase/staging use cases over a per-scope-cached staging store paired with a scope-matched strategy, mirroring the GUI's staging methods. Keeping the page behind this interface lets a test drive it over providermock + an in-memory staging store without a keychain.

func NewStagingService

func NewStagingService(svcCap capability.ServiceCapability, label string, resolve StagingResolver) StagingService

NewStagingService builds a StagingService for one service. resolve lazily yields the scope-paired store and strategy.

type StagingSnapshot

type StagingSnapshot struct {
	Keys       map[StagedKey]struct{}
	DeleteKeys map[StagedKey]struct{}
	EntryKeys  map[StagedKey]struct{}
	TagKeys    map[StagedKey]struct{}
	EntryCount int
	TagCount   int
}

StagingSnapshot is the browser's read-only view of a service's staged state. Keys drives the [staged] badge and the detail banner; DeleteKeys is the subset staged for deletion, so the browser can gate the edit/delete/tag affordances that the reducer would reject as dead-end transitions (#692). EntryKeys and TagKeys split Keys by change kind — a value/entry change and a tag change — so the detail banner can distinguish value-only / tag-only / both, mirroring the GUI's StagingStatus {hasEntry, hasTags} pair (internal/gui/frontend/src/lib/StagingBanner.svelte) (#701). EntryCount and TagCount are the staged entry-row and tag-change totals whose sum feeds the Staging tab badge — the same entries+tags definition the staging page uses, so the badge no longer oscillates between two counts (#693).

type StagingStoreResolver

type StagingStoreResolver func() (store.ReadWriteOperator, error)

StagingStoreResolver resolves (and caches, upstream) the on-disk staging store for the mutator's service. It is nil when the service has no staging workflow. Deferring resolution to the first staged write keeps dialog open off the keychain.

type StoreResolver

type StoreResolver func(ctx context.Context, namespace string) (provider.Store, error)

StoreResolver resolves a param provider.Store for an App Configuration namespace. For non-App-Configuration providers the namespace is ignored and the same store is returned for every call.

type StoreUnavailableError

type StoreUnavailableError struct{ Err error }

StoreUnavailableError marks a StagingProbe failure that comes from CONSTRUCTING the on-disk staging store (a keychain hard-fail / key-loss while encrypted state exists), as opposed to a transient status read. This class of failure is persistent and actionable, so the browser surfaces it on the error line, while keeping ordinary probe read errors quiet (badges just do not show). The epic requires a key-loss to be visible on the read path, not only the write path.

func (*StoreUnavailableError) Error

func (e *StoreUnavailableError) Error() string

func (*StoreUnavailableError) Unwrap

func (e *StoreUnavailableError) Unwrap() error

type StrategyBuilder

type StrategyBuilder func(store provider.Store) staging.FullStrategy

StrategyBuilder builds the provider-specific staging strategy over a resolved provider.Store. The returned FullStrategy satisfies staging.EditStrategy and (via the concrete type) staging.DeleteStrategy, matching the GUI's serviceStrategyScoped narrowing.

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag is a neutral key/value tag.

type TagRemoval

type TagRemoval struct {
	Key   string
	Value string
}

TagRemoval is a staged tag removal: the key and its current remote value.

type WriteOutcome

type WriteOutcome struct {
	Skipped  bool
	Unstaged bool
	Updated  bool
}

WriteOutcome carries the semantic result of a mutation the UI must voice. Skipped is set when a staged edit equalled the live value (nothing staged); Unstaged when an edit-back-to-base or a delete-of-staged-create auto-unstaged the entry (EditOutput.Skipped/Unstaged, DeleteOutput.Unstaged); Updated when an immediate create fell back to update because the entry already existed (the create-or-update/upsert branch), so the status voices an update rather than a create — matching the GUI (ParamSet) and CLI (`param set`).

Jump to

Keyboard shortcuts

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