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

param

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package param provides the provider-neutral use cases of the param service axis (AWS Systems Manager Parameter Store, Azure App Configuration).

The use cases speak only the neutral provider seam: an entry is addressed by its name plus an opaque version suffix (e.g. "#3", "~2", or "" for the latest version) that the caller rebuilt with its provider's grammar and that the adapter re-parses in Reader.Resolve. Versions come back as opaque ids; provider-specific rendering (e.g. AWS integer versions) belongs to the presenters.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned (wrapped with the item noun and name, e.g.
	// "setting not found: key") when the item to update does not exist.
	ErrNotFound = errors.New("not found")
)

Functions

func MatchPrefix added in v1.5.0

func MatchPrefix(name, prefix string, recursive bool) bool

MatchPrefix reports whether name is in scope for the given prefix, using path-hierarchy semantics (AWS Parameter Store's server-side Path filter):

  • An empty prefix matches everything (the old code applied no Path filter, returning all parameters at any depth).
  • Otherwise a name matches the prefix iff name == prefix OR it is a descendant, i.e. HasPrefix(name, prefix+"/"). This is hierarchical, so prefix "/app" does NOT match "/application".
  • Recursive (--recursive) matches any depth under the prefix.
  • OneLevel (default) matches only immediate children: the segment after "prefix/" must contain no further "/".

A trailing slash on the prefix is normalized so "/app/" behaves like "/app".

Types

type CreateInput added in v0.5.0

type CreateInput struct {
	Name        string
	Value       string
	Type        domain.ValueType
	Description string
	// Options carries provider-specific write options (e.g. AWS param Tier,
	// DataType). They are passed through to the provider unchanged.
	Options []provider.WriteOption
}

CreateInput holds input for the create use case.

type CreateOutput added in v0.5.0

type CreateOutput struct {
	Name    string
	Version string // opaque version id; "" for an unversioned store
}

CreateOutput holds the result of the create use case.

type CreateUseCase added in v0.5.0

type CreateUseCase struct {
	Writer provider.Writer
	// ItemNoun names one item of the service in error messages ("parameter",
	// "setting"; capability.ServiceCapability.ItemNoun). Empty means "entry".
	ItemNoun string
}

CreateUseCase executes create operations.

func (*CreateUseCase) Execute added in v0.5.0

func (u *CreateUseCase) Execute(ctx context.Context, input CreateInput) (*CreateOutput, error)

Execute runs the create use case. It creates a new parameter via the provider; if the parameter already exists the provider returns a wrapped provider.ErrAlreadyExists and no overwrite occurs.

type DeleteInput

type DeleteInput struct {
	Name string
}

DeleteInput holds input for the delete use case.

type DeleteOutput

type DeleteOutput struct {
	Name string
}

DeleteOutput holds the result of the delete use case.

type DeleteUseCase

type DeleteUseCase struct {
	Store provider.Store
	// ItemNoun names one item of the service in error messages ("parameter",
	// "setting"; capability.ServiceCapability.ItemNoun). Empty means "entry".
	ItemNoun string
}

DeleteUseCase executes delete operations.

func (*DeleteUseCase) Execute

func (u *DeleteUseCase) Execute(ctx context.Context, input DeleteInput) (*DeleteOutput, error)

Execute runs the delete use case.

func (*DeleteUseCase) GetCurrentValue

func (u *DeleteUseCase) GetCurrentValue(ctx context.Context, name string) (string, error)

GetCurrentValue fetches the current value for preview. A non-existent parameter yields an empty value with no error; any other read failure is propagated.

type DiffInput

type DiffInput struct {
	Name1   string
	Suffix1 string
	Name2   string
	Suffix2 string
}

DiffInput holds input for the diff use case. Each side is a name plus its version-spec suffix (see ShowInput.Suffix), so an unversioned store can compare two distinct names.

type DiffOutput

type DiffOutput struct {
	OldName    string
	OldVersion string // opaque version id
	OldValue   string
	NewName    string
	NewVersion string // opaque version id
	NewValue   string
	// Secret reports whether either version holds a secret value (e.g. an AWS
	// SecureString), so a consumer masks both sides before rendering the diff. A
	// secret-typed param is a secret on the value-type axis even though it lives
	// on the param service axis, so masking must key off this flag, not the
	// service (#677/#702).
	Secret bool
}

DiffOutput holds the result of the diff use case.

type DiffUseCase

type DiffUseCase struct {
	Reader provider.Reader
}

DiffUseCase executes diff operations.

func (*DiffUseCase) Execute

func (u *DiffUseCase) Execute(ctx context.Context, input DiffInput) (*DiffOutput, error)

Execute runs the diff use case.

type ListEntry

type ListEntry struct {
	Name  string
	Value *string // nil when error or not requested
	// Type is the provider-neutral value type. It is only known when values are
	// fetched (WithValue); for name-only listings it stays the zero value.
	Type  domain.ValueType
	Error error
}

ListEntry represents a single parameter in list output.

type ListInput

type ListInput struct {
	Prefix string
	// Recursive matches any depth under Prefix instead of immediate children
	// only (see MatchPrefix). Ignored with PlainPrefix.
	Recursive bool
	// PlainPrefix matches Prefix as a plain, case-sensitive string prefix, for
	// stores whose keys have no path hierarchy. Without it Prefix uses the
	// path-hierarchy semantics of MatchPrefix.
	PlainPrefix bool
	Filter      string // Regex filter pattern
	WithValue   bool   // Include parameter values
}

ListInput holds input for the list use case.

type ListNamespacesEntry added in v1.10.0

type ListNamespacesEntry struct {
	Namespace string
	Name      string
	Value     *string
}

ListNamespacesEntry is one (key, namespace) row. Value is nil when not requested. App Configuration's list response always carries the value, so no per-entry error path exists (unlike the value-fetching neutral list).

type ListNamespacesInput added in v1.10.0

type ListNamespacesInput struct {
	Prefix    string // Name prefix filter (case-sensitive)
	Filter    string // Regex filter pattern (client-side)
	WithValue bool   // Include values (App Config's list response already carries them)
}

ListNamespacesInput holds input for the namespace-aware list use case. The namespace filter itself lives on the store (resolved from --namespace); here only the client-side key filters apply.

type ListNamespacesOutput added in v1.10.0

type ListNamespacesOutput struct {
	Entries []ListNamespacesEntry
}

ListNamespacesOutput holds the result of the namespace-aware list use case.

type ListNamespacesRow added in v1.10.0

type ListNamespacesRow struct {
	Key       string
	Namespace string
	Value     string
}

ListNamespacesRow is one (key, namespace) row a NamespacesLister returns. An empty Namespace is the null (default) namespace. Value is the key's current value in that namespace.

type ListNamespacesUseCase added in v1.10.0

type ListNamespacesUseCase struct {
	Lister NamespacesLister
}

ListNamespacesUseCase lists App Configuration settings with their namespaces.

func (*ListNamespacesUseCase) Execute added in v1.10.0

Execute runs the namespace-aware list use case. The store applies the namespace (label) filter; the name prefix and client-side regex filter are applied here, on the key.

type ListOutput

type ListOutput struct {
	Entries []ListEntry
}

ListOutput holds the result of the list use case.

type ListUseCase

type ListUseCase struct {
	Reader provider.Reader
}

ListUseCase executes list operations.

func (*ListUseCase) Execute

func (u *ListUseCase) Execute(ctx context.Context, input ListInput) (*ListOutput, error)

Execute runs the list use case.

type LogEntry

type LogEntry struct {
	Version      string // opaque version id
	Type         domain.ValueType
	Value        string
	LastModified *time.Time
	// IsCurrent reports whether the adapter marked this version as the current
	// one (domain.Version.Current).
	IsCurrent bool
	Error     error // Error from fetching value, if any
}

LogEntry represents a single version entry.

type LogInput

type LogInput struct {
	Name       string
	MaxResults int32
	Since      *time.Time
	Until      *time.Time
	Reverse    bool // Reverse chronological order
}

LogInput holds input for the log use case.

type LogOutput

type LogOutput struct {
	Name    string
	Entries []LogEntry
	// InitialIncluded reports whether the oldest entry in Entries is the very
	// first version that ever existed. It is false when the window was cut by
	// --number or a date filter, so the oldest shown version is not a creation.
	InitialIncluded bool
}

LogOutput holds the result of the log use case.

type LogUseCase

type LogUseCase struct {
	Reader provider.Reader
}

LogUseCase executes log operations.

func (*LogUseCase) Execute

func (u *LogUseCase) Execute(ctx context.Context, input LogInput) (*LogOutput, error)

Execute runs the log use case.

It fetches the version history (newest first) via the provider, applies the date filters, then retrieves each surviving version's value and type. The provider's History exposes only version metadata (id/created), so values are fetched per version via Resolve+Get. A per-version fetch failure is recorded on the entry's Error field rather than aborting the whole listing.

type NamespacesLister added in v1.10.0

type NamespacesLister interface {
	ListNamespaces(ctx context.Context) ([]ListNamespacesRow, error)
}

NamespacesLister lists per-(key, namespace) rows honoring the store's configured namespace filter, sorted by key then namespace. It is an extension outside the neutral provider.Reader.List contract: only a service with a namespace axis (Azure App Configuration) offers it, through an adapter the caller builds over its store.

type ShowInput

type ShowInput struct {
	Name string
	// Suffix is the version-spec suffix after the name ("#3", "~2", or "" for
	// the latest version), re-parsed by the adapter.
	Suffix string
}

ShowInput holds input for the show use case.

type ShowOutput

type ShowOutput struct {
	Name         string
	Value        string
	Version      string // opaque version id
	Type         domain.ValueType
	Description  string
	LastModified *time.Time
	Tags         []ShowTag
}

ShowOutput holds the result of the show use case.

type ShowTag added in v0.2.0

type ShowTag struct {
	Key   string
	Value string
}

ShowTag represents a tag key-value pair.

type ShowUseCase

type ShowUseCase struct {
	Reader provider.Reader
}

ShowUseCase executes show operations.

func (*ShowUseCase) Execute

func (u *ShowUseCase) Execute(ctx context.Context, input ShowInput) (*ShowOutput, error)

Execute runs the show use case.

type UpdateInput added in v0.5.0

type UpdateInput struct {
	Name        string
	Value       string
	Type        domain.ValueType
	Description string
	// PreserveType, when true, keeps the existing parameter's type instead of
	// applying Type, so a value-only update never downgrades an existing secret
	// or list value (e.g. an AWS SecureString losing its KMS encryption) to
	// plaintext. The AWS CLI sets it when no type flag is given; callers that
	// pass an explicit type (GUI, TUI) leave it false and Type is applied as-is.
	PreserveType bool
	// Options carries provider-specific write options (e.g. AWS param Tier,
	// DataType). They are passed through to the provider unchanged.
	Options []provider.WriteOption
}

UpdateInput holds input for the update use case.

type UpdateOutput added in v0.5.0

type UpdateOutput struct {
	Name    string
	Version string // opaque version id; "" for an unversioned store
}

UpdateOutput holds the result of the update use case.

type UpdateUseCase added in v0.5.0

type UpdateUseCase struct {
	Store provider.Store
	// ItemNoun names one item of the service in error messages ("parameter",
	// "setting"; capability.ServiceCapability.ItemNoun). Empty means "entry".
	ItemNoun string
}

UpdateUseCase executes update operations.

func (*UpdateUseCase) Execute added in v0.5.0

func (u *UpdateUseCase) Execute(ctx context.Context, input UpdateInput) (*UpdateOutput, error)

Execute runs the update use case. It updates an existing parameter; if the parameter doesn't exist it returns a wrapped ErrNotFound. A read failure other than not-found is propagated unchanged (never treated as "does not exist").

func (*UpdateUseCase) GetCurrentValue added in v0.8.0

func (u *UpdateUseCase) GetCurrentValue(ctx context.Context, name string) (string, error)

GetCurrentValue fetches the current parameter value for preview. A non-existent parameter yields an empty value with no error; any other read failure is propagated.

Jump to

Keyboard shortcuts

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