Documentation ¶
Overview ¶
Package configuration is a generic configuration and secret management API.
Index ¶
- Variables
- type Entry
- type EnvarProvider
- func (e EnvarProvider[T]) Delete(ctx context.Context, ref Ref) error
- func (EnvarProvider[T]) Key() string
- func (e EnvarProvider[T]) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error)
- func (e EnvarProvider[T]) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error)
- func (e EnvarProvider[T]) Writer() bool
- type EnvarType
- type EnvarTypeConfig
- type EnvarTypeSecrets
- type FromConfig
- type FromConfigOrSecrets
- type FromSecrets
- type InlineProvider
- func (InlineProvider) Delete(ctx context.Context, ref Ref) error
- func (InlineProvider) Key() string
- func (InlineProvider) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error)
- func (InlineProvider) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error)
- func (i InlineProvider) Writer() bool
- type KeychainProvider
- func (k KeychainProvider) Delete(ctx context.Context, ref Ref) error
- func (k KeychainProvider) Key() string
- func (k KeychainProvider) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error)
- func (k KeychainProvider) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error)
- func (k KeychainProvider) Writer() bool
- type Manager
- type MutableProvider
- type OnePasswordProvider
- func (o OnePasswordProvider) Delete(ctx context.Context, ref Ref) error
- func (o OnePasswordProvider) Key() string
- func (o OnePasswordProvider) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error)
- func (o OnePasswordProvider) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error)
- func (o OnePasswordProvider) Writer() bool
- type ProjectConfigResolver
- func (p ProjectConfigResolver[T]) Get(ctx context.Context, ref Ref) (*url.URL, error)
- func (p ProjectConfigResolver[T]) List(ctx context.Context) ([]Entry, error)
- func (p ProjectConfigResolver[T]) Set(ctx context.Context, ref Ref, key *url.URL) error
- func (p ProjectConfigResolver[From]) Unset(ctx context.Context, ref Ref) error
- type Provider
- type Ref
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a configuration entry is not found or cannot be resolved.
Functions ¶
This section is empty.
Types ¶
type EnvarProvider ¶
type EnvarProvider[T EnvarType] struct { Envar bool `help:"Print configuration as environment variables." xor:"configwriter" group:"Provider:"` }
EnvarProvider is a configuration provider that reads from environment variables.
func (EnvarProvider[T]) Delete ¶
func (e EnvarProvider[T]) Delete(ctx context.Context, ref Ref) error
func (EnvarProvider[T]) Key ¶
func (EnvarProvider[T]) Key() string
func (EnvarProvider[T]) Writer ¶
func (e EnvarProvider[T]) Writer() bool
type EnvarTypeConfig ¶
type EnvarTypeConfig struct{}
type EnvarTypeSecrets ¶
type EnvarTypeSecrets struct{}
type FromConfig ¶
type FromConfig struct{}
type FromConfigOrSecrets ¶
type FromConfigOrSecrets interface {
// contains filtered or unexported methods
}
type FromSecrets ¶
type FromSecrets struct{}
type InlineProvider ¶
type InlineProvider struct {
Inline bool `help:"Write values inline in the configuration file." group:"Provider:" xor:"configwriter"`
}
InlineProvider is a configuration provider that stores configuration in its key.
func (InlineProvider) Key ¶
func (InlineProvider) Key() string
func (InlineProvider) Writer ¶
func (i InlineProvider) Writer() bool
type KeychainProvider ¶
type KeychainProvider struct {
Keychain bool `help:"Write to the system keychain." group:"Provider:" xor:"configwriter"`
}
func (KeychainProvider) Delete ¶
func (k KeychainProvider) Delete(ctx context.Context, ref Ref) error
func (KeychainProvider) Key ¶
func (k KeychainProvider) Key() string
func (KeychainProvider) Writer ¶
func (k KeychainProvider) Writer() bool
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a high-level configuration manager that abstracts the details of the Resolver and Provider interfaces.
func (*Manager) Get ¶
Get a configuration value from the active providers.
"value" must be a pointer to a Go type that can be unmarshalled from JSON.
func (*Manager) Mutable ¶
Mutable returns an error if the configuration manager doesn't have a writeable provider configured.
type MutableProvider ¶
type MutableProvider interface { Provider // Writer returns true if this provider should be used to store configuration. // // Only one provider should return true. // // To be usable from the CLI, each provider must be a Kong-compatible struct // containing a flag that this method should return. For example: // // type InlineProvider struct { // Inline bool `help:"Write values inline." group:"Provider:" xor:"configwriter"` // } // // func (i InlineProvider) Writer() bool { return i.Inline } // // The "xor" tag is used to ensure that only one writer is selected. Writer() bool // Store a configuration value and return its key. Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error) // Delete a configuration value. Delete(ctx context.Context, ref Ref) error }
A MutableProvider is a Provider that can update configuration.
type OnePasswordProvider ¶
type OnePasswordProvider struct {
OnePassword bool `name:"op" help:"Write 1Password secret references - does not write to 1Password." group:"Provider:" xor:"configwriter"`
}
OnePasswordProvider is a configuration provider that reads passwords from 1Password vaults via the "op" command line tool.
func (OnePasswordProvider) Delete ¶
func (o OnePasswordProvider) Delete(ctx context.Context, ref Ref) error
func (OnePasswordProvider) Key ¶
func (o OnePasswordProvider) Key() string
func (OnePasswordProvider) Writer ¶
func (o OnePasswordProvider) Writer() bool
type ProjectConfigResolver ¶
type ProjectConfigResolver[From FromConfigOrSecrets] struct { Config string `help:"Load project configuration from TOML file." placeholder:"FILE" type:"existingfile"` }
ProjectConfigResolver is parametric Resolver that loads values from either a project's configuration or secrets maps based on the type parameter.
func (ProjectConfigResolver[T]) List ¶
func (p ProjectConfigResolver[T]) List(ctx context.Context) ([]Entry, error)
type Provider ¶
type Provider interface { Key() string Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error) }
Provider is a generic interface for storing and retrieving configuration and secrets.
type Ref ¶
A Ref is a reference to a configuration value.
func NewRef ¶
NewRef creates a new Ref.
If [module] is empty, the Ref is considered to be a global configuration value.
func (*Ref) UnmarshalText ¶
type Resolver ¶
type Resolver interface { Get(ctx context.Context, ref Ref) (key *url.URL, err error) Set(ctx context.Context, ref Ref, key *url.URL) error Unset(ctx context.Context, ref Ref) error List(ctx context.Context) ([]Entry, error) }
A Resolver resolves configuration names to keys that are then used to load values from a Provider.
This indirection allows for the storage of configuration values to be abstracted from the configuration itself. For example, the ftl-project.toml file contains per-module and global configuration maps, but the secrets themselves may be stored in a separate secret store such as a system keychain.