|
|
|
@ -64,6 +64,11 @@ var subCmdAdminCreateNetwork = subCmd{ |
|
|
|
|
"Write the default configuration file to stdout and exit.", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
name := flags.StringP( |
|
|
|
|
"name", "n", "", |
|
|
|
|
"Human-readable name to identify the network as.", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
domain := flags.StringP( |
|
|
|
|
"domain", "d", "", |
|
|
|
|
"Domain name that should be used as the root domain in the network.", |
|
|
|
@ -75,7 +80,7 @@ var subCmdAdminCreateNetwork = subCmd{ |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
hostName := flags.StringP( |
|
|
|
|
"name", "n", "", |
|
|
|
|
"hostname", "h", "", |
|
|
|
|
"Name of this host, which will be the first host in the network", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -87,8 +92,8 @@ var subCmdAdminCreateNetwork = subCmd{ |
|
|
|
|
return daemon.CopyDefaultConfig(os.Stdout, envAppDirPath) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if *domain == "" || *ipNetStr == "" || *hostName == "" { |
|
|
|
|
return errors.New("--domain, --ip-net, and --name are required") |
|
|
|
|
if *name == "" || *domain == "" || *ipNetStr == "" || *hostName == "" { |
|
|
|
|
return errors.New("--name, --domain, --ip-net, and --hostname are required") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*domain = strings.TrimRight(strings.TrimLeft(*domain, "."), ".") |
|
|
|
@ -129,6 +134,7 @@ var subCmdAdminCreateNetwork = subCmd{ |
|
|
|
|
|
|
|
|
|
adminCreationParams := admin.CreationParams{ |
|
|
|
|
ID: randStr(32), |
|
|
|
|
Name: *name, |
|
|
|
|
Domain: *domain, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -235,8 +241,8 @@ var subCmdAdminMakeBootstrap = subCmd{ |
|
|
|
|
|
|
|
|
|
flags := subCmdCtx.flagSet(false) |
|
|
|
|
|
|
|
|
|
name := flags.StringP( |
|
|
|
|
"name", "n", "", |
|
|
|
|
hostName := flags.StringP( |
|
|
|
|
"hostname", "h", "", |
|
|
|
|
"Name of the host to generate bootstrap.yml for", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -254,12 +260,12 @@ var subCmdAdminMakeBootstrap = subCmd{ |
|
|
|
|
return fmt.Errorf("parsing flags: %w", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if *name == "" || *ipStr == "" || *adminPath == "" { |
|
|
|
|
return errors.New("--name, --ip, and --admin-path are required") |
|
|
|
|
if *hostName == "" || *ipStr == "" || *adminPath == "" { |
|
|
|
|
return errors.New("--hostname, --ip, and --admin-path are required") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := validateHostName(*name); err != nil { |
|
|
|
|
return fmt.Errorf("invalid hostname %q: %w", *name, err) |
|
|
|
|
if err := validateHostName(*hostName); err != nil { |
|
|
|
|
return fmt.Errorf("invalid hostname %q: %w", *hostName, err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ip := net.ParseIP(*ipStr) |
|
|
|
@ -278,7 +284,7 @@ var subCmdAdminMakeBootstrap = subCmd{ |
|
|
|
|
return fmt.Errorf("loading host bootstrap: %w", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
nebulaHostCreds, err := nebula.NewHostCredentials(adm.Nebula.CACredentials, *name, ip) |
|
|
|
|
nebulaHostCreds, err := nebula.NewHostCredentials(adm.Nebula.CACredentials, *hostName, ip) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("creating new nebula host key/cert: %w", err) |
|
|
|
|
} |
|
|
|
@ -287,7 +293,7 @@ var subCmdAdminMakeBootstrap = subCmd{ |
|
|
|
|
AdminCreationParams: adm.CreationParams, |
|
|
|
|
|
|
|
|
|
Hosts: hostBootstrap.Hosts, |
|
|
|
|
HostName: *name, |
|
|
|
|
HostName: *hostName, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
newHostBootstrap.Nebula.HostCredentials = nebulaHostCreds |
|
|
|
|