Documentation
¶
Index ¶
- func IsCacheable(expr string) bool
- func NormalizeExpression(expr string) (string, bool)
- func NormalizeLegacyBraces(value string) string
- type Checker
- type DeferredError
- type MockProvider
- type OnePasswordCLIProvider
- type OnePasswordSDKProvider
- type OnePasswordVault
- type Provider
- type Resolver
- type SecretRef
- type Shims
- type SopsProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCacheable ¶ added in v0.9.0
IsCacheable reports whether an expression is a standalone secret reference eligible for TF_VAR cache reuse.
func NormalizeExpression ¶ added in v0.9.0
NormalizeExpression returns the secret("vault","item","field") call for a secret reference, for example "secret.op.vault.item.field", "op.vault.item.field", or "secret.sops.key.path". A "secrets." prefix is the same as "secret.". A sops reference becomes secret("sops","key.path",""). A canonical secret(...) call returns trimmed and false. A value that is not a reference returns "" and false.
func NormalizeLegacyBraces ¶ added in v0.9.0
NormalizeLegacyBraces converts ${{ expr }} to ${ expr }.
Types ¶
type Checker ¶ added in v0.10.0
Checker is the optional contract of a provider that can confirm its backend is reachable before any secret is read. Account names the backend in messages and groups the providers that share one account.
type DeferredError ¶ added in v0.9.0
DeferredError signals that a secret expression should be preserved for later evaluation. This is not an error condition but a control-flow signal.
func (*DeferredError) Error ¶ added in v0.9.0
func (e *DeferredError) Error() string
type MockProvider ¶ added in v0.9.0
type MockProvider struct {
LoadSecretsFunc func() error
ResolveFunc func(ref SecretRef) (string, bool, error)
}
MockProvider is a mock implementation of the Provider interface for testing.
func NewMockProvider ¶ added in v0.9.0
func NewMockProvider() *MockProvider
NewMockProvider creates a new MockProvider instance.
func (*MockProvider) LoadSecrets ¶ added in v0.9.0
func (m *MockProvider) LoadSecrets() error
LoadSecrets calls the mock LoadSecretsFunc if set, otherwise returns nil.
type OnePasswordCLIProvider ¶ added in v0.9.0
type OnePasswordCLIProvider struct {
// contains filtered or unexported fields
}
OnePasswordCLIProvider implements the Provider interface using the 1Password CLI.
func NewOnePasswordCLIProvider ¶ added in v0.9.0
func NewOnePasswordCLIProvider(vault OnePasswordVault) *OnePasswordCLIProvider
NewOnePasswordCLIProvider creates a new OnePasswordCLIProvider instance.
func (*OnePasswordCLIProvider) Account ¶ added in v0.10.0
func (s *OnePasswordCLIProvider) Account() string
Account returns the 1Password account this provider reads.
func (*OnePasswordCLIProvider) Check ¶ added in v0.10.0
func (s *OnePasswordCLIProvider) Check() error
Check confirms that the account is reachable and signed in. It runs op whoami for the account.
func (*OnePasswordCLIProvider) LoadSecrets ¶ added in v0.9.0
func (s *OnePasswordCLIProvider) LoadSecrets() error
LoadSecrets marks the provider as unlocked.
func (*OnePasswordCLIProvider) Resolve ¶ added in v0.9.0
func (s *OnePasswordCLIProvider) Resolve(ref SecretRef) (string, bool, error)
Resolve fetches a secret from 1Password CLI. ref.Item is config-controlled and positional; it's placed after "--" (end-of-options) in the op argv so an item name beginning with "-" is parsed as the operand op expects, not as an op flag. Returns handled=true only if the vault ID matches.
type OnePasswordSDKProvider ¶ added in v0.9.0
type OnePasswordSDKProvider struct {
// contains filtered or unexported fields
}
OnePasswordSDKProvider implements the Provider interface using the 1Password SDK.
func NewOnePasswordSDKProvider ¶ added in v0.9.0
func NewOnePasswordSDKProvider(vault OnePasswordVault) *OnePasswordSDKProvider
NewOnePasswordSDKProvider creates a new OnePasswordSDKProvider instance.
func (*OnePasswordSDKProvider) Account ¶ added in v0.10.0
func (s *OnePasswordSDKProvider) Account() string
Account returns the label of the service account that this provider authenticates with. Every SDK provider shares one token, so they all report the same label.
func (*OnePasswordSDKProvider) Check ¶ added in v0.10.0
func (s *OnePasswordSDKProvider) Check() error
Check confirms that the service account token authenticates. It lists the vaults the token can see.
func (*OnePasswordSDKProvider) LoadSecrets ¶ added in v0.9.0
func (s *OnePasswordSDKProvider) LoadSecrets() error
LoadSecrets marks the provider as unlocked.
type OnePasswordVault ¶ added in v0.10.0
OnePasswordVault identifies the 1Password vault that a 1Password provider reads. ID is the alias that secret() references, Name is the vault name, and URL is the account.
type Provider ¶ added in v0.9.0
type Provider interface {
// LoadSecrets loads/unlocks the secret store.
LoadSecrets() error
// Resolve fetches a secret value by reference.
// Returns (value, handled, error). handled=false means this
// provider doesn't own the requested vault.
Resolve(ref SecretRef) (string, bool, error)
}
Provider is the minimal contract for secret backends.
type Resolver ¶ added in v0.9.0
type Resolver struct {
// contains filtered or unexported fields
}
Resolver dispatches secret references across configured providers and serves as the evaluator helper implementation.
func NewResolver ¶ added in v0.9.0
NewResolver creates a Resolver from the given providers and shell.
func (*Resolver) CheckReachable ¶ added in v0.10.0
CheckReachable confirms that each 1Password account is reachable, with one check per account. Each check shows as a progress step under ctx. It checks every account and returns all failures joined, so one run reports every unreachable account.
func (*Resolver) EvaluateHelper ¶ added in v0.9.0
EvaluateHelper is the expr helper callback for secret(vault, item[, field]). On first pass (deferred=false), returns DeferredError. On second pass (deferred=true), resolves the secret.
type SecretRef ¶ added in v0.9.0
type SecretRef struct {
Vault string // "sops" or a 1Password vault ID
Item string // item name or SOPS key path
Field string // field name (empty for SOPS)
}
SecretRef is the canonical internal representation of a secret reference. All notation formats normalize to this before resolution.
type Shims ¶
type Shims struct {
shims.Shims
DecryptFile func(string, string) ([]byte, error)
NewOnePasswordClient func(context.Context, ...onepassword.ClientOption) (*onepassword.Client, error)
ResolveSecret func(*onepassword.Client, context.Context, string) (string, error)
Command func(name string, arg ...string) *exec.Cmd
CmdOutput func(ctx context.Context, cmd *exec.Cmd) (stdout []byte, stderr []byte, err error)
ListVaults func(*onepassword.Client, context.Context) error
WatchInterrupt func() (<-chan struct{}, func())
HintWriter io.Writer
}
Shims holds the shared system call primitives and the secrets-specific provider shims.
func NewShims ¶
func NewShims() *Shims
NewShims returns a Shims with every field set to its real implementation. DecryptFile runs sops and returns its stderr as the error text when sops exits with a failure. CmdOutput runs a command under a context and returns its stdout and stderr separately. WatchInterrupt reports an interrupt signal on its channel until its stop function runs.
type SopsProvider ¶ added in v0.9.0
type SopsProvider struct {
// contains filtered or unexported fields
}
SopsProvider implements the Provider interface using SOPS for decryption.
func NewSopsProvider ¶ added in v0.9.0
func NewSopsProvider(configPath string) *SopsProvider
NewSopsProvider creates a new SopsProvider instance.
func (*SopsProvider) LoadSecrets ¶ added in v0.9.0
func (s *SopsProvider) LoadSecrets() error
LoadSecrets loads and decrypts secrets from all existing secrets files, including the conventionally-unencrypted secrets.yaml/secrets.yml names: content decides whether a file is SOPS-encrypted, not its name, since an operator's own SOPS file can be named either way. A secrets.yaml/secrets.yml that fails to decrypt is refused with a clear error naming the path rather than the raw sops failure, since the far more likely cause is a genuinely plaintext file that was never encrypted (and, without a matching .gitignore entry, at risk of being committed).