1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-18 21:09:40 +02:00
portainer/api/cli/pairlist.go
andres-portainer e126f63965
feat(openamt): add feature flag for OpenAMT [INT-5] (#6049)
feat(openamt): add feature flag for OpenAMT [INT-5]
2021-11-11 15:49:50 -03:00

41 lines
817 B
Go

package cli
import (
portainer "github.com/portainer/portainer/api"
"fmt"
"strings"
"gopkg.in/alecthomas/kingpin.v2"
)
type pairList []portainer.Pair
// Set implementation for a list of portainer.Pair
func (l *pairList) Set(value string) error {
parts := strings.SplitN(value, "=", 2)
if len(parts) != 2 {
return fmt.Errorf("expected NAME=VALUE got '%s'", value)
}
p := new(portainer.Pair)
p.Name = parts[0]
p.Value = parts[1]
*l = append(*l, *p)
return nil
}
// String implementation for a list of pair
func (l *pairList) String() string {
return ""
}
// IsCumulative implementation for a list of pair
func (l *pairList) IsCumulative() bool {
return true
}
func pairs(s kingpin.Settings) (target *[]portainer.Pair) {
target = new([]portainer.Pair)
s.SetValue((*pairList)(target))
return
}