Files
talos/pkg/argsbuilder/argsbuilder_args.go
Andrew Rynhard e1fc9017d2 feat: allow extra arguments to be passed to etcd
This allows for an arbitrary set of args to be passed to etcd. Due to
the fact the we do the discovery of the current cluster state, we
blacklist initial-cluster. Additionally, we black list args that would
makes sense to modify, like the path to the certs.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2019-11-14 05:53:00 -08:00

56 lines
1.0 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package argsbuilder
import "fmt"
// Key represents an arg key.
type Key = string
// Value represents an arg value.
type Value = string
// Args represents a set of args.
type Args map[Key]Value
// Merge implements the ArgsBuilder interface.
func (a Args) Merge(args Args) ArgsBuilder {
for key, val := range args {
a[key] = val
}
return a
}
// Set implements the ArgsBuilder interface.
func (a Args) Set(k, v Key) ArgsBuilder {
a[k] = v
return a
}
// Args implements the ArgsBuilder interface.
func (a Args) Args() []string {
args := []string{}
for key, val := range a {
args = append(args, fmt.Sprintf("--%s=%s", key, val))
}
return args
}
// Get returns an args value.
func (a Args) Get(k Key) Value {
return a[k]
}
// Contains checks if an arg key exists.
func (a Args) Contains(k Key) bool {
_, ok := a[k]
return ok
}