Documentation ¶
Index ¶
- Variables
- func Describe(val flagext.RegistererWithLogger) ([]byte, error)
- type BestEffortDirectMapper
- type ChangedDefault
- type ConversionNotices
- type EntryKind
- type InspectedEntry
- func DefaultCortexConfig() *InspectedEntry
- func DefaultGEM170Config() *InspectedEntry
- func DefaultGEMConfig() *InspectedEntry
- func DefaultMimirConfig() *InspectedEntry
- func InspectConfig(cfg flagext.RegistererWithLogger) (*InspectedEntry, error)
- func InspectConfigWithFlags(cfg interface{}, flags map[uintptr]*flag.Flag) (*InspectedEntry, error)
- func (i *InspectedEntry) Clone() *InspectedEntry
- func (i *InspectedEntry) Delete(path string) error
- func (i InspectedEntry) GetDefaultValue(path string) (Value, error)
- func (i InspectedEntry) GetFlag(path string) (string, error)
- func (i *InspectedEntry) GetValue(path string) (Value, error)
- func (i *InspectedEntry) IsBoolFlag() bool
- func (i *InspectedEntry) MarshalYAML() (interface{}, error)
- func (i InspectedEntry) MustGetDefaultValue(path string) Value
- func (i *InspectedEntry) MustGetValue(path string) Value
- func (i *InspectedEntry) RegisterFlags(fs *flag.FlagSet, logger log.Logger)
- func (i *InspectedEntry) Set(s string) (err error)
- func (i InspectedEntry) SetDefaultValue(path string, val Value) error
- func (i *InspectedEntry) SetValue(path string, v Value) error
- func (i *InspectedEntry) String() string
- func (i *InspectedEntry) UnmarshalJSON(b []byte) error
- func (i *InspectedEntry) UnmarshalYAML(value *yaml.Node) error
- func (i InspectedEntry) Walk(f func(path string, value Value) error) error
- type InspectedEntryFactory
- type Mapper
- type MapperFunc
- type Mapping
- type MultiMapper
- type Parameters
- type PathMapper
- type PrunedDefault
- type Value
- func (v Value) AsBool() bool
- func (v Value) AsDuration() time.Duration
- func (v Value) AsFloat() float64
- func (v Value) AsInt() int
- func (v Value) AsInterface() interface{}
- func (v Value) AsSlice() []*InspectedEntry
- func (v Value) AsString() string
- func (v Value) AsURL() flagext.URLValue
- func (v Value) Equals(other Value) bool
- func (v Value) IsSlice() bool
- func (v Value) IsUnset() bool
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) String() string
- func (v *Value) UnmarshalJSON([]byte) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrParameterNotFound = errors.New("could not find parameter with this path")
)
var Nil = Value{}
Functions ¶
Types ¶
type BestEffortDirectMapper ¶
type BestEffortDirectMapper struct{}
BestEffortDirectMapper implement Mapper and naively maps the values of all parameters form the source to the same name parameter in the target. It ignores all errors while setting the values.
func (BestEffortDirectMapper) DoMap ¶
func (BestEffortDirectMapper) DoMap(source, target Parameters) error
type ChangedDefault ¶
type ConversionNotices ¶
type ConversionNotices struct { RemovedCLIFlags []string RemovedParameters []string ChangedDefaults []ChangedDefault SkippedChangedDefaults []ChangedDefault PrunedDefaults []PrunedDefault }
func Convert ¶
func Convert( contents []byte, flags []string, m Mapper, sourceFactory, targetFactory InspectedEntryFactory, useNewDefaults, showDefaults bool, ) (convertedContents []byte, convertedFlags []string, _ ConversionNotices, conversionErr error)
Convert converts the passed YAML contents and CLI flags in the source schema to a YAML config and CLI flags in the target schema. sourceFactory and targetFactory are assumed to return InspectedEntries where the FieldValue is the default value of the configuration parameter. Convert uses sourceFactory and targetFactory to also prune the default values from the resulting config. Convert returns the marshalled YAML config in the target schema.
type InspectedEntry ¶
type InspectedEntry struct { Kind EntryKind `json:"kind"` Name string `json:"name"` Required bool `json:"required"` Desc string `json:"desc"` // In case the Kind is "block" BlockEntries []*InspectedEntry `json:"blockEntries,omitempty"` BlockFlagsPrefix string `json:"blockFlagsPrefix,omitempty"` BlockFlagsPrefixes []string `json:"blockFlagsPrefixes,omitempty"` // In case the Kind is "field" FieldValue Value `json:"fieldValue,omitempty"` FieldDefaultValue Value `json:"fieldDefaultValue,omitempty"` FieldFlag string `json:"fieldFlag,omitempty"` FieldType string `json:"fieldType,omitempty"` FieldCategory string `json:"fieldCategory,omitempty"` FieldElement *InspectedEntry `json:"fieldElement,omitempty"` // when FieldType is "slice" or "map" }
func DefaultCortexConfig ¶
func DefaultCortexConfig() *InspectedEntry
func DefaultGEM170Config ¶
func DefaultGEM170Config() *InspectedEntry
func DefaultGEMConfig ¶
func DefaultGEMConfig() *InspectedEntry
func DefaultMimirConfig ¶
func DefaultMimirConfig() *InspectedEntry
func InspectConfig ¶
func InspectConfig(cfg flagext.RegistererWithLogger) (*InspectedEntry, error)
InspectConfig returns an InspectedEntry that represents the root block of the configuration.
func InspectConfigWithFlags ¶
func InspectConfigWithFlags(cfg interface{}, flags map[uintptr]*flag.Flag) (*InspectedEntry, error)
InspectConfigWithFlags does the same as InspectConfig while allowing to provide custom CLI flags. This is useful when the configuration struct does not implement flagext.RegistererWithLogger.
func (*InspectedEntry) Clone ¶
func (i *InspectedEntry) Clone() *InspectedEntry
func (*InspectedEntry) Delete ¶
func (i *InspectedEntry) Delete(path string) error
Delete deletes a leaf parameter or entire subtree from the InspectedEntry. Delete also recursively deletes any parent blocks that, because of this delete, now contain no entries. If an error is returned, it's errors.Cause will be ErrParameterNotFound.
func (InspectedEntry) GetDefaultValue ¶
func (i InspectedEntry) GetDefaultValue(path string) (Value, error)
func (InspectedEntry) GetFlag ¶
func (i InspectedEntry) GetFlag(path string) (string, error)
GetFlag returns the CLI flag name of the parameter.
func (*InspectedEntry) IsBoolFlag ¶
func (i *InspectedEntry) IsBoolFlag() bool
IsBoolFlag is used by flag package to support to setting bool flags without using value.
func (*InspectedEntry) MarshalYAML ¶
func (i *InspectedEntry) MarshalYAML() (interface{}, error)
func (InspectedEntry) MustGetDefaultValue ¶
func (i InspectedEntry) MustGetDefaultValue(path string) Value
func (*InspectedEntry) MustGetValue ¶
func (i *InspectedEntry) MustGetValue(path string) Value
MustGetValue does the same as GetVValue, but panics if there's an error.
func (*InspectedEntry) RegisterFlags ¶
func (i *InspectedEntry) RegisterFlags(fs *flag.FlagSet, logger log.Logger)
func (*InspectedEntry) Set ¶
func (i *InspectedEntry) Set(s string) (err error)
Set implements flag.Value
func (InspectedEntry) SetDefaultValue ¶
func (i InspectedEntry) SetDefaultValue(path string, val Value) error
func (*InspectedEntry) SetValue ¶
func (i *InspectedEntry) SetValue(path string, v Value) error
SetValue sets individual parameters. val can be any value. If an error is returned, its errors.Cause will be ErrParameterNotFound.
func (*InspectedEntry) String ¶
func (i *InspectedEntry) String() string
String implements flag.Value
func (*InspectedEntry) UnmarshalJSON ¶
func (i *InspectedEntry) UnmarshalJSON(b []byte) error
func (*InspectedEntry) UnmarshalYAML ¶
func (i *InspectedEntry) UnmarshalYAML(value *yaml.Node) error
func (InspectedEntry) Walk ¶
func (i InspectedEntry) Walk(f func(path string, value Value) error) error
Walk visits all leaf parameters of the InspectedEntry in a depth-first manner and calls f. If f returns an error, the traversal is not stopped. The error Walk returns are the combined errors that all f invocations returned. If no f invocations returned an error, then Walk returns nil.
type InspectedEntryFactory ¶
type InspectedEntryFactory func() *InspectedEntry
type Mapper ¶
type Mapper interface {
DoMap(source, target Parameters) error
}
func CortexToMimirMapper ¶
func CortexToMimirMapper() Mapper
CortexToMimirMapper maps from cortex-1.11.0 to latest mimir configurations
func GEM170ToGEMMapper ¶
func GEM170ToGEMMapper() Mapper
GEM170ToGEMMapper maps from gem-1.7.0 to current gem configuration
type MapperFunc ¶
type MapperFunc func(source, target Parameters) error
func (MapperFunc) DoMap ¶
func (m MapperFunc) DoMap(source, target Parameters) error
type Mapping ¶
func RenameMapping ¶
type MultiMapper ¶
type MultiMapper []Mapper
func (MultiMapper) DoMap ¶
func (m MultiMapper) DoMap(source, target Parameters) error
type Parameters ¶
type Parameters interface { Delete(path string) error GetFlag(path string) (string, error) GetValue(path string) (Value, error) MustGetValue(path string) Value SetValue(path string, v Value) error GetDefaultValue(path string) (Value, error) MustGetDefaultValue(path string) Value SetDefaultValue(path string, v Value) error Walk(f func(path string, value Value) error) error }
type PathMapper ¶
PathMapper applies the mappings to specific parameters of the source.
func (PathMapper) DoMap ¶
func (m PathMapper) DoMap(source, target Parameters) error
DoMap applies the Mappings from source to target. The error DoMap returns are the combined errors that all Mappings returned. If no Mappings returned an error, then DoMap returns nil.
type PrunedDefault ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func DurationValue ¶
func InterfaceValue ¶
func InterfaceValue(v interface{}) Value
func SliceValue ¶
func SliceValue(slice []*InspectedEntry) Value
func StringValue ¶
func (Value) AsDuration ¶
func (Value) AsInterface ¶
func (v Value) AsInterface() interface{}
func (Value) AsSlice ¶
func (v Value) AsSlice() []*InspectedEntry
func (Value) MarshalJSON ¶
func (*Value) UnmarshalJSON ¶
UnmarshalJSON is empty because unmarshalling without type information is not possible. InspectedEntry.UnmarshalJSON does the unmarshalling _with_ type information.