Documentation ¶
Overview ¶
Package option provides the Options type for plugins.
Index ¶
- Variables
- func GetBoolValue(options Options, key string) (bool, error)
- func GetBytesValue(options Options, key string) ([]byte, error)
- func GetFloat64SliceValue(options Options, key string) ([]float64, error)
- func GetFloat64Value(options Options, key string) (float64, error)
- func GetInt64SliceValue(options Options, key string) ([]int64, error)
- func GetInt64Value(options Options, key string) (int64, error)
- func GetStringSliceValue(options Options, key string) ([]string, error)
- func GetStringValue(options Options, key string) (string, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
var EmptyOptions = newOptionsNoValidate(nil)
EmptyOptions is an instance of Options with no keys.
Functions ¶
func GetBoolValue ¶
GetBoolValue gets a bool value from the Options.
If the value is present and is not of type bool, an error is returned.
func GetBytesValue ¶
GetBytesValue gets a bytes value from the Options.
If the value is present and is not of type bytes, an error is returned.
func GetFloat64SliceValue ¶
GetFloat64SliceValue gets a []float64 value from the Options.
If the value is present and is not of type []float64, an error is returned.
func GetFloat64Value ¶
GetFloat64Value gets a float64 value from the Options.
If the value is present and is not of type float64, an error is returned.
func GetInt64SliceValue ¶
GetInt64SliceValue gets a []int64 value from the Options.
If the value is present and is not of type []int64, an error is returned.
func GetInt64Value ¶
GetInt64Value gets a int64 value from the Options.
If the value is present and is not of type int64, an error is returned.
func GetStringSliceValue ¶
GetStringSliceValue gets a []string value from the Options.
If the value is present and is not of type []string, an error is returned.
Types ¶
type Options ¶
type Options interface { // Get gets the option value for the given key. // // Values will be one of: // // - int64 // - float64 // - string // - []byte // - bool // - A slice of any of the above, recursively (i.e. []string, [][]int64, ...) // // A caller should not modify a returned value. // // The key must have at least four characters. // The key must start and end with a lowercase letter from a-z, and only consist // of lowercase letters from a-z and underscores. Get(key string) (any, bool) // Range ranges over all key/value pairs. // // The range order is not deterministic. Range(f func(key string, value any)) // ToProto converts the Options to its Protobuf representation. ToProto() ([]*optionv1.Option, error) // contains filtered or unexported methods }
Options are key/values that can control the behavior of a RuleHandler, and can control the value of the Purpose string of the Rule.
For example, if you had a Rule that checked that the suffix of all Services was "API", you may want an option with key "service_suffix" that can override the suffix "API" to another suffix such as "Service". This would result in the behavior of the check changing, as well as result in the Purpose string potentially changing to specify that the expected suffix is "Service" instead of "API".
It is not possible to set a key with a not-present value. Do not add an Option with a given key to denote that the key is not set.
func NewOptions ¶
NewOptions returns a new validated Options for the given key/value map.