Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddSshFingerprintCommand = cli.Command{ Name: "add", Usage: "Add an SSH key to be used on Droplet creation", Aliases: []string{"+"}, Action: func(c *cli.Context) { if len(c.Args()) < 1 { fmt.Println("To get the SSH fingerprint of your key `id_rsa`, simply type:") fmt.Println("ssh-keygen -lf id_rsa.pub") fmt.Println("You will get something like 'aa:bb:cc:dd'. Exactly what we need! Set it up using") fmt.Println("doenv ssh add 'aa:bb:cc:dd'") fmt.Println("!! The key must already be configured on DigitalOcean to be used !!") return } else { AddSshFingerprint(c.Args().First()) fmt.Println("SSH Fingerprint added! It will be used for the next Droplet creations") SaveSettings() os.Exit(0) } }, }
View Source
var CreateCommand = cli.Command{ Name: "create", Aliases: []string{"c", "init", "setup"}, Usage: "Create a droplet (Initial setup)", ArgsUsage: "<droplet name> [image] [region] [size]", Action: func(c *cli.Context) { var DropletName string var Image string var Region string var Size string if len(c.Args()) < 1 { DropletName = namesgenerator.GetRandomName(1) } else { DropletName = c.Args().Get(0) } if len(c.Args()) < 2 { Image = "debian-8-x64" } else { Image = c.Args().Get(1) } if len(c.Args()) < 3 { Size = "512mb" } else { Size = c.Args().Get(2) } if len(c.Args()) < 4 { Region = "nyc2" } else { Region = c.Args().Get(3) } createDroplet(DropletName, Image, Size, Region) }, }
View Source
var DelSshFingerprintCommand = cli.Command{ Name: "del", Aliases: []string{"delete", "rm", "remove"}, Usage: "Stop using this SSH keys on Droplet creation", Action: func(c *cli.Context) { if len(c.Args()) < 1 { fmt.Println("To get the SSH fingerprint of your key `id_rsa`, simply type:") fmt.Println("ssh-keygen -lf id_rsa.pub") fmt.Println("You will get something like 'aa:bb:cc:dd'. Exactly what we need! Set it up using") fmt.Println("doenv ssh rm 'aa:bb:cc:dd'") fmt.Println("You may also use `doenv ssh list` to see the used fingerprints") return } else { DelSshFingerprint(c.Args().First()) fmt.Println("SSH Fingerprint removed! :(") SaveSettings() os.Exit(0) } }, }
View Source
var EraseCommand = cli.Command{ Name: "erase", Usage: "Let's just drop this droplet.", ArgsUsage: "<droplet name>", Action: func(c *cli.Context) { var DropletName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) eraseDroplet(DropletName) }, }
View Source
var FreezeCommand = cli.Command{ Name: "freeze", Usage: "Freeze a droplet (Stop, Snapshot and Destroy)", ArgsUsage: "<droplet name>", Action: func(c *cli.Context) { var DropletName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) freezeDroplet(DropletName) }, }
View Source
var KeysCommand = cli.Command{ Name: "keys", Usage: "Manage the SSH keys used", Subcommands: []cli.Command{ AddSshFingerprintCommand, ListSshFingerprintsCommand, DelSshFingerprintCommand, }, Action: func(c *cli.Context) { cli.ShowSubcommandHelp(c) }, }
View Source
var ListCommand = cli.Command{ Name: "list", Aliases: []string{"ls"}, Usage: "List your droplets", Action: func(c *cli.Context) { listImages("both") fmt.Println() listDroplets() }, Subcommands: []cli.Command{ { Name: "droplets", Aliases: []string{"d"}, Usage: "List your droplets", Action: func(c *cli.Context) { listDroplets() }, }, { Name: "snapshots", Aliases: []string{"s"}, Usage: "List your snapshots", Action: func(c *cli.Context) { listImages("snapshots") }, }, { Name: "image", Aliases: []string{"i"}, Usage: "List the publicly available images", Action: func(c *cli.Context) { listImages("images") }, }, }, }
View Source
var ListSshFingerprintsCommand = cli.Command{ Name: "list", Usage: "List SSH keys to be used on Droplet creation", Aliases: []string{"ls"}, Action: func(c *cli.Context) { if len(GetSettings().SSHFingerprints) == 0 { fmt.Println("You don't have any SSH Fingerprints setup to be used.") return } fmt.Println("SSH Fingerprints") table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Fingerprint"}) table.SetBorder(false) for _, f := range GetSettings().SSHFingerprints { table.Append([]string{f}) } table.Render() }, }
View Source
var RestoreCommand = cli.Command{ Name: "restore", Aliases: []string{"bring", "up"}, Usage: "Create a droplet based on a snapshot (Restore snapshot, start)", ArgsUsage: "<snapshot name> [droplet name]", Action: func(c *cli.Context) { var DropletName string var SnapshotName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the snapshot name ?! :(") return } SnapshotName = c.Args().Get(0) if len(c.Args()) < 2 { DropletName = SnapshotName } else { DropletName = c.Args().Get(1) } restoreDroplet(SnapshotName, DropletName) }, }
View Source
var SetTokenCommand = cli.Command{ Name: "set-token", Usage: "Set your Personnal API Token (PAT)", Action: func(c *cli.Context) { if len(c.Args()) < 1 { fmt.Println("Sorry, but I can't read what's in your mind.") fmt.Println("Just give me your Personnal App Token and we'll be friends. :)") } else { SetPersonnalApiToken(c.Args().Get(0)) fmt.Println("Great! Now we can work together.") fmt.Println("How about creating a small project ? Would you ? Just run `doenv init my-project` :)") SaveSettings() os.Exit(0) } }, }
View Source
var SnapshotCommand = cli.Command{ Name: "snapshot", Aliases: []string{"snap", "shot"}, Usage: "Snapshot a droplet to reuse it later", ArgsUsage: "<droplet name> [snapshot name]", Action: func(c *cli.Context) { var DropletName string var SnapshotName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) if len(c.Args()) < 2 { SnapshotName = DropletName } else { SnapshotName = c.Args().Get(1) } snapshotDroplet(DropletName, SnapshotName) }, }
View Source
var SshCommand = cli.Command{ Name: "ssh", Aliases: []string{"enter", "hack"}, Usage: "Hack into a droplet!", ArgsUsage: "<droplet name>", Action: func(c *cli.Context) { var DropletName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) sshDroplet(DropletName) }, }
View Source
var StartCommand = cli.Command{ Name: "start", Usage: "Start a droplet (PowerOn)", ArgsUsage: "<droplet name>", Action: func(c *cli.Context) { var DropletName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) startDroplet(DropletName) }, }
View Source
var StatusCommand = cli.Command{ Name: "status", Usage: "Fetch a droplet status", ArgsUsage: "<droplet name ...>", Action: func(c *cli.Context) { statusDroplet(c.Args()) }, }
View Source
var StopCommand = cli.Command{ Name: "stop", Usage: "Shutdown a droplet", ArgsUsage: "<droplet name>", Action: func(c *cli.Context) { var DropletName string if len(c.Args()) < 1 { fmt.Println("Meh. Where's the droplet name ?! :(") return } DropletName = c.Args().Get(0) stopDroplet(DropletName) }, }
Functions ¶
func GuessCommand ¶
func GuessCommand(DropletName string)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.