Documentation ¶
Index ¶
- Constants
- Variables
- func BuildQuery(cqr types.ConfigQueryResolver) string
- func ColorizeValue(value string, isEnum bool) string
- func CreateEnumFormatter(names []string) types.EnumFormatter
- func GetConfigFieldString(config reflect.Value, field FieldInfo) (value string, err error)
- func GetConfigMap(service types.Service) (map[string]string, int)
- func GetConfigQueryResolver(config types.ServiceConfig) types.ConfigQueryResolver
- func IsNumber(value string) bool
- func ParseBool(value string, defaultValue bool) (parsedValue bool, ok bool)
- func PrintBool(value bool) string
- func SetConfigField(config reflect.Value, field FieldInfo, inputValue string) (valid bool, err error)
- type EnumFormatter
- type FieldInfo
- type NotifyFormat
- type PropKeyResolver
- func (pkr *PropKeyResolver) Bind(config types.ServiceConfig) PropKeyResolver
- func (pkr *PropKeyResolver) Get(key string) (string, error)
- func (pkr *PropKeyResolver) KeyIsPrimary(key string) bool
- func (pkr *PropKeyResolver) QueryFields() []string
- func (pkr *PropKeyResolver) Set(key string, value string) error
- func (pkr *PropKeyResolver) UpdateConfigFromParams(config types.ServiceConfig, params *types.Params) error
Constants ¶
const EnumInvalid = -1
EnumInvalid is the constant value that an enum gets assigned when it could not be parsed
Variables ¶
var ColorizeDesc = color.New(color.FgHiBlack).SprintFunc()
ColorizeDesc colorizes the input string as "Description"
var ColorizeEnum = color.New(color.FgHiCyan).SprintFunc()
ColorizeEnum colorizes the input string as "Enum"
var ColorizeFalse = color.New(color.FgHiRed).SprintFunc()
ColorizeFalse colorizes the input string as "False"
var ColorizeNumber = color.New(color.FgHiBlue).SprintFunc()
ColorizeNumber colorizes the input string as "Number"
var ColorizeString = color.New(color.FgHiYellow).SprintFunc()
ColorizeString colorizes the input string as "String"
var ColorizeTrue = color.New(color.FgHiGreen).SprintFunc()
ColorizeTrue colorizes the input string as "True"
Functions ¶
func BuildQuery ¶
func BuildQuery(cqr types.ConfigQueryResolver) string
BuildQuery converts the fields of a config object to a delimited query string
func ColorizeValue ¶
ColorizeValue colorizes the input string according to what type appears to be
func CreateEnumFormatter ¶
func CreateEnumFormatter(names []string) types.EnumFormatter
CreateEnumFormatter creates a EnumFormatter struct
func GetConfigFieldString ¶
func GetConfigMap ¶
GetConfigMap returns a string map of a given Config struct
func GetConfigQueryResolver ¶
func GetConfigQueryResolver(config types.ServiceConfig) types.ConfigQueryResolver
func ParseBool ¶
ParseBool returns true for "1","true","yes" or false for "0","false","no" or defaultValue for any other value
Types ¶
type EnumFormatter ¶
type EnumFormatter struct {
// contains filtered or unexported fields
}
EnumFormatter is the helper methods for enum-like types
func (EnumFormatter) Names ¶
func (ef EnumFormatter) Names() []string
Names is the list of the valid Enum string values
func (EnumFormatter) Parse ¶
func (ef EnumFormatter) Parse(s string) int
Parse takes an enum mapped string and returns it's int representation or EnumInvalid (-1)
func (EnumFormatter) Print ¶
func (ef EnumFormatter) Print(e int) string
Print takes a enum mapped int and returns it's string representation or "Invalid"
type FieldInfo ¶
type FieldInfo struct { Name string Type reflect.Type EnumFormatter types.EnumFormatter Description string DefaultValue string Template string Required bool Title bool Keys []string }
func GetConfigFormat ¶
func GetConfigFormat(serviceConfig types.ServiceConfig) (reflect.Type, []FieldInfo)
type NotifyFormat ¶
type NotifyFormat int
NotifyFormat describes the format used in the notification body
const ( // Markdown is the default notification format Markdown NotifyFormat = 0 )
type PropKeyResolver ¶
type PropKeyResolver struct {
// contains filtered or unexported fields
}
PropKeyResolver implements the ConfigQueryResolver interface for services that uses key tags for query props
func NewPropKeyResolver ¶
func NewPropKeyResolver(config types.ServiceConfig) PropKeyResolver
BindKeys is called to map config fields to it's tagged query keys
func (*PropKeyResolver) Bind ¶
func (pkr *PropKeyResolver) Bind(config types.ServiceConfig) PropKeyResolver
func (*PropKeyResolver) Get ¶
func (pkr *PropKeyResolver) Get(key string) (string, error)
Get returns the value of a config property tagged with the corresponding key
func (*PropKeyResolver) KeyIsPrimary ¶
func (pkr *PropKeyResolver) KeyIsPrimary(key string) bool
func (*PropKeyResolver) QueryFields ¶
func (pkr *PropKeyResolver) QueryFields() []string
QueryFields returns a list of tagged keys
func (*PropKeyResolver) Set ¶
func (pkr *PropKeyResolver) Set(key string, value string) error
Set sets the value of it's bound struct's property, tagged with the corresponding key
func (*PropKeyResolver) UpdateConfigFromParams ¶
func (pkr *PropKeyResolver) UpdateConfigFromParams(config types.ServiceConfig, params *types.Params) error
UpdateConfigFromParams mutates the provided config, updating the values from it's corresponding params