{"modulePath":"github.com/windsorcli/cli","version":"v0.7.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package secrets\n\n## Types\n\n```go\ntype BaseSecretsProvider struct {\n\tSecretsProvider\n\t// contains filtered or unexported fields\n}\n```\nBaseSecretsProvider is a base implementation of the SecretsProvider interface\n\n```go\nfunc NewBaseSecretsProvider(injector di.Injector) *BaseSecretsProvider\n```\nNewBaseSecretsProvider creates a new BaseSecretsProvider instance\n\n```go\nfunc (s *BaseSecretsProvider) GetSecret(key string) (string, error)\n```\nGetSecret retrieves a secret value for the specified key\n\n```go\nfunc (s *BaseSecretsProvider) Initialize() error\n```\nInitialize initializes the secrets provider\n\n```go\nfunc (s *BaseSecretsProvider) LoadSecrets() error\n```\nLoadSecrets loads the secrets from the specified path\n\n```go\nfunc (s *BaseSecretsProvider) ParseSecrets(input string) (string, error)\n```\nParseSecrets is a placeholder function for parsing secrets\n\n```go\ntype MockSecretsProvider struct {\n\tBaseSecretsProvider\n\tInitializeFunc   func() error\n\tLoadSecretsFunc  func() error\n\tGetSecretFunc    func(key string) (string, error)\n\tParseSecretsFunc func(input string) (string, error)\n\tUnlockFunc       func() error\n}\n```\nMockSecretsProvider is a mock implementation of the SecretsProvider interface for testing purposes\n\n```go\nfunc NewMockSecretsProvider(injector di.Injector) *MockSecretsProvider\n```\nNewMockSecretsProvider creates a new instance of MockSecretsProvider\n\n```go\nfunc (m *MockSecretsProvider) GetSecret(key string) (string, error)\n```\nGetSecret calls the mock GetSecretFunc if set, otherwise returns an error indicating the secret was not found\n\n```go\nfunc (m *MockSecretsProvider) Initialize() error\n```\nInitialize calls the mock InitializeFunc if set, otherwise returns nil\n\n```go\nfunc (m *MockSecretsProvider) LoadSecrets() error\n```\nLoadSecrets calls the mock LoadSecretsFunc if set, otherwise returns nil\n\n```go\nfunc (m *MockSecretsProvider) ParseSecrets(input string) (string, error)\n```\nParseSecrets calls the mock ParseSecretsFunc if set, otherwise returns the input unchanged\n\n```go\nfunc (m *MockSecretsProvider) Unlock() error\n```\nUnlock calls the mock UnlockFunc if set, otherwise returns nil\n\n```go\ntype OnePasswordCLISecretsProvider struct {\n\t*BaseSecretsProvider\n\t// contains filtered or unexported fields\n}\n```\nOnePasswordCLISecretsProvider is a struct that implements the SecretsProvider interface using 1Password CLI.\n\n```go\nfunc NewOnePasswordCLISecretsProvider(vault secretsConfigType.OnePasswordVault, injector di.Injector) *OnePasswordCLISecretsProvider\n```\nNewOnePasswordCLISecretsProvider creates a new OnePasswordCLISecretsProvider instance\n\n```go\nfunc (s *OnePasswordCLISecretsProvider) GetSecret(key string) (string, error)\n```\nGetSecret retrieves a secret value for the given key using 1Password CLI. Registers the secret for shell scrubbing to prevent exposure in output. Executes the CLI directly to avoid leaking secrets before registration. If locked, returns a masked value. Key format: 'secret.field'. Returns the secret or error on failure.\n\n```go\nfunc (s *OnePasswordCLISecretsProvider) ParseSecrets(input string) (string, error)\n```\nParseSecrets identifies and replaces ${{ op.\\\u003cid\u003e.\\\u003csecret\u003e.\\\u003cfield\u003e }} patterns in the input with corresponding secret values from 1Password, ensuring the id matches the vault ID.\n\n```go\ntype OnePasswordSDKSecretsProvider struct {\n\t*BaseSecretsProvider\n\t// contains filtered or unexported fields\n}\n```\nOnePasswordSDKSecretsProvider is an implementation of the SecretsProvider interface that uses the 1Password SDK to manage secrets.\n\n```go\nfunc NewOnePasswordSDKSecretsProvider(vault secretsConfigType.OnePasswordVault, injector di.Injector) *OnePasswordSDKSecretsProvider\n```\nNewOnePasswordSDKSecretsProvider creates a new OnePasswordSDKSecretsProvider instance\n\n```go\nfunc (s *OnePasswordSDKSecretsProvider) GetSecret(key string) (string, error)\n```\nGetSecret retrieves a secret value for the specified key and automatically registers it with the shell for output scrubbing. It first checks if the provider is unlocked. If not, it returns a masked value. It then ensures the 1Password client is initialized using a service account token from the environment. The key is split into item and field parts, and the item name is sanitized. A secret reference URI is constructed and used to resolve the secret value from 1Password. If successful, the secret value is registered with the shell's scrubbing system and returned; otherwise, an error is reported.\n\n```go\nfunc (s *OnePasswordSDKSecretsProvider) Initialize() error\n```\nInitialize initializes the secrets provider\n\n```go\nfunc (s *OnePasswordSDKSecretsProvider) ParseSecrets(input string) (string, error)\n```\nParseSecrets identifies and replaces ${{ op.\\\u003cid\u003e.\\\u003csecret\u003e.\\\u003cfield\u003e }} patterns in the input with corresponding secret values from 1Password, ensuring the id matches the vault ID.\n\n```go\ntype SecretsProvider interface {\n\t// Initialize initializes the secrets provider\n\tInitialize() error\n\n\t// LoadSecrets loads the secrets from the specified path\n\tLoadSecrets() error\n\n\t// GetSecret retrieves a secret value for the specified key\n\tGetSecret(key string) (string, error)\n\n\t// ParseSecrets parses a string and replaces ${{ secrets.\u003ckey\u003e }} references with their values\n\tParseSecrets(input string) (string, error)\n}\n```\nSecretsProvider defines the interface for handling secrets operations\n\n```go\ntype Shims struct {\n\tStat                 func(string) (os.FileInfo, error)\n\tYAMLUnmarshal        func([]byte, any) error\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(cmd *exec.Cmd) ([]byte, error)\n}\n```\nShims provides mockable wrappers around system and runtime functions\n\n```go\nfunc NewShims() *Shims\n```\nNewShims creates a new Shims instance with default implementations\n\n```go\ntype SopsSecretsProvider struct {\n\t*BaseSecretsProvider\n\t// contains filtered or unexported fields\n}\n```\nSopsSecretsProvider is a struct that implements the SecretsProvider interface using SOPS for decryption.\n\n```go\nfunc NewSopsSecretsProvider(configPath string, injector di.Injector) *SopsSecretsProvider\n```\nNewSopsSecretsProvider creates a new instance of SopsSecretsProvider.\n\n```go\nfunc (s *SopsSecretsProvider) GetSecret(key string) (string, error)\n```\nGetSecret retrieves a secret value for the specified key and automatically registers it with the shell for output scrubbing. If the provider is locked, it returns a masked value. When unlocked, it returns the actual secret value and registers it with the shell's scrubbing system to prevent accidental exposure in command output.\n\n```go\nfunc (s *SopsSecretsProvider) LoadSecrets() error\n```\nLoadSecrets loads and decrypts the secrets from the SOPS-encrypted file.\n\n```go\nfunc (s *SopsSecretsProvider) ParseSecrets(input string) (string, error)\n```\nParseSecrets parses a string and replaces ${{ sops.\\\u003ckey\u003e }} references with their values\n\n","path":"github.com/windsorcli/cli/pkg/secrets","name":"secrets","synopsis":"","isRedistributable":true}
