secrets

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseKeys

func ParseKeys(path string) []string

ParseKeys processes a string path that may contain mixed dot and bracket notations, extracting and returning an array of keys. It handles quoted strings within brackets and treats consecutive dots as empty keys unless they follow a closing bracket.

Types

type BaseSecretsProvider

type BaseSecretsProvider struct {
	// contains filtered or unexported fields
}

BaseSecretsProvider is a base implementation of the SecretsProvider interface

func NewBaseSecretsProvider

func NewBaseSecretsProvider(injector di.Injector) *BaseSecretsProvider

NewBaseSecretsProvider creates a new BaseSecretsProvider instance

func (*BaseSecretsProvider) GetSecret

func (s *BaseSecretsProvider) GetSecret(key string) (string, error)

GetSecret retrieves a secret value for the specified key

func (*BaseSecretsProvider) Initialize

func (s *BaseSecretsProvider) Initialize() error

Initialize initializes the secrets provider

func (*BaseSecretsProvider) LoadSecrets

func (s *BaseSecretsProvider) LoadSecrets() error

LoadSecrets loads the secrets from the specified path

func (*BaseSecretsProvider) ParseSecrets

func (s *BaseSecretsProvider) ParseSecrets(input string) (string, error)

ParseSecrets is a placeholder function for parsing secrets

type MockSecretsProvider

type MockSecretsProvider struct {
	InitializeFunc   func() error
	LoadSecretsFunc  func() error
	GetSecretFunc    func(key string) (string, error)
	ParseSecretsFunc func(input string) (string, error)
	UnlockFunc       func() error
}

MockSecretsProvider is a mock implementation of the SecretsProvider interface for testing purposes

func NewMockSecretsProvider

func NewMockSecretsProvider() *MockSecretsProvider

NewMockSecretsProvider creates a new instance of MockSecretsProvider

func (*MockSecretsProvider) GetSecret

func (m *MockSecretsProvider) GetSecret(key string) (string, error)

GetSecret calls the mock GetSecretFunc if set, otherwise returns an error indicating the secret was not found

func (*MockSecretsProvider) Initialize

func (m *MockSecretsProvider) Initialize() error

Initialize calls the mock InitializeFunc if set, otherwise returns nil

func (*MockSecretsProvider) LoadSecrets

func (m *MockSecretsProvider) LoadSecrets() error

LoadSecrets calls the mock LoadSecretsFunc if set, otherwise returns nil

func (*MockSecretsProvider) ParseSecrets

func (m *MockSecretsProvider) ParseSecrets(input string) (string, error)

ParseSecrets calls the mock ParseSecretsFunc if set, otherwise returns the input unchanged

func (*MockSecretsProvider) Unlock

func (m *MockSecretsProvider) Unlock() error

Unlock calls the mock UnlockFunc if set, otherwise returns nil

type OnePasswordCLISecretsProvider

type OnePasswordCLISecretsProvider struct {
	BaseSecretsProvider
	// contains filtered or unexported fields
}

OnePasswordCLISecretsProvider is an implementation of the SecretsProvider interface that uses the 1Password CLI to manage secrets.

func NewOnePasswordCLISecretsProvider

func NewOnePasswordCLISecretsProvider(vault secretsConfigType.OnePasswordVault, injector di.Injector) *OnePasswordCLISecretsProvider

NewOnePasswordCLISecretsProvider creates a new OnePasswordCLISecretsProvider instance

func (*OnePasswordCLISecretsProvider) GetSecret

func (s *OnePasswordCLISecretsProvider) GetSecret(key string) (string, error)

GetSecret retrieves a secret value for the specified key

func (*OnePasswordCLISecretsProvider) ParseSecrets

func (s *OnePasswordCLISecretsProvider) ParseSecrets(input string) (string, error)

ParseSecrets identifies and replaces ${{ op.<id>.<secret>.<field> }} patterns in the input with corresponding secret values from 1Password, ensuring the id matches the vault ID.

type SecretsProvider

type SecretsProvider interface {
	// Initialize initializes the secrets provider
	Initialize() error

	// LoadSecrets loads the secrets from the specified path
	LoadSecrets() error

	// GetSecret retrieves a secret value for the specified key
	GetSecret(key string) (string, error)

	// ParseSecrets parses a string and replaces ${{ secrets.<key> }} references with their values
	ParseSecrets(input string) (string, error)
}

SecretsProvider defines the interface for handling secrets operations

type SopsSecretsProvider

type SopsSecretsProvider struct {
	BaseSecretsProvider
	// contains filtered or unexported fields
}

SopsSecretsProvider is a struct that implements the SecretsProvider interface using SOPS for decryption.

func NewSopsSecretsProvider

func NewSopsSecretsProvider(configPath string, injector di.Injector) *SopsSecretsProvider

NewSopsSecretsProvider creates a new instance of SopsSecretsProvider.

func (*SopsSecretsProvider) GetSecret

func (s *SopsSecretsProvider) GetSecret(key string) (string, error)

GetSecret retrieves a secret value for the specified key

func (*SopsSecretsProvider) LoadSecrets

func (s *SopsSecretsProvider) LoadSecrets() error

LoadSecrets checks for the existence of the SOPS encrypted file, decrypts it, converts the decrypted YAML content into a map of secrets, flattens the map to use full path keys, and stores the secrets in the BaseSecretsProvider, setting the provider to unlocked.

func (*SopsSecretsProvider) ParseSecrets

func (s *SopsSecretsProvider) ParseSecrets(input string) (string, error)

ParseSecrets parses a string and replaces ${{ sops.<key> }} references with their values

Jump to

Keyboard shortcuts

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