fix: server/record improved output + interactivity
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2d091a6b00
commit
a7970132c2
@ -88,14 +88,24 @@ func ValidateApp(c *cli.Context) config.App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidateDomain ensures the domain name arg is valid.
|
// 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()
|
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 == "" {
|
if domainName == "" {
|
||||||
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
|
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("validated '%s' as domain argument", domainName)
|
logrus.Debugf("validated '%s' as domain argument", domainName)
|
||||||
|
|
||||||
return domainName
|
return domainName, nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"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.
|
are listed. This zone must already be created on your provider account.
|
||||||
`,
|
`,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
zone := c.Args().First()
|
zone, err := internal.EnsureZoneArgument(c)
|
||||||
if zone == "" {
|
if err != nil {
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
var provider gandi.Provider
|
var provider gandi.Provider
|
||||||
switch internal.DNSProvider {
|
switch internal.DNSProvider {
|
||||||
case "gandi":
|
case "gandi":
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -44,16 +43,15 @@ You may also invoke this command in "wizard" mode and be prompted for input
|
|||||||
abra record new
|
abra record new
|
||||||
`,
|
`,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
zone := c.Args().First()
|
zone, err := internal.EnsureZoneArgument(c)
|
||||||
if zone == "" {
|
if err != nil {
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := internal.EnsureDNSProvider(); err != nil {
|
if err := internal.EnsureDNSProvider(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
var provider gandi.Provider
|
var provider gandi.Provider
|
||||||
switch internal.DNSProvider {
|
switch internal.DNSProvider {
|
||||||
case "gandi":
|
case "gandi":
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -43,16 +42,15 @@ You may also invoke this command in "wizard" mode and be prompted for input
|
|||||||
abra record rm
|
abra record rm
|
||||||
`,
|
`,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
zone := c.Args().First()
|
zone, err := internal.EnsureZoneArgument(c)
|
||||||
if zone == "" {
|
if err != nil {
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no zone provided"))
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := internal.EnsureDNSProvider(); err != nil {
|
if err := internal.EnsureDNSProvider(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
var provider gandi.Provider
|
var provider gandi.Provider
|
||||||
switch internal.DNSProvider {
|
switch internal.DNSProvider {
|
||||||
case "gandi":
|
case "gandi":
|
||||||
|
@ -391,7 +391,7 @@ You may omit flags to avoid performing this provisioning logic.
|
|||||||
internal.ShowSubcommandHelpAndError(c, err)
|
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'")
|
err := errors.New("--ssh-auth only accepts 'identity-file' or 'password'")
|
||||||
internal.ShowSubcommandHelpAndError(c, err)
|
internal.ShowSubcommandHelpAndError(c, err)
|
||||||
}
|
}
|
||||||
@ -403,7 +403,10 @@ You may omit flags to avoid performing this provisioning logic.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
domainName := internal.ValidateDomain(c)
|
domainName, err := internal.ValidateDomain(c)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := createServerDir(domainName); err != nil {
|
if err := createServerDir(domainName); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
@ -68,23 +68,31 @@ func newHetznerCloudVPS(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tableColumns = []string{"name", "ipv4", "root password"}
|
var rootPassword string
|
||||||
table = formatter.CreateTable(tableColumns)
|
|
||||||
if len(sshKeys) > 0 {
|
if len(sshKeys) > 0 {
|
||||||
table.Append([]string{
|
rootPassword = "N/A (using SSH keys)"
|
||||||
internal.HetznerCloudName,
|
|
||||||
res.Server.PublicNet.IPv4.IP.String(),
|
|
||||||
"N/A (using SSH keys)",
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
table.Append([]string{
|
rootPassword = res.RootPassword
|
||||||
internal.HetznerCloudName,
|
|
||||||
res.Server.PublicNet.IPv4.IP.String(),
|
|
||||||
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
|
return nil
|
||||||
}
|
}
|
||||||
@ -136,11 +144,22 @@ func newCapsulVPS(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tableColumns = []string{"Name", "ID"}
|
fmt.Println(fmt.Sprintf(`
|
||||||
table = formatter.CreateTable(tableColumns)
|
Your new Capsul has successfully been created! Here are the details:
|
||||||
table.Append([]string{internal.CapsulName, resp.ID})
|
|
||||||
table.SetCaption(true, "capsul creation response")
|
Capsul name: %s
|
||||||
table.Render()
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,10 @@ like tears in rain.
|
|||||||
internal.DNSProviderFlag,
|
internal.DNSProviderFlag,
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
domainName := internal.ValidateDomain(c)
|
domainName, err := internal.ValidateDomain(c)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if rmServer {
|
if rmServer {
|
||||||
if err := internal.EnsureServerProvider(); err != nil {
|
if err := internal.EnsureServerProvider(); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user