mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-04 10:14:55 +08:00
a1d07a3262
* added the PLUGIN_MULTIPLE_BUILD_ARGS for all registries * added the tests and README
37 lines
772 B
Go
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
|
|
}
|