diff --git a/docs/admin/adding-a-host-to-the-network.md b/docs/admin/adding-a-host-to-the-network.md index 94aca10..068b143 100644 --- a/docs/admin/adding-a-host-to-the-network.md +++ b/docs/admin/adding-a-host-to-the-network.md @@ -44,7 +44,7 @@ following command from their own host: ``` cryptic-net hosts make-bootstrap \ - --name \ + --hostname \ --ip \ --admin-path \ > bootstrap.yml @@ -67,7 +67,7 @@ generate a `bootstrap.yml`: ``` gpg -d | cryptic-net hosts make-boostrap \ - --name \ + --hostname \ --ip \ --admin-path - \ > bootstrap.yml diff --git a/docs/admin/creating-a-new-network.md b/docs/admin/creating-a-new-network.md index c6b9a88..fa513fd 100644 --- a/docs/admin/creating-a-new-network.md +++ b/docs/admin/creating-a-new-network.md @@ -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 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 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 @@ -102,9 +105,10 @@ you can run: ``` sudo cryptic-net admin create-network \ --config /path/to/daemon.yml \ + --name \ + --ip \ --domain \ - --ip \ - --name \ + --hostname \ | gpg -e -r \ > admin.yml.gpg ``` diff --git a/entrypoint/src/admin/admin.go b/entrypoint/src/admin/admin.go index a4a13c8..0868550 100644 --- a/entrypoint/src/admin/admin.go +++ b/entrypoint/src/admin/admin.go @@ -13,6 +13,7 @@ import ( // are available to all hosts within the network via their bootstrap files. type CreationParams struct { ID string `yaml:"id"` + Name string `yaml:"name"` Domain string `yaml:"domain"` } diff --git a/entrypoint/src/cmd/entrypoint/admin.go b/entrypoint/src/cmd/entrypoint/admin.go index 711b5d9..5218df9 100644 --- a/entrypoint/src/cmd/entrypoint/admin.go +++ b/entrypoint/src/cmd/entrypoint/admin.go @@ -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 diff --git a/entrypoint/src/cmd/entrypoint/hosts.go b/entrypoint/src/cmd/entrypoint/hosts.go index 184a9c4..b2f894e 100644 --- a/entrypoint/src/cmd/entrypoint/hosts.go +++ b/entrypoint/src/cmd/entrypoint/hosts.go @@ -57,8 +57,8 @@ var subCmdHostsDelete = subCmd{ flags := subCmdCtx.flagSet(false) - name := flags.StringP( - "name", "n", "", + hostName := flags.StringP( + "hostname", "h", "", "Name of the host to delete", ) @@ -66,8 +66,8 @@ var subCmdHostsDelete = subCmd{ return fmt.Errorf("parsing flags: %w", err) } - if *name == "" { - return errors.New("--name is required") + if *hostName == "" { + return errors.New("--hostname is required") } hostBootstrap, err := loadHostBootstrap() @@ -77,7 +77,7 @@ var subCmdHostsDelete = subCmd{ client := hostBootstrap.GlobalBucketS3APIClient() - return bootstrap.RemoveGarageBootstrapHost(subCmdCtx.ctx, client, *name) + return bootstrap.RemoveGarageBootstrapHost(subCmdCtx.ctx, client, *hostName) }, }