secret

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Providers

func Providers() []string

Providers lists registered secret provider names.

func RegisterProvider

func RegisterProvider(name string, constructor ProviderConstructor) error

RegisterProvider registers a secret backend provider by name (case-insensitive).

Types

type JsonProvider

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

JsonProvider implements a simple secret provider backed by a map. It can be initialized from a JSON file and supports nested configurations.

func (*JsonProvider) Get

func (j *JsonProvider) Get(ctx context.Context, key string) (string, error)

Get returns the plaintext value for a logical key. If the value is a string, it's returned as-is. If the value is a complex object (map, array), it's marshaled to JSON.

func (*JsonProvider) Put

func (j *JsonProvider) Put(ctx context.Context, key, value string) error

Put stores a plaintext value at the logical key. Note: This only updates the in-memory store and does not persist to disk.

type Provider

type Provider interface {
	// Get returns the plaintext value for a logical key.
	Get(ctx context.Context, key string) (string, error)
	// Put stores a plaintext value at the logical key, creating or updating as needed.
	Put(ctx context.Context, key, value string) error
}

Provider is the abstraction for secret backends (Vault, AWS KMS, GCP KMS, local, etc.). Implementations must be stateless and receive all config through the constructor.

func NewJsonProvider

func NewJsonProvider(config map[string]any) (Provider, error)

NewJsonProvider creates a new JsonProvider. If the config contains a "path" key, it attempts to load secrets from that JSON file.

type ProviderConstructor

type ProviderConstructor func(config map[string]any) (Provider, error)

ProviderConstructor builds a Provider from decrypted config.

func LookupProvider

func LookupProvider(name string) (ProviderConstructor, bool)

LookupProvider finds a provider constructor by name.

Jump to

Keyboard shortcuts

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