Files
plugin-drone-kaniko/pkg/utils/custom_string_slice.go
T
Satya a1d07a3262 fix: [CI-18923]: Build argument getting split if it has a comma in the value (#153)
* added the PLUGIN_MULTIPLE_BUILD_ARGS for all registries

* added the tests and README
2025-09-15 19:04:48 +05:30

37 lines
772 B
Go

package utils
import (
"strings"
)
// CustomStringSliceFlag is like a regular StringSlice flag but with
// semicolon as a delimiter
type CustomStringSliceFlag struct {
Value []string
}
// GetValue returns the slice of strings stored in the flag
func (f *CustomStringSliceFlag) GetValue() []string {
if f.Value == nil {
return make([]string, 0)
}
return f.Value
}
// String returns a string representation of the flag
func (f *CustomStringSliceFlag) String() string {
if f.Value == nil {
return ""
}
return strings.Join(f.Value, ";")
}
// Set sets the value of the flag from a string
func (f *CustomStringSliceFlag) Set(v string) error {
for _, s := range strings.Split(v, ";") {
s = strings.TrimSpace(s)
f.Value = append(f.Value, s)
}
return nil
}