ensure call aliases also work formatting parameters

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2024-06-03 12:09:40 -07:00
parent ef4a165e48
commit 0902294e1a
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39
1 changed files with 13 additions and 8 deletions

View File

@ -12,17 +12,10 @@ import (
const defaultPrintFunc = "build"
func ParsePrintFunc(str string) (*controllerapi.PrintFunc, error) {
if str == "" || str == defaultPrintFunc {
if str == "" {
return nil, nil
}
// "check" has been added as an alias for "lint",
// in order to maintain backwards compatibility
// we need to convert it.
if str == "check" {
str = "lint"
}
csvReader := csv.NewReader(strings.NewReader(str))
fields, err := csvReader.Read()
if err != nil {
@ -51,5 +44,17 @@ func ParsePrintFunc(str string) (*controllerapi.PrintFunc, error) {
f.Name = field
}
}
// "check" has been added as an alias for "lint",
// in order to maintain backwards compatibility
// we need to convert it.
if f.Name == "check" {
f.Name = "lint"
}
if f.Name == defaultPrintFunc {
return nil, nil
}
return f, nil
}