Various fixes to bugs in admin create-network
This commit is contained in:
parent
6ba8b948c2
commit
b935457439
@ -36,7 +36,8 @@ func (b Bootstrap) GaragePeers() []garage.RemotePeer {
|
||||
func (b Bootstrap) GarageRPCPeerAddrs() []string {
|
||||
var addrs []string
|
||||
for _, peer := range b.GaragePeers() {
|
||||
addrs = append(addrs, peer.RPCPeerAddr())
|
||||
addr := peer.RPCPeerAddr()
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
return addrs
|
||||
}
|
||||
|
@ -69,14 +69,14 @@ var subCmdAdminCreateNetwork = subCmd{
|
||||
"Domain name that should be used as the root domain in the network.",
|
||||
)
|
||||
|
||||
subnetStr := flags.StringP(
|
||||
"subnet", "s", "",
|
||||
"CIDR which denotes the subnet that IPs hosts on the network can be assigned.",
|
||||
ipNetStr := flags.StringP(
|
||||
"ip-net", "i", "",
|
||||
`IP+prefix (e.g. "10.10.0.1/16") which denotes the IP of this host, which will be the first host in the network, and the range of IPs which other hosts in the network can be assigned`,
|
||||
)
|
||||
|
||||
hostName := flags.StringP(
|
||||
"name", "n", "",
|
||||
"Name of the host which will be the first host in the network",
|
||||
"Name of this host, which will be the first host in the network",
|
||||
)
|
||||
|
||||
if err := flags.Parse(subCmdCtx.args); err != nil {
|
||||
@ -87,15 +87,15 @@ var subCmdAdminCreateNetwork = subCmd{
|
||||
return daemon.CopyDefaultConfig(os.Stdout, envAppDirPath)
|
||||
}
|
||||
|
||||
if *domain == "" || *subnetStr == "" || *hostName == "" {
|
||||
return errors.New("--domain, --subnet, and --name are required")
|
||||
if *domain == "" || *ipNetStr == "" || *hostName == "" {
|
||||
return errors.New("--domain, --ip-net, and --name are required")
|
||||
}
|
||||
|
||||
*domain = strings.TrimRight(strings.TrimLeft(*domain, "."), ".")
|
||||
|
||||
ip, subnet, err := net.ParseCIDR(*subnetStr)
|
||||
ip, subnet, err := net.ParseCIDR(*ipNetStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("parsing %q as a CIDR: %w", *subnetStr, err)
|
||||
return fmt.Errorf("parsing %q as a CIDR: %w", *ipNetStr, err)
|
||||
}
|
||||
|
||||
if err := validateHostName(*hostName); err != nil {
|
||||
|
@ -59,6 +59,7 @@ func InitAlloc(metaDirPath string) (string, error) {
|
||||
return false
|
||||
|
||||
} else if _, err = os.Stat(path); errors.Is(err, fs.ErrNotExist) {
|
||||
err = nil
|
||||
return false
|
||||
|
||||
} else if err != nil {
|
||||
@ -100,5 +101,5 @@ func InitAlloc(metaDirPath string) (string, error) {
|
||||
return "", fmt.Errorf("writing public key to %q: %w", nodeKeyPubPath, err)
|
||||
}
|
||||
|
||||
return "", nil
|
||||
return hex.EncodeToString(pubKey), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user