mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-04-27 19:15:23 +00:00
* accept custom cluster config locations Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> * use yaml.v3 Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> * go mod tidy Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> * added custom root and config flag in cluster properties * remove ClusterRootPath Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> * go mod tidy Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> --------- Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> Co-authored-by: Piyush Kumar <k17piyush@gmail.com>
32 lines
587 B
Go
32 lines
587 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"gopkg.in/yaml.v3"
|
|
"math/rand"
|
|
"strings"
|
|
)
|
|
|
|
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
|
|
func RandStringRunes(n int) string {
|
|
b := make([]rune, n)
|
|
for i := range b {
|
|
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
func ListOutput(rels []string, output string) []string {
|
|
switch strings.ToLower(output) {
|
|
case "yaml":
|
|
d, _ := yaml.Marshal(rels)
|
|
return []string{string(d)}
|
|
case "json":
|
|
d, _ := json.Marshal(rels)
|
|
return []string{string(d)}
|
|
default:
|
|
return rels
|
|
}
|
|
}
|