Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Configer
- type Dumper
- type Field
- func (s *Field) CLIPrompt() cliPromptType
- func (s Field) Default() string
- func (s Field) Description() string
- func (s *Field) Get() string
- func (s Field) HasChanged() bool
- func (s Field) IsOptional() bool
- func (s Field) IsSecret() bool
- func (s Field) Key() string
- func (s Field) SecretPath() string
- func (s *Field) Set(v string) error
- func (s Field) String() string
- type FieldOptFunc
- type IncorrectArgumentsToSecretPathFuncError
- type Initer
- type JSONLoader
- type Loader
- type MapLoader
- type OptionalStringValue
- type SSMDumper
- type SSMGetter
- type SafeDumper
- type SecretGetter
- type SecretPathFunc
- type SecretStringValue
- type StringValue
- type Tester
- type Valuer
Constants ¶
const ( CLIPromptTypeString cliPromptType = iota CLIPromptTypeFile CLIPromptTypePassword )
Variables ¶
var ErrFieldValueMustNotBeNil error = errors.New("field value must not be nil")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config []*Field
Config is the list of variables which a provider can be configured with.
func (Config) Dump ¶
Dump renders a map[string]string where the values are mapped in different ways based on the provided dumper
use SafeDumper to get all values with secrets redacted
SSMDumper first pushes any updated secrets to ssm then returns the ssm paths to the secrets
func (Config) FindFieldByKey ¶
FindFieldByKey looks up a field by its key. If the field doesn't exist in the config, an error is returned.
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a key-value pair in a configuration to create a Field, use one of the generator functions StringField(), SecretStringField() or OptionalStringField()
func OptionalStringField ¶
func OptionalStringField(key string, dest *OptionalStringValue, usage string, opts ...FieldOptFunc) *Field
OptionalStringField creates a new optional field with an OptionalStringValue There is no OptionalSecret type.
func SecretStringField ¶
func SecretStringField(key string, dest *SecretStringValue, usage string, secretPathFunc SecretPathFunc, opts ...FieldOptFunc) *Field
SecretStringField creates a new field with a SecretStringValue
func StringField ¶
func StringField(key string, dest *StringValue, usage string, opts ...FieldOptFunc) *Field
StringField creates a new field with a StringValue This field type is for non secrets for secrets, use SecretField()
func (Field) Description ¶
Description returns the usage string for this field
func (Field) HasChanged ¶
func (Field) IsOptional ¶
IsOptional returns true if this Field is optional
func (Field) SecretPath ¶
Path returns the secret path secrets loaded from config with the SSM Loader will have an secret path relevant to the loader type secrets loaded from a test loader like JSONLoader or MapLoader will not have a path and this method will return an empty string
type FieldOptFunc ¶
type FieldOptFunc func(f *Field)
func WithCLIPrompt ¶
func WithCLIPrompt(prompt cliPromptType) FieldOptFunc
WithCLIPrompt allows to override the type of cli prompt used to collect a value for this field when used in the context of a CLI
func WithDefaultFunc ¶
func WithDefaultFunc(df func() string) FieldOptFunc
WithDefaultFunc sets the default function for a field The default func can be used to initialise a new config
type IncorrectArgumentsToSecretPathFuncError ¶
func (IncorrectArgumentsToSecretPathFuncError) Error ¶
func (e IncorrectArgumentsToSecretPathFuncError) Error() string
type JSONLoader ¶
type JSONLoader struct { // Set this to true to skip loading secrets SkipLoadingSecrets bool Data []byte }
JSONLoader loads configuration from a serialized JSON payload set in the 'Data' field. if any values are prefixed with one of teh known prefixes, there are further processed e.g values prefixed with "awsssm://" will be treated as an ssm parameter and will be fetched via the aws SDK
type Loader ¶
type Loader interface { // Load configuration. Returns a map of config values. // The keys of the map are the value names, and the values // are the actual values of the config. // For example: // {"orgUrl": "http://my-org.com"} // // Returns an error if loading the values fails. // // The Loader should internally handle sourcing the configuration for example from a map or environment variables Load(ctx context.Context) (map[string]string, error) }
Loader loads configuration for Common Fate providers.
type MapLoader ¶
type MapLoader struct { // Set this to true to skip loading secrets SkipLoadingSecrets bool Values map[string]string }
MapLoader looks up values in it's Values map when loading configuration.
It's useful for writing tests which use genv to configure things.
type OptionalStringValue ¶
type OptionalStringValue struct {
Value *string
}
OptionalStringValue value implements the Valuer interface
func (*OptionalStringValue) Get ¶
func (s *OptionalStringValue) Get() string
Get the value of the string
func (*OptionalStringValue) IsSet ¶
func (s *OptionalStringValue) IsSet() bool
Get the value of the string
func (*OptionalStringValue) Set ¶
func (s *OptionalStringValue) Set(value string)
Set the value of the string
func (OptionalStringValue) String ¶
func (s OptionalStringValue) String() string
String calls OptionalStringValue.Get()
type SSMDumper ¶
type SSMDumper struct { Suffix string // secret path args are optional args passed through to the secret args functions SecretPathArgs []interface{} }
SSMDumper will upload any secrets to SSM which have changed and then return the tokenised ssm path as the value
type SafeDumper ¶
type SafeDumper struct{}
SafeDumper implements the Dumper interface which dumps the values of the config as a map for logging or diagnostic purposes. Secret values are redacted by virtue of the String() method of the value fields.
type SecretGetter ¶
type SecretPathFunc ¶
func WithArgs ¶
func WithArgs(path string, expectedCount int) SecretPathFunc
WithArgs returns a SecretPathFunc which is intended to be used when dynamic formatting of the path is required. For example a path refers to an id entered by a user, we only know this at dump time. The SSMDumper takes in args which are passed to the the format string
func WithNoArgs ¶
func WithNoArgs(path string) SecretPathFunc
Use this if the path is a simple string
type SecretStringValue ¶
type SecretStringValue struct {
Value string
}
SecretStringValue value implements the Valuer interface, it should be used for secrets in configuration structs.
It is configured to automatically redact the secret for common logging usecases like Zap, fmt.Println and json.Marshal
func (*SecretStringValue) Get ¶
func (s *SecretStringValue) Get() string
Get the raw value of the secret
func (SecretStringValue) MarshalJSON ¶
func (s SecretStringValue) MarshalJSON() ([]byte, error)
MarshalJSON returns a redacted value bytes for this secret
func (*SecretStringValue) Set ¶
func (s *SecretStringValue) Set(value string)
Set the value of the secret
func (SecretStringValue) String ¶
func (s SecretStringValue) String() string
String returns a redacted value for this secret
type StringValue ¶
type StringValue struct {
Value string
}
StringValue value implements the Valuer interface