secret

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher interface {
	// FetchData returns cached file data if valid,
	// otherwise it tries to fetch new data and update cache first.
	FetchData(ctx context.Context) (string, error)
}

Fetcher represents a struct that can fetch file data for clients

type FileFetcher

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

func NewFileFetcher

func NewFileFetcher(ctx context.Context, filePath string, opts ...FileFetcherOption) (*FileFetcher, error)

func (*FileFetcher) FetchData

func (fetcher *FileFetcher) FetchData(_ context.Context) ([]byte, error)

FetchData fetches the data stored in the fetcher

type FileFetcherOption

type FileFetcherOption func(*FileFetcher)

func WithAllowInitialFailure

func WithAllowInitialFailure(allow bool) FileFetcherOption

WithAllowInitialFailure allows for ignoring errors from the initial fetchAndStoreFileContents() call. Disabled by default.

func WithCreateDirIfNotExist

func WithCreateDirIfNotExist(create bool) FileFetcherOption

WithCreateDirIfNotExist attempts to create the directory for the file path provided in order to watch the dir when the file doesn't exist. The dir is created with 0755 permissions. Disabled by default.

func WithForceFileRefreshInterval

func WithForceFileRefreshInterval(fileRefreshInterval time.Duration) FileFetcherOption

WithForceFileRefreshInterval enables a ticker to force refresh the file at a particular cadence

func WithMaxFileSize

func WithMaxFileSize(msize int64) FileFetcherOption

func WithOnFileUpdateListener

func WithOnFileUpdateListener(f func(context.Context, io.Reader)) FileFetcherOption

WithOnFileUpdateListener sets a callback function to be called when the file is updated

type KeyFileFetcher

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

func NewKeyFileFetcher

func NewKeyFileFetcher(ctx context.Context, opts ...KeyFileFetcherOption) (*KeyFileFetcher, error)

func (*KeyFileFetcher) FetchSecretKey

func (fetcher *KeyFileFetcher) FetchSecretKey(ctx context.Context) (string, error)

FetchSecretKey fetches the token stored in the fetcher struct

func (*KeyFileFetcher) FetchToken

func (fetcher *KeyFileFetcher) FetchToken(ctx context.Context) (string, error)

FetchToken is an adapter for downstream consumers to use this directly

type KeyFileFetcherOption

type KeyFileFetcherOption func(*KeyFileFetcher)

func WithKeyFileFetcherOptions

func WithKeyFileFetcherOptions(opts ...FileFetcherOption) KeyFileFetcherOption

WithKeyFileFetcherOptions forwards FileFetcher options when key file mode is used.

func WithOnKeyFileUpdateListener

func WithOnKeyFileUpdateListener(f func(context.Context, io.Reader)) KeyFileFetcherOption

WithOnKeyFileUpdateListener sets a callback function to be called when the key file is updated

func WithSecretKey

func WithSecretKey(secretKey string) KeyFileFetcherOption

WithSecretKey provides a default secret key to use if the file is not specified

func WithSecretKeyEnvVar

func WithSecretKeyEnvVar(secretKeyEnvVar string) KeyFileFetcherOption

WithSecretKeyEnvVar specifies the environment variable the secret key file may be found in for error messages

func WithSecretKeyFile

func WithSecretKeyFile(secretKeyFile string) KeyFileFetcherOption

WithSecretKeyFile specifies the secret key file to read from

type TokenFetcher

type TokenFetcher interface {
	// FetchToken returns the token in the cache if it think the token is
	// valid, otherwise, it tries to fetch a new token and update cache
	// first.
	FetchToken(ctx context.Context) (string, error)
}

TokenFetcher represents a struct that can fetch tokens for clients

Jump to

Keyboard shortcuts

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