func runRun(c *cli.Context) { if runtime.GOOS == "windows" { printFatal("Not supported on Windows") os.Exit(2) } stack := mustStack(c) if c.String("service") != "" && stack.Framework != "docker" { printFatal("The service option only applies to docker stacks") os.Exit(2) } serverName := c.String("server") if !c.IsSet("service") { if len(c.Args()) != 1 { cli.ShowCommandHelp(c, "run") os.Exit(2) } } userCommand := "" if len(c.Args()) == 1 { userCommand = c.Args()[0] } servers, err := client.Servers(stack.Uid) if err != nil { printFatal(err.Error()) } server, err := findServer(servers, serverName) if err != nil { printFatal(err.Error()) } if server == nil { printFatal("Server '" + serverName + "' not found") } if c.String("service") != "" { // fetch service information for existing server/command service, err := client.GetService(stack.Uid, c.String("service"), &server.Uid, &userCommand) must(err) userCommand = service.WrapCommand } includeTty := c.String("service") != "" err = SshToServerForCommand(*server, userCommand, includeTty) if err != nil { printFatal(err.Error()) } }
func runUpload(c *cli.Context) { if runtime.GOOS == "windows" { printFatal("Not supported on Windows") os.Exit(2) } stack := mustStack(c) // args start after stack name // and check if user specified target directory var targetDirectory string = "" if len(c.Args()) < 1 { cli.ShowCommandHelp(c, "upload") os.Exit(2) } else if len(c.Args()) == 2 { targetDirectory = c.Args()[1] } // get the server serverName := c.String("server") // get the file path filePath := c.Args()[0] servers, err := client.Servers(stack.Uid) if err != nil { printFatal(err.Error()) } server, err := findServer(servers, serverName) if err != nil { printError("server not found, please ensure correct server is specified in command.") os.Exit(2) } if server == nil { printFatal("Server '" + serverName + "' not found") } fmt.Printf("Server: %s\n", server.Name) if targetDirectory == "" { err = sshToServerToUpload(*server, filePath) } else { err = sshToServerToUpload(*server, filePath, targetDirectory) } if err != nil { printFatal(err.Error()) } }
func runSsh(c *cli.Context) { if runtime.GOOS == "windows" { printFatal("Not supported on Windows") os.Exit(2) } stack := mustStack(c) if len(c.Args()) != 1 { cli.ShowCommandHelp(c, "ssh") os.Exit(2) } // get the server serverName := c.Args()[0] servers, err := client.Servers(stack.Uid) if err != nil { printFatal(err.Error()) } server, err := findServer(servers, serverName) if err != nil { printFatal(err.Error()) } if server == nil { printFatal("Server '" + serverName + "' not found") } fmt.Printf("Server: %s\n", server.Name) err = sshToServer(*server) if err != nil { printError("If you're having issues connecting to your server, you may find some help at http://help.cloud66.com/managing-your-stack/ssh-to-your-server") printFatal(err.Error()) } }
func dummyCommand(c *cli.Context) { cli.ShowCommandHelp(c, "help-environ") }