parent
2d091a6b00
commit
a7970132c2
@ -88,14 +88,24 @@ func ValidateApp(c *cli.Context) config.App {
|
||||
}
|
||||
|
||||
// ValidateDomain ensures the domain name arg is valid.
|
||||
func ValidateDomain(c *cli.Context) string {
|
||||
func ValidateDomain(c *cli.Context) (string, error) {
|
||||
domainName := c.Args().First()
|
||||
|
||||
if domainName == "" && !NoInput {
|
||||
prompt := &survey.Input{
|
||||
Message: "Specify a domain name",
|
||||
Default: "example.com",
|
||||
}
|
||||
if err := survey.AskOne(prompt, &domainName); err != nil {
|
||||
return domainName, err
|
||||
}
|
||||
}
|
||||
|
||||
if domainName == "" {
|
||||
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
|
||||
}
|
||||
|
||||
logrus.Debugf("validated '%s' as domain argument", domainName)
|
||||
|
||||
return domainName
|
||||
return domainName, nil
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@ -30,12 +29,11 @@ You must specify a zone (e.g. example.com) under which your domain name records
|
||||
are listed. This zone must already be created on your provider account.
|
||||
`,
|
||||
Action: func(c *cli.Context) error {
|
||||
zone := c.Args().First()
|
||||
if zone == "" {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
||||
zone, err := internal.EnsureZoneArgument(c)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
var err error
|
||||
var provider gandi.Provider
|
||||
switch internal.DNSProvider {
|
||||
case "gandi":
|
||||
|
@ -1,7 +1,6 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -44,16 +43,15 @@ You may also invoke this command in "wizard" mode and be prompted for input
|
||||
abra record new
|
||||
`,
|
||||
Action: func(c *cli.Context) error {
|
||||
zone := c.Args().First()
|
||||
if zone == "" {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
||||
zone, err := internal.EnsureZoneArgument(c)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := internal.EnsureDNSProvider(); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
var err error
|
||||
var provider gandi.Provider
|
||||
switch internal.DNSProvider {
|
||||
case "gandi":
|
||||
|
@ -1,7 +1,6 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@ -43,16 +42,15 @@ You may also invoke this command in "wizard" mode and be prompted for input
|
||||
abra record rm
|
||||
`,
|
||||
Action: func(c *cli.Context) error {
|
||||
zone := c.Args().First()
|
||||
if zone == "" {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
||||
zone, err := internal.EnsureZoneArgument(c)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := internal.EnsureDNSProvider(); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
var err error
|
||||
var provider gandi.Provider
|
||||
switch internal.DNSProvider {
|
||||
case "gandi":
|
||||
|
@ -391,7 +391,7 @@ You may omit flags to avoid performing this provisioning logic.
|
||||
internal.ShowSubcommandHelpAndError(c, err)
|
||||
}
|
||||
|
||||
if sshAuth != "password" || sshAuth != "identity-file" {
|
||||
if sshAuth != "password" && sshAuth != "identity-file" {
|
||||
err := errors.New("--ssh-auth only accepts 'identity-file' or 'password'")
|
||||
internal.ShowSubcommandHelpAndError(c, err)
|
||||
}
|
||||
@ -403,7 +403,10 @@ You may omit flags to avoid performing this provisioning logic.
|
||||
return nil
|
||||
}
|
||||
|
||||
domainName := internal.ValidateDomain(c)
|
||||
domainName, err := internal.ValidateDomain(c)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := createServerDir(domainName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
@ -68,23 +68,31 @@ func newHetznerCloudVPS(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tableColumns = []string{"name", "ipv4", "root password"}
|
||||
table = formatter.CreateTable(tableColumns)
|
||||
var rootPassword string
|
||||
if len(sshKeys) > 0 {
|
||||
table.Append([]string{
|
||||
internal.HetznerCloudName,
|
||||
res.Server.PublicNet.IPv4.IP.String(),
|
||||
"N/A (using SSH keys)",
|
||||
})
|
||||
rootPassword = "N/A (using SSH keys)"
|
||||
} else {
|
||||
table.Append([]string{
|
||||
internal.HetznerCloudName,
|
||||
res.Server.PublicNet.IPv4.IP.String(),
|
||||
res.RootPassword,
|
||||
})
|
||||
rootPassword = res.RootPassword
|
||||
}
|
||||
table.SetCaption(true, "hetzner cloud creation response")
|
||||
table.Render()
|
||||
|
||||
ip := res.Server.PublicNet.IPv4.IP.String()
|
||||
|
||||
fmt.Println(fmt.Sprintf(`
|
||||
Your new Hetzner Cloud VPS has successfully been created! Here are the details:
|
||||
|
||||
VPS Name: %s
|
||||
VPS IP address: %s
|
||||
VPS Root Password: %s
|
||||
|
||||
You can access this new VPS via SSH using the following command:
|
||||
|
||||
ssh root@%s
|
||||
|
||||
Please note, this server is not managed by Abra yet (i.e. "abra server ls" will
|
||||
not list this server)! You will need to assign a domain name record ("abra
|
||||
record new") and add the server to your Abra configuration ("abra server add")
|
||||
to have a working server that you can deploy Co-op Cloud apps to.
|
||||
`, internal.HetznerCloudName, ip, rootPassword, ip))
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -136,11 +144,22 @@ func newCapsulVPS(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tableColumns = []string{"Name", "ID"}
|
||||
table = formatter.CreateTable(tableColumns)
|
||||
table.Append([]string{internal.CapsulName, resp.ID})
|
||||
table.SetCaption(true, "capsul creation response")
|
||||
table.Render()
|
||||
fmt.Println(fmt.Sprintf(`
|
||||
Your new Capsul has successfully been created! Here are the details:
|
||||
|
||||
Capsul name: %s
|
||||
Capsul ID: %v
|
||||
|
||||
You will need to log into your Capsul instance web interface to retrieve the IP
|
||||
address. You can learn all about how to get SSH access to your new Capsul on:
|
||||
|
||||
%s/about-ssh
|
||||
|
||||
Please note, this server is not managed by Abra yet (i.e. "abra server ls" will
|
||||
not list this server)! You will need to assign a domain name record ("abra
|
||||
record new") and add the server to your Abra configuration ("abra server add")
|
||||
to have a working server that you can deploy Co-op Cloud apps to.
|
||||
`, internal.CapsulName, resp.ID, internal.CapsulInstanceURL))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -45,7 +45,10 @@ like tears in rain.
|
||||
internal.DNSProviderFlag,
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
domainName := internal.ValidateDomain(c)
|
||||
domainName, err := internal.ValidateDomain(c)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if rmServer {
|
||||
if err := internal.EnsureServerProvider(); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user