confz

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EnvConsulAddr  = "CONSUL_ADDR"
	EnvConsulToken = "CONSUL_TOKEN"
)
View Source
const (
	EnvVaultAddr     = "VAULT_ADDR"
	EnvVaultRoleId   = "VAULT_ROLE_ID"
	EnvVaultSecretId = "VAULT_SECRET_ID"
	EnvVaultTmpDir   = "VAULT_TMP_DIR"
)
View Source
const (
	EnvConfigKey = "CONFIG_KEY"
)

Variables

This section is empty.

Functions

func ConsulGet added in v0.5.0

func ConsulGet(key string) ([]byte, error)

func Decode

func Decode(obj any, secretFetcher SecretFetcher, encDecoder SecretFetcher) (any, error)

Decode decrypts the encrypted string fields start with `ENC~` in fields tree of obj and returns the decrypted obj.

func Decrypt added in v0.2.0

func Decrypt(v any) (any, error)

func DecryptInplace added in v0.3.0

func DecryptInplace(v any) error

func FileExists

func FileExists(file string) (bool, error)

func Md5Hex

func Md5Hex(data []byte) string

Md5Hex returns the md5 hex string of data.

func NewAppRoleVaultClient

func NewAppRoleVaultClient(
	addr string,
	roleId string,
	secretId string,
) (*vault.Client, error)

func NewEnvAppRoleVaultClient

func NewEnvAppRoleVaultClient() (*vault.Client, error)

Types

type EncDecoder

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

func NewDefaultEncDecoder

func NewDefaultEncDecoder() *EncDecoder

func NewEncDecoder

func NewEncDecoder(key string) *EncDecoder

func (*EncDecoder) Fetch

func (d *EncDecoder) Fetch(ctx context.Context, key string) (string, error)

type LazyVaultSecretFetcher

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

func NewLazyVaultSecretFetcher

func NewLazyVaultSecretFetcher() *LazyVaultSecretFetcher

func (*LazyVaultSecretFetcher) Fetch

func (f *LazyVaultSecretFetcher) Fetch(ctx context.Context, secretKey string) (string, error)

type SecretFetcher

type SecretFetcher interface {
	Fetch(ctx context.Context, key string) (string, error)
}

type VaultConf

type VaultConf struct {
	Addr  string `json:"addr,env=VAULT_ADDR"`
	Token string `json:"token,env=VAULT_TOKEN"`
}

type VaultSecretFetcher

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

func NewVaultSecretFetcher

func NewVaultSecretFetcher(client *vault.Client) *VaultSecretFetcher

func (*VaultSecretFetcher) Close

func (f *VaultSecretFetcher) Close() error

func (*VaultSecretFetcher) Fetch

func (f *VaultSecretFetcher) Fetch(ctx context.Context, secretKey string) (string, error)

Fetch returns the value of the key in the given path. path format: {mount}/{path}/{key} cache key: {mount}/{path}

Directories

Path Synopsis
adapter
zero Module

Jump to

Keyboard shortcuts

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