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

provider

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package provider defines the provider-neutral storage seam: the interfaces and opaque reference types that every backend (AWS, Google Cloud, and Azure services) implements.

It imports only internal/domain and the standard library; it has ZERO knowledge of any cloud SDK. Provider-specific concerns (ARNs, staging labels, version-id semantics) live behind these interfaces inside each adapter.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates the requested entry does not exist.
	ErrNotFound = errors.New("provider: entry not found")
	// ErrAlreadyExists indicates a create was attempted on an entry that
	// already exists.
	ErrAlreadyExists = errors.New("provider: entry already exists")
	// ErrBinaryValue indicates the entry holds a binary value that suve cannot
	// represent as text (e.g. an AWS Secrets Manager SecretBinary secret).
	// Callers must not treat such an entry as an empty-string value.
	ErrBinaryValue = errors.New("binary value is not supported")
	// ErrPendingDeletion indicates the entry is deleted but still recoverable
	// (AWS Secrets Manager: scheduled for deletion; Azure Key Vault:
	// soft-deleted), so it can be neither read nor re-created until it is
	// restored or the deletion completes. It is distinct from ErrNotFound and
	// ErrAlreadyExists so callers do not treat the name as free or as live.
	ErrPendingDeletion = errors.New("scheduled for deletion")
	// ErrUnsupportedKind indicates the provider does not offer the requested
	// store kind (e.g. GoogleCloud has no param store).
	ErrUnsupportedKind = errors.New("provider: unsupported store kind")
	// ErrNoFactory indicates no factory is registered for a provider.
	ErrNoFactory = errors.New("provider: no factory registered for provider")
)

Sentinel errors returned by provider implementations so that callers can classify failures without importing any cloud SDK. Adapters wrap the underlying provider error with these via fmt.Errorf("%w", ...).

Functions

This section is empty.

Types

type DeleteOption

type DeleteOption interface {
	// contains filtered or unexported methods
}

DeleteOption is a provider-interpreted functional option for delete operations (e.g. AWS Secrets Manager ForceDelete / RecoveryWindow). It follows the same pass-through contract as WriteOption: consumers pass options through untyped and the adapter interprets the ones it recognizes. Concrete options satisfy it by embedding DeleteOptionMarker.

type DeleteOptionMarker

type DeleteOptionMarker struct{}

DeleteOptionMarker is embedded by provider-specific delete-option types to satisfy DeleteOption. See WriteOptionMarker for the rationale.

type Factory

type Factory interface {
	// Store builds a Store for the given scope and kind.
	Store(ctx context.Context, scope Scope, kind Kind) (Store, error)
}

Factory builds a Store for a scope + kind. It returns ErrUnsupportedKind if the provider does not offer that kind (e.g. GoogleCloud has no param store).

type ForceDelete added in v1.5.2

type ForceDelete struct{ DeleteOptionMarker }

ForceDelete requests immediate, unrecoverable deletion, skipping any recovery window. Only AWS Secrets Manager honors it (mapped to ForceDeleteWithoutRecovery). Azure Key Vault ignores it — its retention is a vault-level property, not a per-delete option, so deletes stay soft (use Restore to recover). Providers without the concept ignore it.

type Kind

type Kind string

Kind selects a store kind within a provider (some providers offer only one).

const (
	// KindParam selects a parameter store (e.g. AWS SSM Parameter Store, Azure App Configuration).
	KindParam Kind = "param"
	// KindSecret selects a secret store (e.g. AWS Secrets Manager, Azure Key Vault).
	KindSecret Kind = "secret"
)

type Provider

type Provider string

Provider identifies a cloud provider backend.

const (
	// ProviderAWS is the Amazon Web Services provider.
	ProviderAWS Provider = "aws"
	// ProviderGoogleCloud is the Google Cloud Platform provider.
	ProviderGoogleCloud Provider = "googlecloud"
	// ProviderAzure is the Microsoft Azure provider.
	ProviderAzure Provider = "azure"
)

func Providers added in v1.10.0

func Providers() []Provider

Providers returns every provider in the stable order that listings and messages use: AWS, Google Cloud, then Azure.

type Reader

type Reader interface {
	// Resolve parses a provider-specific version spec string (e.g. "#3~1",
	// "#abc123", ":AWSCURRENT" for AWS) and resolves it to an opaque VersionRef.
	Resolve(ctx context.Context, name, spec string) (VersionRef, error)
	// Get retrieves the entry at the given version ref. It returns a wrapped
	// ErrNotFound if the entry does not exist.
	Get(ctx context.Context, name string, ref VersionRef) (*domain.Entry, error)
	// History returns the version history for an entry, newest first.
	History(ctx context.Context, name string) ([]domain.Version, error)
	// List returns the names of all entries in the provider's namespace.
	List(ctx context.Context) ([]string, error)
}

Reader provides read access to a provider's entries.

type Registry

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

Registry maps a Provider to its Factory.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty Registry.

func (*Registry) Register

func (r *Registry) Register(p Provider, f Factory)

Register associates a Factory with a Provider, overwriting any prior registration.

func (*Registry) Store

func (r *Registry) Store(ctx context.Context, scope Scope, kind Kind) (Store, error)

Store resolves the factory for scope.Provider and builds the requested store.

type Restorer

type Restorer interface {
	// Restore cancels a pending deletion for an entry.
	Restore(ctx context.Context, name string) error
}

Restorer restores a soft-deleted entry (e.g. Secrets Manager). Optional.

type Scope

type Scope struct {
	// Provider selects which backend the scope belongs to.
	Provider Provider `json:"provider"`

	// AccountID is the AWS account id (AWS).
	AccountID string `json:"accountId,omitempty"`
	// Region is the AWS region (AWS).
	Region string `json:"region,omitempty"`

	// ProjectID is the Google Cloud project id (GoogleCloud).
	ProjectID string `json:"projectId,omitempty"`

	// VaultName is the Azure Key Vault name (Azure, secret).
	VaultName string `json:"vaultName,omitempty"`
	// StoreName is the Azure App Configuration store name (Azure, param).
	StoreName string `json:"storeName,omitempty"`
	// AppConfigNamespace is the Azure App Configuration namespace — the axis
	// Azure calls a "label" — selected for the store (Azure, param). Empty is
	// the null (default) namespace. A single resolved namespace only; the
	// filter grammar (`*`/`,`) never reaches staging (see #381).
	AppConfigNamespace string `json:"appConfigNamespace,omitempty"`
}

Scope identifies a provider-specific namespace for staging state. The set of meaningful fields depends on Provider:

  • AWS: AccountID + Region (shared for param and secret).
  • GoogleCloud: ProjectID (Secret Manager only).
  • Azure: VaultName (Key Vault, secret) or StoreName (App Configuration, param) — each a globally-unique name that fully identifies the resource, so no subscription/resource-group is needed.

Scope is used both to select a provider factory (Provider field) and to key on-disk staging storage (see Key).

func AWSScope

func AWSScope(accountID, region string) Scope

AWSScope creates a Scope for AWS from an account id and region.

func AzureAppConfigScope

func AzureAppConfigScope(storeName string) Scope

AzureAppConfigScope creates a Scope for an Azure App Configuration store (param store). The store name is globally unique, so it fully identifies the resource.

func AzureKeyVaultScope

func AzureKeyVaultScope(vaultName string) Scope

AzureKeyVaultScope creates a Scope for an Azure Key Vault (secret store). The vault name is globally unique, so it fully identifies the resource.

func GoogleCloudScope

func GoogleCloudScope(projectID string) Scope

GoogleCloudScope creates a Scope for Google Cloud from a project id.

func (Scope) Key

func (s Scope) Key() string

Key returns a stable, filesystem-safe key identifying the scope. It is used to key on-disk staging storage (e.g. ~/.suve/staging/{Key()}/param.json).

func (Scope) SupportedKinds

func (s Scope) SupportedKinds() []Kind

SupportedKinds returns the store kinds the scope supports, in a stable order (KindParam, then KindSecret). This is the registry-driven iteration source that replaces hardcoded {param, secret} loops.

func (Scope) SupportsService

func (s Scope) SupportsService(kind Kind) bool

SupportsService reports whether the scope's provider offers the given store kind. AWS supports both param and secret; GoogleCloud supports secret only; Azure supports secret (Key Vault) or param (App Configuration) depending on which of VaultName/StoreName is set.

func (Scope) Target added in v1.10.0

func (s Scope) Target() Target

Target describes the scope without any network call. An AWS scope that does not carry both account and region is Pending: those come from the STS caller identity, together with the profile the scope never carries.

type Store

type Store interface {
	Reader
	Writer
	Tagger
}

Store is the full provider contract for one service (e.g. AWS SSM, Google Cloud Secret Manager, or Azure App Configuration). Providers may additionally implement the optional Restorer capability.

type Tagger

type Tagger interface {
	// Tag adds or updates the given tags on an entry.
	Tag(ctx context.Context, name string, add map[string]string) error
	// Untag removes the tags with the given keys from an entry.
	Untag(ctx context.Context, name string, keys []string) error
}

Tagger provides tag mutation for a provider's entries.

type Target added in v1.10.0

type Target struct {
	// Segments are in display order. Each provider always lists the same labels,
	// so a UI can keep a stable layout while some values are still empty.
	Segments []TargetSegment
	// Pending is true when some values need a network lookup that has not run
	// yet (AWS: the STS caller identity). Resolve it through
	// builtin.ResolveTarget.
	Pending bool
}

Target describes, for display, what a scope points at: the ordered segments every UI shows as "who am I connected to" (the TUI status bar, the apply confirmation, the GUI sidebar, and the CLI confirmation prompts).

func AWSTarget added in v1.10.0

func AWSTarget(profile, accountID, region string) Target

AWSTarget builds the AWS target from a resolved caller identity: the profile, account and region.

func (Target) String added in v1.10.0

func (t Target) String() string

String renders the segments that have a value as "label value", joined by " · ". It returns "" when no segment has a value. The package imports only the standard library, so this is a plain loop.

type TargetSegment added in v1.10.0

type TargetSegment struct {
	Label string
	Value string
}

TargetSegment is one labeled part of a Target, such as "account" and its id. Value is empty when the part is unknown or unset.

type VersionRef

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

VersionRef is an opaque reference to a specific version, produced by a provider (Resolve/History) and consumed by the same provider. The zero value denotes the latest/current version. It intentionally exposes no version-id or staging-label semantics to generic callers.

func NewVersionRef

func NewVersionRef(id string) VersionRef

NewVersionRef builds a VersionRef from a provider-internal id. For adapter use.

func (VersionRef) ID

func (r VersionRef) ID() string

ID returns the provider-internal identifier ("" for latest). For adapter use.

func (VersionRef) IsLatest

func (r VersionRef) IsLatest() bool

IsLatest reports whether the ref denotes the latest/current version.

type WriteOption

type WriteOption interface {
	// contains filtered or unexported methods
}

WriteOption is a provider-interpreted functional option for create/update operations. Providers define concrete option types (e.g. AWS param Tier or DataType) that satisfy this marker by embedding WriteOptionMarker.

Consumers (usecases, CLI) build and pass these options through WITHOUT type-asserting them; the provider adapter type-switches over the options it understands and silently ignores the rest. This keeps provider-specific options out of the neutral domain model while remaining strongly typed.

The marker method is unexported, so the WriteOption set stays closed to types that embed WriteOptionMarker; arbitrary external types cannot masquerade as options.

type WriteOptionMarker

type WriteOptionMarker struct{}

WriteOptionMarker is embedded by provider-specific option types to satisfy WriteOption. Embedding it (rather than defining the unexported method in each provider package, which Go forbids across packages) is what lets the AWS adapters declare their own option types against this sealed interface.

type Writer

type Writer interface {
	// Create creates a new entry and returns the resulting version. It returns
	// a wrapped ErrAlreadyExists if an entry with the same name already exists
	// (it never overwrites). Provider-specific WriteOptions are interpreted by
	// the adapter and ignored when unrecognized.
	Create(
		ctx context.Context, name, value string, valueType domain.ValueType, description string, opts ...WriteOption,
	) (domain.Version, error)
	// Put creates or updates an entry (upsert) and returns the resulting
	// version. Unlike Create it overwrites an existing entry. Provider-specific
	// WriteOptions are interpreted by the adapter and ignored when unrecognized.
	Put(
		ctx context.Context, name, value string, valueType domain.ValueType, description string, opts ...WriteOption,
	) (domain.Version, error)
	// Delete removes an entry. Provider-specific DeleteOptions are interpreted
	// by the adapter and ignored when unrecognized.
	Delete(ctx context.Context, name string, opts ...DeleteOption) error
}

Writer provides write access to a provider's entries.

Directories

Path Synopsis
aws
Package aws wires the AWS Parameter Store and Secrets Manager adapters into a provider.Factory / provider.Registry.
Package aws wires the AWS Parameter Store and Secrets Manager adapters into a provider.Factory / provider.Registry.
parameterstore
Package parameterstore implements the provider.Store contract for AWS Systems Manager Parameter Store.
Package parameterstore implements the provider.Store contract for AWS Systems Manager Parameter Store.
paramtype
Package paramtype maps between the provider-neutral domain.ValueType and the AWS SSM Parameter Store type names ("String", "SecureString", "StringList") used in CLI output, the --type flag, and the TUI/GUI type pickers.
Package paramtype maps between the provider-neutral domain.ValueType and the AWS SSM Parameter Store type names ("String", "SecureString", "StringList") used in CLI output, the --type flag, and the TUI/GUI type pickers.
secretsmanager
Package secretsmanager implements the provider.Store and provider.Restorer contracts for AWS Secrets Manager.
Package secretsmanager implements the provider.Store and provider.Restorer contracts for AWS Secrets Manager.
Package azure wires the two Azure adapters into a provider.Factory / provider.Registry:
Package azure wires the two Azure adapters into a provider.Factory / provider.Registry:
appconfig
Package appconfig implements the provider.Store contract (Reader/Writer/Tagger) for Azure App Configuration, confining all App Configuration SDK types to this package.
Package appconfig implements the provider.Store contract (Reader/Writer/Tagger) for Azure App Configuration, confining all App Configuration SDK types to this package.
appconfig/namespaces
Package namespaces parses the value of the Azure App Configuration --namespace / --ns flag (env AZURE_APPCONFIG_NAMESPACE).
Package namespaces parses the value of the Azure App Configuration --namespace / --ns flag (env AZURE_APPCONFIG_NAMESPACE).
keyvault
Package keyvault implements the provider.Store contract (Reader/Writer/Tagger) for Azure Key Vault secrets.
Package keyvault implements the provider.Store contract (Reader/Writer/Tagger) for Azure Key Vault secrets.
Package builtin composes the provider.Registry every entry point (CLI, GUI, TUI) resolves stores through, with each built-in cloud adapter registered on equal footing: AWS (param + secret), Google Cloud (secret), and Azure (Key Vault secret + App Configuration param).
Package builtin composes the provider.Registry every entry point (CLI, GUI, TUI) resolves stores through, with each built-in cloud adapter registered on equal footing: AWS (param + secret), Google Cloud (secret), and Azure (Key Vault secret + App Configuration param).
Package detect resolves which cloud provider should back the flat `param` / `secret` command aliases and a bare `suve --tui` / `suve --gui` launch, and hydrates a launch scope's resource fields, based purely on environment variables.
Package detect resolves which cloud provider should back the flat `param` / `secret` command aliases and a bare `suve --tui` / `suve --gui` launch, and hydrates a launch scope's resource fields, based purely on environment variables.
Package gcloud wires the Google Cloud Secret Manager adapter into a provider.Factory / provider.Registry.
Package gcloud wires the Google Cloud Secret Manager adapter into a provider.Factory / provider.Registry.
secretmanager
Package secretmanager implements the provider.Store contract (Reader/Writer/Tagger) for Google Cloud Secret Manager.
Package secretmanager implements the provider.Store contract (Reader/Writer/Tagger) for Google Cloud Secret Manager.
Package providermock provides a configurable mock implementation of the provider interfaces (Reader/Writer/Tagger/Store) for use in unit tests.
Package providermock provides a configurable mock implementation of the provider interfaces (Reader/Writer/Tagger/Store) for use in unit tests.

Jump to

Keyboard shortcuts

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