Documentation ¶
Overview ¶
This is used for getting query parameters from options in the CLI. And also for validate the parameters set - especially for filters.
Index ¶
Constants ¶
const FiltersPartitionChar = "="
Variables ¶
This section is empty.
Functions ¶
func GetListQueryParams ¶
func GetListQueryParams(c *core.CommandConfig) (resources.ListQueryParams, error)
func ValidateFilters ¶
func ValidateFilters(c *core.PreCommandConfig, availableFilters []string, usageFilters string) error
ValidateFilters checks for invalid user-provided filters in PreRun. It compares user input against a list of valid filters (`availableFilters`), which are derived from struct properties (like 'Name', 'Description') with the first letter in lowercase, following the SDK struct naming conventions.
Usage:
- `availableFilters`: List of valid filter keys (struct properties with lowercase first letter).
- `usageFilters`: Usage information string displayed if an invalid filter is provided.
IMPORTANT:
- This function relies on the naming convention of SDK struct fields.
- If these names change, a refactor of filters.go in commands/cloudapi/completer may be necessary.
WORKAROUND:
This function 'corrects' the capitalization of valid keys. For instance, it would adjust
'--filters NAME=myserver,NAME=otherserver,imagetype=LINUX' to
'--filters name=myserver,name=otherserver,imageType=LINUX'
This adjustment is done by manually setting both the flag and global config (viper) values.
The function first retrieves and processes filter key-value pairs. If any invalid filters are found, it reports them and returns an error. Otherwise, it applies the capitalization correction and updates the flag and viper settings accordingly.
Types ¶
This section is empty.