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

binding

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: 7 Imported by: 0

Documentation

Overview

Package binding is the single per-(provider, service kind) lookup that the CLI, GUI and TUI share. For each provider and kind it owns:

  • the version grammar that splits "name#VERSION~SHIFT" into the name and the suffix the use cases take (SplitSpec),
  • the store-less parser (status, reset, export/import parsing),
  • the staging strategy built over a resolved provider.Store,
  • the scope that keys on-disk staging state, derived from the selected scope (Azure keys its two services in separate buckets; AWS keys by the caller identity, which needs a network lookup),
  • the namespace override for a service with a namespace axis inside one store (Azure App Configuration).

An unknown provider is an error (ErrUnknownProvider). A known provider that does not offer a kind is provider.ErrUnsupportedKind. There is no default provider.

The package imports no cloud SDK directly. The AWS identity lookup goes through aws.LoadIdentity (internal/provider/aws), which loads the AWS config and calls STS.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownProvider = errors.New("unknown provider")

ErrUnknownProvider is returned for a provider that has no staging binding (an unknown or unselected provider).

Functions

func ResolveTarget

func ResolveTarget(ctx context.Context, sc provider.Scope, lookup IdentityLookup) (provider.Target, error)

ResolveTarget describes what the selected scope sc points at, running the provider's identity lookup when sc cannot describe itself (AWS: the STS caller identity fills the profile, account and region). lookup replaces the default lookup, as in StagingScope, so a caller can share one memoized lookup between staging and display.

func StagingScope

func StagingScope(ctx context.Context, sc provider.Scope, kind provider.Kind, lookup IdentityLookup) (staging.ResolvedScope, error)

StagingScope resolves the scope that keys kind's staging state for the selected scope sc, plus the confirmation target. It fails only for an unknown provider: a known provider keys a kind it does not offer under the selected scope, and the parser or strategy lookup rejects that kind instead.

lookup replaces the provider's default identity lookup (for memoizing or stubbing it); nil uses the default. It runs only when sc cannot key staging by itself.

Types

type Binding

type Binding struct {
	// SplitSpec splits a version spec into its name and the version suffix the
	// use cases take, with the product's grammar (a version grammar's Split).
	// An unversioned service (Azure App Configuration) keeps the whole argument
	// as the name, so a key that contains '#' or '~' is not split. It is a
	// field rather than a method because only the build-tagged GUI calls it,
	// and the default-build dead-code gate cannot see that caller.
	//
	//declscope:ignore overexported // internal/gui/spec.go calls it behind production || dev
	SplitSpec func(input string) (name, suffix string, err error)
	// contains filtered or unexported fields
}

Binding is the staging binding for one (provider, kind) pair. Get one from Lookup.

func Lookup

func Lookup(p provider.Provider, kind provider.Kind) (Binding, error)

Lookup returns the staging binding for a provider and kind.

func (Binding) NamespaceScope

func (b Binding) NamespaceScope(sc provider.Scope, ns string) provider.Scope

NamespaceScope returns sc with its namespace set to ns when the service has a namespace axis. For every other service it returns sc unchanged.

func (Binding) Namespaced

func (b Binding) Namespaced(sc provider.Scope) bool

Namespaced reports whether the service has a namespace axis for the selected scope, so staged entries must apply under their own namespace.

func (Binding) Parser

func (b Binding) Parser() staging.Parser

Parser returns a store-less parser for the service.

func (Binding) ParserFactory

func (b Binding) ParserFactory() staging.ParserFactory

ParserFactory returns the parser constructor, for configs that take a staging.ParserFactory.

func (Binding) Strategy

func (b Binding) Strategy(store provider.Store) staging.FullStrategy

Strategy builds the staging strategy over a resolved provider store.

type IdentityLookup

type IdentityLookup func(ctx context.Context) (staging.ResolvedScope, error)

IdentityLookup resolves the account-level staging scope for a provider whose selected scope does not carry it (AWS: the STS caller identity). Callers may pass their own to memoize or stub the lookup.

func DefaultIdentity

func DefaultIdentity(p provider.Provider) IdentityLookup

DefaultIdentity returns the provider's default identity lookup, for a caller that wraps it (for example to memoize it). It returns a lookup that fails for an unknown provider or one that never needs a lookup.

Jump to

Keyboard shortcuts

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