refactor: domainName as arg and doc strings

See coop-cloud/organising#163.
This commit is contained in:
2021-09-10 15:04:01 +02:00
parent 683ef0c3de
commit 99160967a8
4 changed files with 20 additions and 21 deletions

View File

@ -2,7 +2,6 @@ package server
import (
"context"
"errors"
"fmt"
"net"
"time"
@ -20,7 +19,7 @@ var serverInitCommand = &cli.Command{
Usage: "Initialise server for deploying apps",
Aliases: []string{"i"},
HideHelp: true,
ArgsUsage: "<server>",
ArgsUsage: "<domain>",
Description: `
Initialise swarm mode on the target <server>.
@ -29,12 +28,9 @@ the default IPv4 address as the advertising address. This can be re-configured
later for more advanced use cases.
`,
Action: func(c *cli.Context) error {
server := c.Args().First()
if server == "" {
internal.ShowSubcommandHelpAndError(c, errors.New("no server provided"))
}
domainName := internal.ValidateDomain(c)
cl, err := client.New(server)
cl, err := client.New(domainName)
if err != nil {
return err
}
@ -51,13 +47,13 @@ later for more advanced use cases.
}
ctx := context.Background()
ips, err := resolver.LookupIPAddr(ctx, server)
ips, err := resolver.LookupIPAddr(ctx, domainName)
if err != nil {
logrus.Fatal(err)
}
if len(ips) == 0 {
return fmt.Errorf("unable to retrieve ipv4 address for %s", server)
return fmt.Errorf("unable to retrieve ipv4 address for %s", domainName)
}
ipv4 := ips[0].IP.To4().String()