func cmdUp(cmd *cobra.Command, args []string) { // FIXME: duplicate internal.ReadConfig() var ns string // Check args if len(args) > 1 { internal.Exit("Invalid usage. sail compose up [<application>]. Please see sail compose up -h\n") } else if len(args) > 1 { ns = args[0] } else { ns = internal.User } // Try to read file payload, err := ioutil.ReadFile(upFile) if err != nil { internal.Exit("Error reading compose file: %s\n", err) } // Execute request path := fmt.Sprintf("/applications/%s/fig/up", ns) buffer, _, err := internal.Stream("POST", path, payload, internal.SetHeader("Content-Type", "application/x-yaml")) internal.Check(err) // Display api stream line, err := internal.DisplayStream(buffer) internal.Check(err) if len(line) > 0 { var data []map[string]interface{} err = json.Unmarshal(line, &data) if err != nil { fmt.Printf("Error detected in API Return. Line: %s\n", line) return } for i := range data { fmt.Printf("Compose operation for service %v is %v\n", data[i]["name"], data[i]["result"]) } } }
func cmdGet(cmd *cobra.Command, args []string) { // FIXME: duplicate internal.ReadConfig() var ns string // Check args if len(args) > 1 { internal.Exit("Invalid usage. sail compose get [--standard] [<application>]. Please see sail compose get -h\n") } else if len(args) > 1 { ns = args[0] } else { ns = internal.User } path := fmt.Sprintf("/applications/%s/fig?standard=%v", ns, getStandard) data, _, err := internal.Request("GET", path, nil) if err != nil { internal.Exit("Error: %s\n", err) } fmt.Printf("%s", data) }
func prettyFormater(data []byte) { fmt.Fprintf(os.Stderr, "Version sail: %s\n", internal.VERSION) internal.ReadConfig() }