orlop

package module
v1.47.7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 65 Imported by: 4

README

orlop

Orlop is the base deck in a ship where the cables are stowed.

It is Ketch's standard (opinionated) library that all of our projects include.

  • Configuration
  • Logging (Logrus)
  • Metrics (OpenTracing/Prometheus)
  • Tracing (OpenTracing/Jaeger)
  • Server setup
  • TLS - leveraging Vault
  • Vault - secrets and certificates

It supports gRPC clients and servers, Swagger and automatic certificate generation for mTLS.

Documentation

Index

Constants

View Source
const (
	// TLSCertificateKey is the key of the TLS certificate in Vault
	TLSCertificateKey = "certificate"
	// TLSPrivateKey is the key of the TLS private key in Vault
	TLSPrivateKey = "private_key"
	// TLSRootCAKey is the key of the TLS root CA in Vault
	TLSRootCAKey = "issuing_ca"
)
View Source
const EnvironmentKey = "KETCH_ENVIRONMENT"

EnvironmentKey is the environment variable we look for to set the environment

Variables

View Source
var (
	ErrInvalidLengthOrlop        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowOrlop          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupOrlop = fmt.Errorf("proto: unexpected end of group")
)
View Source
var AuthToken struct{}

AuthToken is the context key to retrieve the Authentication token from context

Functions

func Connect

func Connect(ctx context.Context, cfg ClientConfig, vault VaultConfig) (*grpc.ClientConn, error)

Connect creates a new client from configuration

func DefaultHTTPHeaders added in v1.44.1

func DefaultHTTPHeaders(options HeaderOptions) func(next http.Handler) http.Handler

DefaultHTTPHeaders is middleware to handle default HTTP headers

func FxContext added in v1.45.0

func FxContext(ctx context.Context) fx.Option

func FxOptions added in v1.45.0

func FxOptions(o ProvidesFxOptions) fx.Option

func FxServiceName added in v1.46.0

func FxServiceName(n string) fx.Option

func GenerateCertificates

func GenerateCertificates(ctx context.Context, vault VaultConfig, cfg CertGenerationConfig, cert *[]byte, key *[]byte) error

GenerateCertificates calls Vault to generate a certificate

func GetVariablesFromConfig

func GetVariablesFromConfig(prefix string, cfg interface{}) ([]string, error)

GetVariablesFromConfig returns the environment variables from the given config object

func LoadEnvironment added in v1.40.0

func LoadEnvironment(env Environment, files ...string)

LoadEnvironment loads the environment variables from the specified files and from the standard locations

func LoadKey

func LoadKey(ctx context.Context, cfg KeyConfig, vault VaultConfig, which string) ([]byte, error)

LoadKey loads the key material based on the config

func LoadPrivateKey

func LoadPrivateKey(key []byte) (*rsa.PrivateKey, error)

LoadPrivateKey loads a private key from the given bytes

func LoadPublicKeys

func LoadPublicKeys(key []byte) (publicKeys []*rsa.PublicKey, err error)

LoadPublicKeys loads an array of public keys from the given bytes

func Logging added in v1.36.0

func Logging(cfg HttpLoggingConfig) func(http.Handler) http.Handler

Logging is middleware to log each HTTP request

func Metrics

func Metrics(next http.Handler) http.Handler

Metrics is middleware for handling metrics

func NewClientTLSConfig

func NewClientTLSConfig(ctx context.Context, cfg TLSConfig, vault VaultConfig) (*tls.Config, error)

NewClientTLSConfig returns a new tls.VaultConfig from the given configuration input

func NewMetricsHandler

func NewMetricsHandler() http.Handler

NewMetricsHandler creates a new MetricsHandler

func NewServerTLSConfig

func NewServerTLSConfig(ctx context.Context, cfg TLSConfig, vault VaultConfig) (*tls.Config, error)

NewServerTLSConfig returns a new tls.VaultConfig from the given configuration input

func RegisterConfigParser

func RegisterConfigParser(typeName string, parser func(value reflect.Value, input string) error)

RegisterConfigParser registers a config parser

func Run

func Run(prefix string, runner interface{}, cfg interface{})

Run loads config and then executes the given runner

func RunGrpcTest added in v1.40.0

func RunGrpcTest(ctx context.Context, t *testing.T, s *TestServer, name string, fn GrpcTestFunc)

RunGrpcTest runs a test function with a client GRPC connection connected to the given server

func RunGrpcTestSuite added in v1.40.0

func RunGrpcTestSuite(ctx context.Context, t *testing.T, serviceName string, options []ServerOption, testCases ...GrpcTestFunc)

RunGrpcTestSuite runs a suite of GRPC tests

func Serve

func Serve(ctx context.Context, serviceName string, options ...ServerOption) error

Serve sets up the server and listens for requests

func ServeLifecycle added in v1.42.0

func ServeLifecycle(params ServeLifecycleParams)

func URLParamFromContext

func URLParamFromContext(ctx context.Context, key string) string

URLParamFromContext returns the url parameter from a context.Context object.

func URLParamFromRequest

func URLParamFromRequest(r *http.Request, key string) string

URLParamFromRequest returns the url parameter from a http.Request object.

func Unmarshal

func Unmarshal(prefix string, cfg interface{}) error

Unmarshal reads configuration into the cfg object

func UnmarshalFromEnv

func UnmarshalFromEnv(prefix string, vars []string, cfg interface{}) error

UnmarshalFromEnv reads configuration into the cfg object from the env vars

Types

type BinaryMarshaler

type BinaryMarshaler struct{}

BinaryMarshaler marshals the given object as a binary object

func (BinaryMarshaler) ContentType

func (BinaryMarshaler) ContentType() string

ContentType returns the Content-Type which this marshaler is responsible for.

func (BinaryMarshaler) Marshal

func (BinaryMarshaler) Marshal(v interface{}) ([]byte, error)

Marshal marshals "v" into byte sequence.

func (BinaryMarshaler) NewDecoder

func (BinaryMarshaler) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a Decoder which reads byte sequence from "r".

func (BinaryMarshaler) NewEncoder

func (BinaryMarshaler) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes bytes sequence into "w".

func (BinaryMarshaler) Unmarshal

func (BinaryMarshaler) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals "data" into "v". "v" must be a pointer value.

type CertGenerationConfig

type CertGenerationConfig struct {
	Enabled    bool
	Path       string `config:"path,default=/pki/issue/"`
	CommonName string
	AltNames   string
	TTL        time.Duration
}

CertGenerationConfig provides the certificate generation configuration

func (CertGenerationConfig) GetEnabled

func (c CertGenerationConfig) GetEnabled() bool

GetEnabled returns true if certificate generation is enabled

type ClientConfig

type ClientConfig struct {
	Name                  string
	URL                   string
	Host                  string
	Port                  int32
	Token                 TokenConfig
	TLS                   TLSConfig
	Headers               map[string]string
	WriteBufferSize       int
	ReadBufferSize        int
	InitialWindowSize     int32
	InitialConnWindowSize int32
	MaxCallRecvMsgSize    int
	MaxCallSendMsgSize    int
	MinConnectTimeout     time.Duration
	ConnTimeout           time.Duration
	Block                 bool
	UserAgent             string
}

ClientConfig is standard configuration of most client commands

func (ClientConfig) GetName

func (c ClientConfig) GetName() string

GetName returns the Name of the client config

func (ClientConfig) GetURL

func (c ClientConfig) GetURL() string

GetURL returns the URL to contact the server

func (ClientConfig) GetUserAgent

func (c ClientConfig) GetUserAgent() string

GetUserAgent returns the user agent

type ContextCredentials

type ContextCredentials struct{}

ContextCredentials provides credentials to the client based on the context

func (ContextCredentials) GetRequestMetadata

func (j ContextCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata returns authorization metadata

func (ContextCredentials) RequireTransportSecurity

func (j ContextCredentials) RequireTransportSecurity() bool

RequireTransportSecurity denotes we require transport security

type Credentials

type Credentials struct {
	Username string
	Password string
}

Credentials provides username/password information

func GetCredentials

func GetCredentials(ctx context.Context, cfg CredentialsConfig, vault VaultConfig) (*Credentials, error)

GetCredentials retrieves credentials

type CredentialsConfig

type CredentialsConfig struct {
	ID       string
	Username string
	Password string
}

CredentialsConfig provides credentials configuration

type Enabled

type Enabled struct {
	Enabled bool
}

Enabled provides an Enabled flag

func (Enabled) GetEnabled

func (c Enabled) GetEnabled() bool

GetEnabled returns true if enabled

type Environment

type Environment string

Environment is a defined environment

func Env

func Env() Environment

Env returns the environment from the environment variables

func (Environment) IsLocal

func (e Environment) IsLocal() bool

IsLocal returns true if the environment is not defined (aka local)

func (Environment) IsProduction

func (e Environment) IsProduction() bool

IsProduction returns true if the environment is the production environment.

func (Environment) IsTest

func (e Environment) IsTest() bool

IsTest returns true if the environment is the test environment

func (Environment) String

func (e Environment) String() string

String returns a string version of the environment.

type ErrorMessage

type ErrorMessage struct {
	// Code description
	Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	// Error description
	Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	// Message description
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
}

ErrorMessage represents an error message

func (*ErrorMessage) Descriptor

func (*ErrorMessage) Descriptor() ([]byte, []int)

func (*ErrorMessage) Equal

func (this *ErrorMessage) Equal(that interface{}) bool

func (*ErrorMessage) GetCode

func (m *ErrorMessage) GetCode() int32

func (*ErrorMessage) GetError

func (m *ErrorMessage) GetError() string

func (*ErrorMessage) GetMessage

func (m *ErrorMessage) GetMessage() string

func (*ErrorMessage) GoString

func (this *ErrorMessage) GoString() string

func (*ErrorMessage) Marshal

func (m *ErrorMessage) Marshal() (dAtA []byte, err error)

func (*ErrorMessage) MarshalTo

func (m *ErrorMessage) MarshalTo(dAtA []byte) (int, error)

func (*ErrorMessage) MarshalToSizedBuffer

func (m *ErrorMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ErrorMessage) ProtoMessage

func (*ErrorMessage) ProtoMessage()

func (*ErrorMessage) Reset

func (m *ErrorMessage) Reset()

func (*ErrorMessage) Size

func (m *ErrorMessage) Size() (n int)

func (*ErrorMessage) String

func (this *ErrorMessage) String() string

func (*ErrorMessage) Unmarshal

func (m *ErrorMessage) Unmarshal(dAtA []byte) error

func (*ErrorMessage) XXX_DiscardUnknown

func (m *ErrorMessage) XXX_DiscardUnknown()

func (*ErrorMessage) XXX_Marshal

func (m *ErrorMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ErrorMessage) XXX_Merge

func (m *ErrorMessage) XXX_Merge(src proto.Message)

func (*ErrorMessage) XXX_Size

func (m *ErrorMessage) XXX_Size() int

func (*ErrorMessage) XXX_Unmarshal

func (m *ErrorMessage) XXX_Unmarshal(b []byte) error

type File

type File struct {
	File string
}

File provides a filename

func (File) GetFile

func (f File) GetFile() string

GetFile returns the filename

type GrpcTestFunc added in v1.40.0

type GrpcTestFunc func(ctx context.Context, t *testing.T, conn *grpc.ClientConn)

GrpcTestFunc defines a function called for a GRPC test

type HasEnabled

type HasEnabled interface {
	GetEnabled() bool
}

HasEnabled denotes an object provides an Enabled flag

type HasFile

type HasFile interface {
	GetFile() string
}

HasFile denotes an object provides a filename

type HeaderOptions added in v1.44.1

type HeaderOptions struct {
	AllowedOrigins []string
}

type HealthChecker

type HealthChecker func(ctx context.Context, check string) (interface{}, error)

HealthChecker provides the capability to check the health

type HealthHandler

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

HealthHandler is a HTTP handler for checking health

func (HealthHandler) ServeHTTP

func (h HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves HTTP requests for `/healthz/`, optionally with a specific check appended

type HttpClient added in v1.35.0

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

HttpClient provides a wrapper around http.Client, providing automatic TLS setup and header management

func NewHttpClient added in v1.35.0

func NewHttpClient(ctx context.Context, cfg ClientConfig, vault VaultConfig) (*HttpClient, error)

NewHttpClient creates a new HttpClient

func (*HttpClient) Delete added in v1.35.0

func (c *HttpClient) Delete(ctx context.Context, url string) (resp *http.Response, err error)

Delete performs a DELETE against the given relative url

func (*HttpClient) Do added in v1.35.0

func (c *HttpClient) Do(req *http.Request) (*http.Response, error)

Do executes the request

func (*HttpClient) Get added in v1.35.0

func (c *HttpClient) Get(ctx context.Context, url string) (resp *http.Response, err error)

Get performs a GET against the given relative url

func (*HttpClient) GetJSON added in v1.35.0

func (c *HttpClient) GetJSON(ctx context.Context, url string, out interface{}) error

GetJSON performs a GET against the given relative url and returns the results unmarshalled from JSON

func (*HttpClient) Head added in v1.35.0

func (c *HttpClient) Head(ctx context.Context, url string) (resp *http.Response, err error)

Head performs a HEAD against the given relative url

func (*HttpClient) Patch added in v1.35.3

func (c *HttpClient) Patch(ctx context.Context, url, contentType string, body io.Reader) (resp *http.Response, err error)

Patch performs a PATCH against the given relative url

func (*HttpClient) PatchJSON added in v1.35.3

func (c *HttpClient) PatchJSON(ctx context.Context, url string, in interface{}, out interface{}) error

PatchJSON performs a PATCH against the given relative url using the JSON body and returns JSON

func (*HttpClient) Post added in v1.35.0

func (c *HttpClient) Post(ctx context.Context, url, contentType string, body io.Reader) (resp *http.Response, err error)

Post performs a POST against the given relative url

func (*HttpClient) PostJSON added in v1.35.0

func (c *HttpClient) PostJSON(ctx context.Context, url string, in interface{}, out interface{}) error

PostJSON performs a POST against the given relative url using the JSON body and returns JSON

func (*HttpClient) Put added in v1.35.0

func (c *HttpClient) Put(ctx context.Context, url, contentType string, body io.Reader) (resp *http.Response, err error)

Put performs a PUT against the given relative url

func (*HttpClient) PutJSON added in v1.35.0

func (c *HttpClient) PutJSON(ctx context.Context, url string, in interface{}, out interface{}) error

PutJSON performs a PUT against the given relative url using the JSON body and returns JSON

type HttpLoggingConfig added in v1.36.0

type HttpLoggingConfig struct {
	Enabled bool
	Headers []string `config:",default=X-Forwarded-For"`
}

HttpLoggingConfig provides configuration for HTTP logging

type KeyConfig

type KeyConfig struct {
	ID     string
	Secret []byte `config:"secret,encoding=base64"`
	File   string
}

KeyConfig provides key-related configurations

func (KeyConfig) GetEnabled

func (c KeyConfig) GetEnabled() bool

GetEnabled returns true if the key is enabled

type MetricsHandler

type MetricsHandler struct{}

MetricsHandler is the Prometheus metrics exporter

func (*MetricsHandler) ServeHTTP

func (s *MetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProvidesFxOptions added in v1.45.0

type ProvidesFxOptions interface {
	Options() fx.Option
}

type Redirect

type Redirect struct {
	// Location to redirect to
	Location string `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"`
}

Redirect represents a redirection to a new location

func (*Redirect) Descriptor

func (*Redirect) Descriptor() ([]byte, []int)

func (*Redirect) Equal

func (this *Redirect) Equal(that interface{}) bool

func (*Redirect) GetLocation

func (m *Redirect) GetLocation() string

func (*Redirect) GoString

func (this *Redirect) GoString() string

func (*Redirect) Marshal

func (m *Redirect) Marshal() (dAtA []byte, err error)

func (*Redirect) MarshalTo

func (m *Redirect) MarshalTo(dAtA []byte) (int, error)

func (*Redirect) MarshalToSizedBuffer

func (m *Redirect) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Redirect) ProtoMessage

func (*Redirect) ProtoMessage()

func (*Redirect) Reset

func (m *Redirect) Reset()

func (*Redirect) Size

func (m *Redirect) Size() (n int)

func (*Redirect) String

func (this *Redirect) String() string

func (*Redirect) Unmarshal

func (m *Redirect) Unmarshal(dAtA []byte) error

func (*Redirect) XXX_DiscardUnknown

func (m *Redirect) XXX_DiscardUnknown()

func (*Redirect) XXX_Marshal

func (m *Redirect) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Redirect) XXX_Merge

func (m *Redirect) XXX_Merge(src proto.Message)

func (*Redirect) XXX_Size

func (m *Redirect) XXX_Size() int

func (*Redirect) XXX_Unmarshal

func (m *Redirect) XXX_Unmarshal(b []byte) error

type Runner added in v1.37.0

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

Runner represents a command runner

func NewRunner added in v1.37.0

func NewRunner(prefix string) *Runner

NewRunner creates a new Runner

func (*Runner) Getenv added in v1.37.0

func (r *Runner) Getenv(key string) string

Getenv returns the value of the environment variabled named `key`

func (*Runner) Setup added in v1.37.0

func (r *Runner) Setup(cmd *cobra.Command, runner interface{}, cfg interface{}) *Runner

Setup sets up the Command

func (*Runner) SetupLogging added in v1.37.0

func (r *Runner) SetupLogging(env Environment, loglevel string)

SetupLogging sets up logging for the environment and the default log level

func (*Runner) SetupRoot added in v1.37.0

func (r *Runner) SetupRoot(cmd *cobra.Command) *Runner

SetupRoot sets up the root Command

type ServeLifecycleParams added in v1.42.0

type ServeLifecycleParams struct {
	fx.In

	Lifecycle     fx.Lifecycle
	ServiceName   string `name:"serviceName"`
	ServerOptions []ServerOption
}

type ServerConfig

type ServerConfig struct {
	Bind           string `config:"bind,default=0.0.0.0"`
	Listen         uint   `config:"listen,default=5000"`
	TLS            TLSConfig
	Logging        HttpLoggingConfig
	Profiling      Enabled
	AllowedOrigins []string
}

ServerConfig is standard configuration of most server commands

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption provides an interface for utilizing custom server options

func WithAuthentication

func WithAuthentication(authenticate func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)) ServerOption

WithAuthentication returns a new authenticateServerOption

func WithDELETE

func WithDELETE(pattern string, handler http.Handler) ServerOption

WithDELETE returns a handlerServerOption

func WithGET

func WithGET(pattern string, handler http.Handler) ServerOption

WithGET returns a handlerServerOption

func WithGRPCServices

func WithGRPCServices(registerServices func(ctx context.Context, grpcServer *grpc.Server)) ServerOption

WithGRPCServices returns a new grpcServicesServerOption

func WithHandler

func WithHandler(pattern string, handler http.Handler) ServerOption

WithHandler returns a handlerServerOption

func WithHandlerFunc

func WithHandlerFunc(pattern string, handler http.HandlerFunc) ServerOption

WithHandlerFunc returns a handlerServerOption

func WithHealth

func WithHealth(checker http.Handler) ServerOption

WithHealth specifies a health handler

func WithHealthCheck

func WithHealthCheck(check string, checker http.Handler) ServerOption

WithHealthCheck specifies a health checker function

func WithHttpHandler added in v1.33.0

func WithHttpHandler(method string, pattern string, handler http.Handler) ServerOption

WithHttpHandler returns a handlerServerOption

func WithLogger

func WithLogger(log *logrus.Entry) ServerOption

WithLogger returns a new loggerServerOption

func WithMethodNotAllowedHandler

func WithMethodNotAllowedHandler(handler http.Handler) ServerOption

WithMethodNotAllowedHandler returns a notFoundHandlerServerOption

func WithMetrics

func WithMetrics(handler http.Handler) ServerOption

WithMetrics specifies a metrics handler

func WithMiddleware

func WithMiddleware(middlewares ...func(http.Handler) http.Handler) ServerOption

WithMiddleware returns a middlewareServerOption

func WithNotFoundHandler

func WithNotFoundHandler(handler http.Handler) ServerOption

WithNotFoundHandler returns a notFoundHandlerServerOption

func WithOPTIONS

func WithOPTIONS(pattern string, handler http.Handler) ServerOption

WithOPTIONS returns a handlerServerOption

func WithPATCH

func WithPATCH(pattern string, handler http.Handler) ServerOption

WithPATCH returns a handlerServerOption

func WithPOST

func WithPOST(pattern string, handler http.Handler) ServerOption

WithPOST returns a handlerServerOption

func WithPUT

func WithPUT(pattern string, handler http.Handler) ServerOption

WithPUT returns a handlerServerOption

func WithProfiler

func WithProfiler() ServerOption

WithProfiler specifies a profiler handler to provide profiling information to go tool pprof

func WithServerConfig

func WithServerConfig(config ServerConfig) ServerOption

WithServerConfig returns a new serverConfigOption

func WithSwagger

func WithSwagger(fs http.FileSystem) ServerOption

WithSwagger specifies a swagger handler based off the given file system

func WithTLS

func WithTLS(cfg TLSConfig) ServerOption

WithTLS returns a new tlsServerOption

func WithVault

func WithVault(vault VaultConfig) ServerOption

WithVault returns a new vaultServerOption

type SharedContextCredentials

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

SharedContextCredentials provides context-based or token-based credentials to the client

func (SharedContextCredentials) GetRequestMetadata

func (j SharedContextCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata returns authorization metadata

func (SharedContextCredentials) RequireTransportSecurity

func (j SharedContextCredentials) RequireTransportSecurity() bool

RequireTransportSecurity denotes we require transport security

type TLSConfig

type TLSConfig struct {
	ClientAuth tls.ClientAuthType `config:"clientauth"`
	Enabled    bool               `config:"enabled,default=true"`
	Insecure   bool
	Override   string
	Cert       KeyConfig
	Key        KeyConfig
	RootCA     KeyConfig `config:"rootca"`
	Generate   CertGenerationConfig
}

TLSConfig provides TLS configuration

func CloneTLSConfig

func CloneTLSConfig(cfg TLSConfig) TLSConfig

CloneTLSConfig clones the given TLS configuration

func FromTLSConfig added in v1.40.0

func FromTLSConfig(t *tls.Config) TLSConfig

FromTLSConfig returns a TLSConfig for the given tls.Config

func (TLSConfig) GetEnabled

func (t TLSConfig) GetEnabled() bool

GetEnabled returns true of TLS is enabled

type TestServer added in v1.40.0

type TestServer struct {
	*httptest.Server
}

TestServer provides functionality for running a test server instance

func NewTestServer added in v1.40.0

func NewTestServer(ctx context.Context, serviceName string, options ...ServerOption) (*TestServer, error)

NewTestServer sets up the test server and

func (*TestServer) ClientConfig added in v1.40.0

func (s *TestServer) ClientConfig() ClientConfig

ClientConfig returns a proper ClientConfig for connecting to the server

func (*TestServer) Connect added in v1.40.0

func (s *TestServer) Connect(ctx context.Context) (*grpc.ClientConn, error)

Connect opens a gRPC client connection to the server

type TokenConfig

type TokenConfig struct {
	Issuer     string
	KeyMap     KeyConfig `config:"keymap"`
	PrivateKey KeyConfig `config:"privatekey"`
	PublicKey  KeyConfig `config:"publickey"`
	Shared     KeyConfig
	TTL        time.Duration `config:"ttl,default=24h"`
}

TokenConfig is the configuration for managing tokens

type VaultClient

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

VaultClient is a Vault client

func NewVault

func NewVault(ctx context.Context, cfg VaultConfig) (*VaultClient, error)

NewVault connects to Vault given the configuration

func (VaultClient) Delete

func (c VaultClient) Delete(ctx context.Context, p string) error

Delete a secret at the given path

func (VaultClient) IsNotFound added in v1.39.0

func (c VaultClient) IsNotFound(err error) bool

IsNotFound returns true if the error means the object was not found

func (VaultClient) List added in v1.39.0

func (c VaultClient) List(ctx context.Context, p string) ([]string, error)

List returns keys available at the given path p

func (VaultClient) Read

func (c VaultClient) Read(ctx context.Context, p string) (*vault.Secret, error)

Read returns a secret at the given path

func (VaultClient) ReadObject added in v1.39.0

func (c VaultClient) ReadObject(ctx context.Context, p string, out interface{}) error

ReadObject returns a secret at the given path

func (VaultClient) Write

func (c VaultClient) Write(ctx context.Context, p string, data map[string]interface{}) (*vault.Secret, error)

Write secret data at the given path

func (VaultClient) WriteObject added in v1.39.0

func (c VaultClient) WriteObject(ctx context.Context, p string, in interface{}) error

WriteObject writes secret data at the given path from an object

type VaultConfig

type VaultConfig struct {
	Enabled bool
	Address string
	Token   string
	Prefix  string
	TLS     TLSConfig
}

VaultConfig provides the configuration options available for Vault

func (VaultConfig) GetEnabled

func (c VaultConfig) GetEnabled() bool

GetEnabled returns true if Vault is enabled

Directories

Path Synopsis
Code generated by winch.
Code generated by winch.

Jump to

Keyboard shortcuts

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