secrets

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SourceTypeEnv = "env"
	SourceTypeGCP = "gcp"
)

The set of source types.

Variables

View Source
var ErrNotFound = errors.New("secret not found")

ErrNotFound is used when a secret cannot be found by its name.

Functions

func MustGet

func MustGet(ctx context.Context, source Source, name string) string

MustGet gets the secret of the given name and panics if any error occurs.

Types

type EnvSource

type EnvSource struct{}

EnvSource provides secrets via environment variables.

func (*EnvSource) Close

func (src *EnvSource) Close() error

Close does nothing.

func (*EnvSource) Get

func (src *EnvSource) Get(ctx context.Context, name string) (string, error)

Get looks up the given name as an environment variable.

func (*EnvSource) Type

func (src *EnvSource) Type() SourceType

Type returns the type of this source (environment).

type GCPSource

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

GCPSource provides secrets via GCP secrets.

func NewGCPSource

func NewGCPSource(ctx context.Context) (*GCPSource, error)

NewGCPSource returns a new GCP secret source that derives its information from the given context.

func (*GCPSource) Close

func (g *GCPSource) Close() error

Close closes the underlying GCP client.

func (*GCPSource) Get

func (g *GCPSource) Get(ctx context.Context, name string) (string, error)

Get looks up the given name as a secret in GCP.

func (*GCPSource) Type

func (g *GCPSource) Type() SourceType

Type returns the type of this source (gcp).

type Source

type Source interface {
	Get(ctx context.Context, name string) (string, error)
	Type() SourceType
	Close() error
}

A Source provides the means to look up secrets.

func NewSource

func NewSource(ctx context.Context, sourceType SourceType) (Source, error)

NewSource returns a new source of the given type. Right now configuration details are derived via the given context but in the future there should probably be a config passed in.

type SourceType

type SourceType string

SourceType identifies the type of secret source.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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