{"modulePath":"github.com/windsorcli/cli","version":"v0.10.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package secrets\n\n## Functions\n\n```go\nfunc IsCacheable(expr string) bool\n```\nIsCacheable reports whether an expression is a standalone secret reference eligible for TF\\_VAR cache reuse.\n\n```go\nfunc NormalizeExpression(expr string) (string, bool)\n```\nNormalizeExpression 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.\n\n```go\nfunc NormalizeLegacyBraces(value string) string\n```\nNormalizeLegacyBraces converts ${{ expr }} to ${ expr }.\n\n## Types\n\n```go\ntype Checker interface {\n\tAccount() string\n\tCheck() error\n}\n```\nChecker 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.\n\n```go\ntype DeferredError struct {\n\tExpression string\n\tMessage    string\n}\n```\nDeferredError signals that a secret expression should be preserved for later evaluation. This is not an error condition but a control-flow signal.\n\n```go\nfunc (e *DeferredError) Error() string\n```\n\n```go\ntype MockProvider struct {\n\tLoadSecretsFunc func() error\n\tResolveFunc     func(ref SecretRef) (string, bool, error)\n}\n```\nMockProvider is a mock implementation of the Provider interface for testing.\n\n```go\nfunc NewMockProvider() *MockProvider\n```\nNewMockProvider creates a new MockProvider instance.\n\n```go\nfunc (m *MockProvider) LoadSecrets() error\n```\nLoadSecrets calls the mock LoadSecretsFunc if set, otherwise returns nil.\n\n```go\nfunc (m *MockProvider) Resolve(ref SecretRef) (string, bool, error)\n```\nResolve calls the mock ResolveFunc if set, otherwise returns unhandled.\n\n```go\ntype OnePasswordCLIProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nOnePasswordCLIProvider implements the Provider interface using the 1Password CLI.\n\n```go\nfunc NewOnePasswordCLIProvider(vault OnePasswordVault) *OnePasswordCLIProvider\n```\nNewOnePasswordCLIProvider creates a new OnePasswordCLIProvider instance.\n\n```go\nfunc (s *OnePasswordCLIProvider) Account() string\n```\nAccount returns the 1Password account this provider reads.\n\n```go\nfunc (s *OnePasswordCLIProvider) Check() error\n```\nCheck confirms that the account is reachable and signed in. It runs op whoami for the account.\n\n```go\nfunc (s *OnePasswordCLIProvider) LoadSecrets() error\n```\nLoadSecrets marks the provider as unlocked.\n\n```go\nfunc (s *OnePasswordCLIProvider) Resolve(ref SecretRef) (string, bool, error)\n```\nResolve 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.\n\n```go\ntype OnePasswordSDKProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nOnePasswordSDKProvider implements the Provider interface using the 1Password SDK.\n\n```go\nfunc NewOnePasswordSDKProvider(vault OnePasswordVault) *OnePasswordSDKProvider\n```\nNewOnePasswordSDKProvider creates a new OnePasswordSDKProvider instance.\n\n```go\nfunc (s *OnePasswordSDKProvider) Account() string\n```\nAccount 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.\n\n```go\nfunc (s *OnePasswordSDKProvider) Check() error\n```\nCheck confirms that the service account token authenticates. It lists the vaults the token can see.\n\n```go\nfunc (s *OnePasswordSDKProvider) LoadSecrets() error\n```\nLoadSecrets marks the provider as unlocked.\n\n```go\nfunc (s *OnePasswordSDKProvider) Resolve(ref SecretRef) (string, bool, error)\n```\nResolve fetches a secret from 1Password SDK. Returns handled=true only if the vault ID matches.\n\n```go\ntype OnePasswordVault struct {\n\tID   string\n\tName string\n\tURL  string\n}\n```\nOnePasswordVault 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.\n\n```go\ntype Provider interface {\n\t// LoadSecrets loads/unlocks the secret store.\n\tLoadSecrets() error\n\n\t// Resolve fetches a secret value by reference.\n\t// Returns (value, handled, error). handled=false means this\n\t// provider doesn't own the requested vault.\n\tResolve(ref SecretRef) (string, bool, error)\n}\n```\nProvider is the minimal contract for secret backends.\n\n```go\ntype Resolver struct {\n\t// contains filtered or unexported fields\n}\n```\nResolver dispatches secret references across configured providers and serves as the evaluator helper implementation.\n\n```go\nfunc NewResolver(providers []Provider, sh shell.Shell) *Resolver\n```\nNewResolver creates a Resolver from the given providers and shell.\n\n```go\nfunc (r *Resolver) CheckReachable(ctx context.Context) error\n```\nCheckReachable 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.\n\n```go\nfunc (r *Resolver) EvaluateHelper(params []any, deferred bool) (any, error)\n```\nEvaluateHelper 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.\n\n```go\nfunc (r *Resolver) LoadAll() error\n```\nLoadAll calls LoadSecrets on every provider.\n\n```go\nfunc (r *Resolver) Resolve(ref SecretRef) (string, error)\n```\nResolve finds the right provider and returns the secret value. Registers the value with shell for scrubbing.\n\n```go\ntype SecretRef struct {\n\tVault string // \"sops\" or a 1Password vault ID\n\tItem  string // item name or SOPS key path\n\tField string // field name (empty for SOPS)\n}\n```\nSecretRef is the canonical internal representation of a secret reference. All notation formats normalize to this before resolution.\n\n```go\ntype Shims struct {\n\tshims.Shims\n\tDecryptFile          func(string, string) ([]byte, error)\n\tNewOnePasswordClient func(context.Context, ...onepassword.ClientOption) (*onepassword.Client, error)\n\tResolveSecret        func(*onepassword.Client, context.Context, string) (string, error)\n\tCommand              func(name string, arg ...string) *exec.Cmd\n\tCmdOutput            func(ctx context.Context, cmd *exec.Cmd) (stdout []byte, stderr []byte, err error)\n\tListVaults           func(*onepassword.Client, context.Context) error\n\tWatchInterrupt       func() (\u003c-chan struct{}, func())\n\tHintWriter           io.Writer\n}\n```\nShims holds the shared system call primitives and the secrets-specific provider shims.\n\n```go\nfunc NewShims() *Shims\n```\nNewShims 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.\n\n```go\ntype SopsProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nSopsProvider implements the Provider interface using SOPS for decryption.\n\n```go\nfunc NewSopsProvider(configPath string) *SopsProvider\n```\nNewSopsProvider creates a new SopsProvider instance.\n\n```go\nfunc (s *SopsProvider) LoadSecrets() error\n```\nLoadSecrets 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).\n\n```go\nfunc (s *SopsProvider) Resolve(ref SecretRef) (string, bool, error)\n```\nResolve fetches a SOPS secret by reference. Returns handled=true only if the vault is \"sops\" (case-insensitive).\n\n","path":"github.com/windsorcli/cli/pkg/runtime/secrets","name":"secrets","synopsis":"","isRedistributable":true}
