From 0902294e1a5faa005cac35893f9624c075c0451e Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 3 Jun 2024 12:09:40 -0700 Subject: [PATCH] ensure call aliases also work formatting parameters Signed-off-by: Tonis Tiigi --- util/buildflags/printfunc.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/util/buildflags/printfunc.go b/util/buildflags/printfunc.go index 6a5a95c1..1019702f 100644 --- a/util/buildflags/printfunc.go +++ b/util/buildflags/printfunc.go @@ -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 }