diff --git a/pkg/util/strings.go b/pkg/util/strings.go index 7e503a99118..f0ac3403296 100644 --- a/pkg/util/strings.go +++ b/pkg/util/strings.go @@ -1,18 +1,18 @@ package util func StringsFallback2(val1 string, val2 string) string { - if val1 != "" { - return val1 - } - return val2 + return stringsFallback(val1, val2) } func StringsFallback3(val1 string, val2 string, val3 string) string { - if val1 != "" { - return val1 - } - if val2 != "" { - return val2 - } - return val3 + return stringsFallback(val1, val2, val3) +} + +func stringsFallback(vals ...string) string { + for _, v := range vals { + if v != "" { + return v + } + } + return "" }