Documentation ¶
Index ¶
- Constants
- Variables
- func FxContext(ctx context.Context) fx.Option
- func FxOptions(c any) fx.Option
- func GetVariablesFromConfig(prefix string, cfg any) ([]string, error)
- func Identity[T any](in T) T
- func IdentityContext[T any](_ context.Context, in T) T
- func IdentityContextError[T any](_ context.Context, in T) (T, error)
- func IdentityError[T any](in T) (T, error)
- func IgnoreError[T any](in T, _ error) T
- func IgnoreValue[T any](_ T, err error) error
- func LoadEnvironment(env Environment, files ...string)
- func PanicOnError[T any](in T, err error) T
- func Populate(ctx context.Context, prefix string, _ env.Environment, module fx.Option, ...) error
- func RegisterConfigParser(typeName string, parser func(value reflect.Value, input string) error)
- func RequireValue[T comparable](name string) func(value T, err error) error
- func Run(prefix string, runner any, cfg any)
- func TestModule(prefix string, module ...fx.Option) (*fx.App, error)
- func Unmarshal(prefix string, cfg any) error
- func UnmarshalFromEnv(prefix string, vars []string, cfg any) error
- type ContextCredentials
- type Enabled
- type Environment
- type File
- type HasEnabled
- type HasFile
- type Runner
Constants ¶
const EnvironmentKey = "KETCH_ENVIRONMENT"
EnvironmentKey is the environment variable we look for to set the environment
deprecated: moved to `env.EnvironmentKey`
Variables ¶
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 GetVariablesFromConfig ¶
GetVariablesFromConfig returns the environment variables from the given config object
deprecated: GetVariablesFromConfig not supported and will be removed soon
func IdentityContext ¶ added in v2.18.0
IdentityContext returns the given input with a context as the first parameter
func IdentityContextError ¶ added in v2.18.0
IdentityContextError returns the given input with a context as the first parameter with a nil error
func IdentityError ¶ added in v2.18.0
IdentityError returns the given input
func IgnoreError ¶ added in v2.18.0
IgnoreError returns the given input and ignores the error (use at your own peril
func IgnoreValue ¶ added in v2.19.0
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
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 ¶
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 TestModule ¶ added in v2.14.0
TestModule returns an instantiated fx.App
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`
type Environment ¶
type Environment string
Environment is a defined environment
deprecated: moved to `env.Environment`
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`
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 (*Runner) Getenv ¶
Getenv returns the value of the environment variabled named `key`
deprecated: use `cmd.Runner.Getenv`
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`