func main() { appname := "app1" labels := []string{""} if appname == "" { fmt.Println() } fmt.Println("APPNAME", "======", appname) api := common.NewAPI("http://localhost:4747") api.Debug(true) listEnv() fmt.Println("GET VALUES ===") values, err := api.GetValues(appname, labels) if err != nil { fmt.Println("ERROR GETTING THE VALUES") os.Exit(9) } for _, v := range values.Values { os.Setenv(v.Name, v.Value) } fmt.Println("LIST ENV VARIABLES (AGAIN)") listEnv() }
func main() { host := os.Getenv("SIESTA_HOST") appname := os.Getenv("SIESTA_APP") labels := strings.Split(os.Getenv("SIESTA_LABELS"), ",") if appname == "" { fmt.Println("ERROR, SIESTA_APP not defined") os.Exit(1) } if host == "" { host = "http://gophersiesta.herokuapp.com/" } api := common.NewAPI(host) values, err := api.GetValues(appname, labels) if err != nil { fmt.Println("ERROR GETTING THE VALUES") os.Exit(2) } for _, v := range values.Values { os.Setenv(v.Name, v.Value) } listEnv() }
func Execute() { api = common.NewAPI("http://localhost:4747") //api.Debug(true) g := gocui.NewGui() if err := g.Init(); err != nil { log.Panicln(err) } defer g.Close() g.SetLayout(layout) if err := keybindings(g); err != nil { log.Panicln(err) } g.SelBgColor = gocui.ColorGreen g.SelFgColor = gocui.ColorBlack g.Cursor = true if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { log.Panicln(err) } }
func main() { appname := "app1" labels := []string{""} api := common.NewAPI("http://localhost:4747") api.Debug(true) fmt.Println("GET APPS ===") fmt.Println(api.GetApps()) fmt.Println("GET TEMPLATE ===") fmt.Println(api.GetTemplate(appname)) fmt.Println("GET PLACEHOLDERS ===") fmt.Println(api.GetPlaceholders(appname)) fmt.Println("GET LABELS ===") fmt.Println(api.GetLabels(appname)) fmt.Println("GET VALUES ===") fmt.Println(api.GetValues(appname, labels)) fmt.Println("SET VALUES ===") v1 := common.Value{"name1", "value1"} v2 := common.Value{"name2", "value2"} v3 := common.Value{"name3", "value3"} values := common.Values{[]*common.Value{&v1, &v2, &v3}} fmt.Println(api.SetValues(appname, labels, values)) fmt.Println("GET VALUES (AGAIN) ===") fmt.Println(api.GetValues(appname, labels)) fmt.Println("RENDER ===") fmt.Println(api.Render(appname, labels, "original")) }
"fmt" "strings" "os" "github.com/gophersiesta/gophersiesta/Godeps/_workspace/src/github.com/spf13/cobra" "github.com/gophersiesta/gophersiesta/common" ) // setCmd represents the set command var setCmd = &cobra.Command{ Use: "set", Short: "Set all the values to configuration manager. Needed {appname + label}", Long: "Set all the values to be setup. From appname + label", Run: func(cmd *cobra.Command, args []string) { api := common.NewAPI(source) data := map[string]interface{}{} json.Unmarshal([]byte(properties), &data) var values common.Values if len(data) > 0 { //it's a JSON for k, v := range data { values.Values = append(values.Values, &common.Value{k, fmt.Sprint(v)}) } } else if strings.Contains(properties, "=") { pairs := strings.Split(properties, ",") for _, v := range pairs { vv := strings.Split(v, "=") values.Values = append(values.Values, &common.Value{vv[0], strings.Join(vv[1:], "=")})