handlers

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandlerRegistry map[string]HandlerFactory = map[string]HandlerFactory{
	"literal": MakeInlineFactory(func(arg []string) (map[string]string, error) {
		return map[string]string{"name": arg[1], "value": arg[2], "type": "literal"}, nil
	}, func(input map[string]string) (SecretHandler, error) {
		return &literalHandler{key: input["name"], value: input["value"]}, nil
	}),

	"file": MakeInlineFactory(func(arg []string) (map[string]string, error) {
		return map[string]string{"name": arg[1], "path": arg[2], "type": "file"}, nil
	}, func(input map[string]string) (SecretHandler, error) {
		return &fileHandler{key: input["name"], file: input["path"]}, nil
	}),

	"sema-literal": MakeInlineFactory(func(arg []string) (map[string]string, error) {
		return map[string]string{"name": arg[1], "semaKey": arg[2], "type": "sema-literal"}, nil
	}, func(input map[string]string) (SecretHandler, error) {
		return &semaHandlerLiteral{key: input["name"], secret: input["semaKey"]}, nil
	}),
}

HandlerRegistry stores HandlerFactories

Functions

This section is empty.

Types

type ConcreteSecretHandler

type ConcreteSecretHandler struct {
	SecretHandler
}

ConcreteSecretHandler is a way to implement the Unmarshaller (UnmarshalFlag) interface from go-flags on the interface type SecretHandler.

func InjectSemaClient

func InjectSemaClient(handlers []ConcreteSecretHandler, client secretmanager.KVClient, opts SecretHandlerOptions) []ConcreteSecretHandler

InjectSemaClient -

func (*ConcreteSecretHandler) UnmarshalFlag

func (c *ConcreteSecretHandler) UnmarshalFlag(value string) error

UnmarshalFlag -

type HandlerFactory

type HandlerFactory interface {
	ParseCommandline(args []string) (SecretHandler, error)
	ParseConfig(arg map[string]string) (SecretHandler, error)
}

HandlerFactory needs to be implemented to expose new input formats

func MakeInlineFactory

func MakeInlineFactory(argsToMap func(arg []string) (map[string]string, error), mapToSecret func(arg map[string]string) (SecretHandler, error)) HandlerFactory

MakeInlineFactory -

type InlineFactory

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

InlineFactory -

func (InlineFactory) ParseCommandline

func (f InlineFactory) ParseCommandline(args []string) (SecretHandler, error)

ParseCommandline -

func (InlineFactory) ParseConfig

func (f InlineFactory) ParseConfig(arg map[string]string) (SecretHandler, error)

ParseConfig -

type ResolvedSecret

type ResolvedSecret interface {
	String() string
	Annotation() string
	GetSecretValue() (interface{}, error)
}

ResolvedSecret is something that does not necessarily have a value at the start; it is a placeholder that can be resolved later.

type ResolvedSecretSema

type ResolvedSecretSema struct {
	Key    string
	Client secretmanager.KVClient
	KV     secretmanager.KVValue
}

ResolvedSecretSema -

func (ResolvedSecretSema) Annotation

func (r ResolvedSecretSema) Annotation() string

func (ResolvedSecretSema) GetSecretValue

func (r ResolvedSecretSema) GetSecretValue() (interface{}, error)

func (ResolvedSecretSema) String

func (r ResolvedSecretSema) String() string

type SecretHandler

type SecretHandler interface {
	Prepare(bucket map[string]bool)
	Populate(bucket map[string][]byte)
	Annotate(func(key string, value string))
}

SecretHandler is the shared interface common between all handlers: they can all populate values in a blob of secret data.

func MakeSecretHandler

func MakeSecretHandler(handler, name, value string) (SecretHandler, error)

MakeSecretHandler resolves the different kinds of handlers

func ParseSecretHandler

func ParseSecretHandler(input map[string]string) (SecretHandler, error)

ParseSecretHandler parses the different types of secret definitions into correct MakeSecretHandler calls

type SecretHandlerOptions

type SecretHandlerOptions struct {
	Prefix  string
	Mock    bool
	Verbose bool
}

SecretHandlerOptions -

type SecretHandlerWithSema

type SecretHandlerWithSema interface {
	InjectSemaClient(client secretmanager.KVClient, opts SecretHandlerOptions)
}

SecretHandlerWithSema implement this interface to get a SemaClient injected

Jump to

Keyboard shortcuts

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