orlop

package module
v2.25.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 24 Imported by: 0

README

orlop

This repository stores the orlop library. More information can be found in the docs folder.

What do you want to do?

Documentation

Index

Constants

View Source
const EnvironmentKey = "KETCH_ENVIRONMENT"

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

deprecated: moved to `env.EnvironmentKey`

Variables

View Source
var AuthToken struct{}

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

deprecated: AuthToken not supported and will be removed soon

Functions

func FxContext

func FxContext(ctx context.Context) fx.Option

deprecated: should not need to provide this directly anymore

func FxOptions

func FxOptions(c any) fx.Option

deprecated: should not need to provide this directly anymore

func GetVariablesFromConfig

func GetVariablesFromConfig(prefix string, cfg any) ([]string, error)

GetVariablesFromConfig returns the environment variables from the given config object

deprecated: GetVariablesFromConfig not supported and will be removed soon

func Identity added in v2.18.0

func Identity[T any](in T) T

Identity returns the given input

func IdentityContext added in v2.18.0

func IdentityContext[T any](_ context.Context, in T) T

IdentityContext returns the given input with a context as the first parameter

func IdentityContextError added in v2.18.0

func IdentityContextError[T any](_ context.Context, in T) (T, error)

IdentityContextError returns the given input with a context as the first parameter with a nil error

func IdentityError added in v2.18.0

func IdentityError[T any](in T) (T, error)

IdentityError returns the given input

func IgnoreError added in v2.18.0

func IgnoreError[T any](in T, _ error) T

IgnoreError returns the given input and ignores the error (use at your own peril

func IgnoreValue added in v2.19.0

func IgnoreValue[T any](_ T, err error) error

IgnoreValue returns just the error, ignoring the value

func LoadEnvironment

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

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

func PanicOnError added in v2.18.0

func PanicOnError[T any](in T, err error) T

PanicOnError panics on error and returns the given input if not an error

func Populate added in v2.2.0

func Populate(ctx context.Context, prefix string, _ env.Environment, module fx.Option, targets ...any) error

Populate is used for testing to populate specific entities for a unit test.

deprecated: Use TestModule instead

func RegisterConfigParser

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

RegisterConfigParser registers a config parser

deprecated: RegisterConfigParser not supported and will be removed soon

func RequireValue added in v2.19.0

func RequireValue[T comparable](name string) func(value T, err error) error

RequireValue requires a non-nil value, raising an error if not returned

func Run

func Run(prefix string, runner any, cfg any)

Run loads config and then executes the given runner

deprecated: use `cmd.Run`

func TestModule added in v2.14.0

func TestModule(prefix string, module ...fx.Option) (*fx.App, error)

TestModule returns an instantiated fx.App

func Unmarshal

func Unmarshal(prefix string, cfg any) error

Unmarshal reads configuration into the cfg object

deprecated: Unmarshal not supported and will be removed soon

func UnmarshalFromEnv

func UnmarshalFromEnv(prefix string, vars []string, cfg any) error

UnmarshalFromEnv reads configuration into the cfg object from the env vars

deprecated: UnmarshalFromEnv not supported and will be removed soon

Types

type ContextCredentials

type ContextCredentials struct{}

ContextCredentials provides credentials to the client based on the context

deprecated: ContextCredentials not supported and will be removed soon

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 Enabled

type Enabled struct {
	Enabled bool
}

Enabled provides an Enabled flag

deprecated: HasEnabled has moved to `config.HasEnabled`

func (Enabled) GetEnabled

func (c Enabled) GetEnabled() bool

GetEnabled returns true if enabled

type Environment

type Environment string

Environment is a defined environment

deprecated: moved to `env.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 File

type File struct {
	File string
}

File provides a filename

deprecated: moved to `config.HasFile`

func (File) GetFile

func (f File) GetFile() string

GetFile returns the filename

type HasEnabled

type HasEnabled interface {
	GetEnabled() bool
}

HasEnabled denotes an object provides an Enabled flag

deprecated: HasEnabled has moved to `config.Enabled`

type HasFile

type HasFile interface {
	GetFile() string
}

HasFile denotes an object provides a filename

deprecated: moved to `config.File`

type Runner

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

Runner represents a command runner

deprecated: use `cmd.Runner`

func NewRunner

func NewRunner(prefix string) *Runner

NewRunner creates a new Runner

deprecated: use `cmd.Runner.NewRunner`

func (*Runner) Getenv

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

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

deprecated: use `cmd.Runner.Getenv`

func (*Runner) Setup

func (r *Runner) Setup(cmd *cobra.Command, runner any, cfg any) *Runner

Setup sets up the Command

deprecated: use `cmd.Runner.Setup`

func (*Runner) SetupLogging

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

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

deprecated: use `cmd.Runner.SetupLogging`

func (*Runner) SetupRoot

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

SetupRoot sets up the root Command

deprecated: use `cmd.Runner.SetupRoot`

Directories

Path Synopsis
Package errors provides utilities to augment errors
Package errors provides utilities to augment errors

Jump to

Keyboard shortcuts

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