Documentation
¶
Index ¶
- Constants
- func HasConfiguration(dogu *core.Dogu) bool
- type BinaryMeasurementValidator
- type ConfigValidator
- type DoguConfigurationEditor
- func (editor *DoguConfigurationEditor) DeleteField(field core.ConfigurationField) error
- func (editor *DoguConfigurationEditor) EditConfiguration(fields []core.ConfigurationField, deleteOnEmpty bool) error
- func (editor *DoguConfigurationEditor) GetCurrentValue(field core.ConfigurationField) (string, error)
- func (editor *DoguConfigurationEditor) SetFieldToValue(field core.ConfigurationField, value string, deleteOnEmpty bool) error
- type EntryValidator
- type FieldReader
- type FieldWriter
- type FloatPercentageValidator
- type Validator
Constants ¶
const ( // OneOfKey identifies the one-of-validator to select a single value among a list of valid values used in dogu.json. OneOfKey = "ONE_OF" // BinaryMeasurementKey identifies the binary prefix validator for integer values like "1024m" used in dogu.json. BinaryMeasurementKey = "BINARY_MEASUREMENT" // FloatPercentageHundredKey identifies the float percentage validator for float values between 0 and 100% used in dogu.json. FloatPercentageHundredKey = "FLOAT_PERCENTAGE_HUNDRED" )
const (
// ValidBinaryUnits contains available binary measurement units that are manifolds of 1024.
ValidBinaryUnits = "bkmg"
)
Variables ¶
This section is empty.
Functions ¶
func HasConfiguration ¶ added in v0.10.0
HasConfiguration returns true if the dogu has configuration fields applied, otherwise false.
Types ¶
type BinaryMeasurementValidator ¶
type BinaryMeasurementValidator struct {
// contains filtered or unexported fields
}
BinaryMeasurementValidator checks if the given value matches a binary measurement, f. i. '1024k'. BinaryMeasurementValidator validates only the actual config value and does not evaluate the field
ValidationDescriptor.Values
It is best to not configure the ValidationDescriptor.Values field when using this validator.
func (*BinaryMeasurementValidator) Check ¶
func (bpv *BinaryMeasurementValidator) Check(input string) error
Check checks if the input matches a zero or positive integer followed by a binary measurement, namely: b, k, m, g.
func (*BinaryMeasurementValidator) SplitValueAndUnit ¶
func (bpv *BinaryMeasurementValidator) SplitValueAndUnit(input string) (string, string)
SplitValueAndUnit returns the input's integer part as well as the binary unit. Be sure to call Check() beforehand.
type ConfigValidator ¶
type ConfigValidator struct {
// contains filtered or unexported fields
}
ConfigValidator is a Validator implementation which uses a configReader to read the values of the field.
func (*ConfigValidator) Check ¶
func (c *ConfigValidator) Check(field core.ConfigurationField) error
Check checks if a configurationField is valid.
type DoguConfigurationEditor ¶ added in v0.10.0
type DoguConfigurationEditor struct { ConfigurationContext doguConfigurationContext PublicKey *keys.PublicKey Writer FieldWriter Reader FieldReader // contains filtered or unexported fields }
DoguConfigurationEditor struct is able to edit registry configuration values of a dogu.
func NewDoguConfigurationEditor ¶ added in v0.10.0
func NewDoguConfigurationEditor(doguConfig registry.ConfigurationContext, publicKey *keys.PublicKey) (*DoguConfigurationEditor, error)
NewDoguConfigurationEditor creates a new DoguConfigurationEditor struct, with stdout as writer and stdin as reader for the given dogu
func (*DoguConfigurationEditor) DeleteField ¶ added in v0.10.0
func (editor *DoguConfigurationEditor) DeleteField(field core.ConfigurationField) error
func (*DoguConfigurationEditor) EditConfiguration ¶ added in v0.10.0
func (editor *DoguConfigurationEditor) EditConfiguration(fields []core.ConfigurationField, deleteOnEmpty bool) error
EditConfiguration prints registry keys to writer and read values from reader.
func (*DoguConfigurationEditor) GetCurrentValue ¶ added in v0.10.0
func (editor *DoguConfigurationEditor) GetCurrentValue(field core.ConfigurationField) (string, error)
GetCurrentValue returns a value for a given ConfigurationField if it exists, otherwise it returns an error.
func (*DoguConfigurationEditor) SetFieldToValue ¶ added in v0.10.0
func (editor *DoguConfigurationEditor) SetFieldToValue(field core.ConfigurationField, value string, deleteOnEmpty bool) error
SetFieldToValue set the Field as value into the editor.
type EntryValidator ¶
type EntryValidator interface { // Check checks the given input from a configuration entry and returns nil if it is valid, otherwise an error. Check(input string) error }
EntryValidator provides a Check method to check the validity of a single configuration entry.
func CreateBinaryMeasurementValidator ¶
func CreateBinaryMeasurementValidator(core.ValidationDescriptor) EntryValidator
CreateBinaryMeasurementValidator creates a binary measurement validator that validates a single config value.
func CreateEntryValidator ¶
func CreateEntryValidator(descriptor core.ValidationDescriptor) (EntryValidator, error)
CreateEntryValidator creates the correct EntryValidator for the given descriptor.
func CreateFloatPercentageValidator ¶
func CreateFloatPercentageValidator(_ core.ValidationDescriptor) EntryValidator
CreateFloatPercentageValidator creates a float percentage measurement validator that validates a single config value.
type FieldReader ¶ added in v0.10.0
FieldReader can read the input for a configuration field from an underlying system such as stdin.
type FieldWriter ¶ added in v0.10.0
type FieldWriter interface {
Print(field core.ConfigurationField, currentValue string) error
}
FieldWriter can print a configuration field to a underlying system such as stdout.
type FloatPercentageValidator ¶
type FloatPercentageValidator struct {
// contains filtered or unexported fields
}
FloatPercentageValidator checks if the given value matches a percentage in float form, f. i. '55.50' for 55.5%. FloatPercentageValidator validates only the actual config value and does not evaluate the field ValidationDescriptor.Values It is best to not configure the ValidationDescriptor.Values field when using this validator.
func (*FloatPercentageValidator) Check ¶
func (fpv *FloatPercentageValidator) Check(input string) error
Check checks the correct regex and validates that the actual value is between 0%-100%
type Validator ¶
type Validator interface {
Check(core.ConfigurationField) error
}
Validator checks if the given configurationField is valid.