Documentation ¶
Index ¶
- Variables
- func ConsulClient(consulAddress string) (*consul.Client, error)
- func Contains(elm string, list []string) bool
- func Filter(vs []string, f func(string) bool) []string
- func ListConsulKv(client *consul.Client, prefix string, q *consul.QueryOptions) (consul.KVPairs, error)
- func MapsEqual(a, b map[string]string) bool
- func MarkAsOutdated(client *consul.Client, name string, delay time.Duration) error
- func MergeMaps(maps ...map[string]string) map[string]string
- func RunCmd(cmdline string, a ...interface{}) error
- func RunParallelSshCmd(cluster, sshUser, cmd string, maxProcs int) error
- func RunSingleSshCmd(cluster, sshUser, cmd string) error
- func RunSshCmd(cluster, sshUser, cmd string) error
- func Substr(s string, pos, length int) string
- type BySortIndex
Constants ¶
This section is empty.
Variables ¶
View Source
var DelConsulKv = func(client *consul.Client, key string) error { log.Printf("consul delete `%s`", key) _, err := client.KV().Delete(strings.TrimPrefix(key, "/"), nil) return err }
View Source
var DeletePluginData = func(plugin string, packageName string, consulAddress string) error { log.Println(color.YellowString("Delete %s for %s package in consul", plugin, packageName)) consulApi, err := ConsulClient(consulAddress) if err != nil { return err } return DelConsulKv(consulApi, "services/data/"+packageName+"/"+plugin) }
View Source
var PutConsulKv = func(client *consul.Client, key string, value string) error { log.Printf("consul put `%s`: %s", key, value) _, err := client.KV().Put(&consul.KVPair{Key: strings.TrimPrefix(key, "/"), Value: []byte(value)}, nil) return err }
View Source
var RandomString = func(length uint) string { b := make([]rune, length) for i := range b { b[i] = allLetters[rand.Intn(len(allLetters))] } return string(b) }
View Source
var RegisterPluginData = func(plugin string, packageName string, data string, consulAddress string) error { consulApi, err := ConsulClient(consulAddress) if err != nil { return err } return PutConsulKv(consulApi, "services/data/"+packageName+"/"+plugin, data) }
View Source
var RunCmdWithEnv = func(cmdline string, env map[string]string) error { log.Println(color.YellowString("> %s", cmdline)) cmd := exec.Command("/bin/bash", "-c", cmdline) cmd.Env = os.Environ() for k, v := range env { cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%v", k, v)) } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return cmd.Run() }
Functions ¶
func ListConsulKv ¶
func MarkAsOutdated ¶
func RunParallelSshCmd ¶
func RunSingleSshCmd ¶
Types ¶
type BySortIndex ¶
func (BySortIndex) Len ¶
func (a BySortIndex) Len() int
func (BySortIndex) Less ¶
func (a BySortIndex) Less(i, j int) bool
func (BySortIndex) Swap ¶
func (a BySortIndex) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.