Add Name field to admin.CreationParams
This commit is contained in:
parent
bd5a5552bc
commit
c0ebca193d
@ -44,7 +44,7 @@ following command from their own host:
|
|||||||
|
|
||||||
```
|
```
|
||||||
cryptic-net hosts make-bootstrap \
|
cryptic-net hosts make-bootstrap \
|
||||||
--name <name> \
|
--hostname <name> \
|
||||||
--ip <ip> \
|
--ip <ip> \
|
||||||
--admin-path <path to admin.yml> \
|
--admin-path <path to admin.yml> \
|
||||||
> bootstrap.yml
|
> bootstrap.yml
|
||||||
@ -67,7 +67,7 @@ generate a `bootstrap.yml`:
|
|||||||
|
|
||||||
```
|
```
|
||||||
gpg -d <path to admin.yml.gpg> | cryptic-net hosts make-boostrap \
|
gpg -d <path to admin.yml.gpg> | cryptic-net hosts make-boostrap \
|
||||||
--name <name> \
|
--hostname <name> \
|
||||||
--ip <ip> \
|
--ip <ip> \
|
||||||
--admin-path - \
|
--admin-path - \
|
||||||
> bootstrap.yml
|
> bootstrap.yml
|
||||||
|
@ -61,6 +61,9 @@ There are some key parameters which must be chosen when creating a new network.
|
|||||||
These will remain constant throughout the lifetime of the network, and so should
|
These will remain constant throughout the lifetime of the network, and so should
|
||||||
be chosen with care.
|
be chosen with care.
|
||||||
|
|
||||||
|
* Name: A human-readable name for the network. This will only be used for
|
||||||
|
display purposes.
|
||||||
|
|
||||||
* Subnet: The IP subnet (or CIDR) will look something like `10.10.0.0/16`, where
|
* Subnet: The IP subnet (or CIDR) will look something like `10.10.0.0/16`, where
|
||||||
the `/16` indicates that all IPs from `10.10.0.0` to `10.10.255.255` are
|
the `/16` indicates that all IPs from `10.10.0.0` to `10.10.255.255` are
|
||||||
included. It's recommended to choose from the [ranges reserved for private
|
included. It's recommended to choose from the [ranges reserved for private
|
||||||
@ -102,9 +105,10 @@ you can run:
|
|||||||
```
|
```
|
||||||
sudo cryptic-net admin create-network \
|
sudo cryptic-net admin create-network \
|
||||||
--config /path/to/daemon.yml \
|
--config /path/to/daemon.yml \
|
||||||
|
--name <name> \
|
||||||
|
--ip <ip/subnet-prefix> \
|
||||||
--domain <domain> \
|
--domain <domain> \
|
||||||
--ip <ip/subnet-prefix> \
|
--hostname <hostname> \
|
||||||
--name <hostname> \
|
|
||||||
| gpg -e -r <my gpg email> \
|
| gpg -e -r <my gpg email> \
|
||||||
> admin.yml.gpg
|
> admin.yml.gpg
|
||||||
```
|
```
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
// are available to all hosts within the network via their bootstrap files.
|
// are available to all hosts within the network via their bootstrap files.
|
||||||
type CreationParams struct {
|
type CreationParams struct {
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
|
Name string `yaml:"name"`
|
||||||
Domain string `yaml:"domain"`
|
Domain string `yaml:"domain"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,11 @@ var subCmdAdminCreateNetwork = subCmd{
|
|||||||
"Write the default configuration file to stdout and exit.",
|
"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 := flags.StringP(
|
||||||
"domain", "d", "",
|
"domain", "d", "",
|
||||||
"Domain name that should be used as the root domain in the network.",
|
"Domain name that should be used as the root domain in the network.",
|
||||||
@ -75,7 +80,7 @@ var subCmdAdminCreateNetwork = subCmd{
|
|||||||
)
|
)
|
||||||
|
|
||||||
hostName := flags.StringP(
|
hostName := flags.StringP(
|
||||||
"name", "n", "",
|
"hostname", "h", "",
|
||||||
"Name of this host, which will be the first host in the network",
|
"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)
|
return daemon.CopyDefaultConfig(os.Stdout, envAppDirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *domain == "" || *ipNetStr == "" || *hostName == "" {
|
if *name == "" || *domain == "" || *ipNetStr == "" || *hostName == "" {
|
||||||
return errors.New("--domain, --ip-net, and --name are required")
|
return errors.New("--name, --domain, --ip-net, and --hostname are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
*domain = strings.TrimRight(strings.TrimLeft(*domain, "."), ".")
|
*domain = strings.TrimRight(strings.TrimLeft(*domain, "."), ".")
|
||||||
@ -129,6 +134,7 @@ var subCmdAdminCreateNetwork = subCmd{
|
|||||||
|
|
||||||
adminCreationParams := admin.CreationParams{
|
adminCreationParams := admin.CreationParams{
|
||||||
ID: randStr(32),
|
ID: randStr(32),
|
||||||
|
Name: *name,
|
||||||
Domain: *domain,
|
Domain: *domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +241,8 @@ var subCmdAdminMakeBootstrap = subCmd{
|
|||||||
|
|
||||||
flags := subCmdCtx.flagSet(false)
|
flags := subCmdCtx.flagSet(false)
|
||||||
|
|
||||||
name := flags.StringP(
|
hostName := flags.StringP(
|
||||||
"name", "n", "",
|
"hostname", "h", "",
|
||||||
"Name of the host to generate bootstrap.yml for",
|
"Name of the host to generate bootstrap.yml for",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -254,12 +260,12 @@ var subCmdAdminMakeBootstrap = subCmd{
|
|||||||
return fmt.Errorf("parsing flags: %w", err)
|
return fmt.Errorf("parsing flags: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *name == "" || *ipStr == "" || *adminPath == "" {
|
if *hostName == "" || *ipStr == "" || *adminPath == "" {
|
||||||
return errors.New("--name, --ip, and --admin-path are required")
|
return errors.New("--hostname, --ip, and --admin-path are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateHostName(*name); err != nil {
|
if err := validateHostName(*hostName); err != nil {
|
||||||
return fmt.Errorf("invalid hostname %q: %w", *name, err)
|
return fmt.Errorf("invalid hostname %q: %w", *hostName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ip := net.ParseIP(*ipStr)
|
ip := net.ParseIP(*ipStr)
|
||||||
@ -278,7 +284,7 @@ var subCmdAdminMakeBootstrap = subCmd{
|
|||||||
return fmt.Errorf("loading host bootstrap: %w", err)
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("creating new nebula host key/cert: %w", err)
|
return fmt.Errorf("creating new nebula host key/cert: %w", err)
|
||||||
}
|
}
|
||||||
@ -287,7 +293,7 @@ var subCmdAdminMakeBootstrap = subCmd{
|
|||||||
AdminCreationParams: adm.CreationParams,
|
AdminCreationParams: adm.CreationParams,
|
||||||
|
|
||||||
Hosts: hostBootstrap.Hosts,
|
Hosts: hostBootstrap.Hosts,
|
||||||
HostName: *name,
|
HostName: *hostName,
|
||||||
}
|
}
|
||||||
|
|
||||||
newHostBootstrap.Nebula.HostCredentials = nebulaHostCreds
|
newHostBootstrap.Nebula.HostCredentials = nebulaHostCreds
|
||||||
|
@ -57,8 +57,8 @@ var subCmdHostsDelete = subCmd{
|
|||||||
|
|
||||||
flags := subCmdCtx.flagSet(false)
|
flags := subCmdCtx.flagSet(false)
|
||||||
|
|
||||||
name := flags.StringP(
|
hostName := flags.StringP(
|
||||||
"name", "n", "",
|
"hostname", "h", "",
|
||||||
"Name of the host to delete",
|
"Name of the host to delete",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ var subCmdHostsDelete = subCmd{
|
|||||||
return fmt.Errorf("parsing flags: %w", err)
|
return fmt.Errorf("parsing flags: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *name == "" {
|
if *hostName == "" {
|
||||||
return errors.New("--name is required")
|
return errors.New("--hostname is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostBootstrap, err := loadHostBootstrap()
|
hostBootstrap, err := loadHostBootstrap()
|
||||||
@ -77,7 +77,7 @@ var subCmdHostsDelete = subCmd{
|
|||||||
|
|
||||||
client := hostBootstrap.GlobalBucketS3APIClient()
|
client := hostBootstrap.GlobalBucketS3APIClient()
|
||||||
|
|
||||||
return bootstrap.RemoveGarageBootstrapHost(subCmdCtx.ctx, client, *name)
|
return bootstrap.RemoveGarageBootstrapHost(subCmdCtx.ctx, client, *hostName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user