Skip to content

Commit cb3f1a5

Browse files
committed
Allow a custom name, not just auto-generated
This affected @richardcase when a team-mate deleted his VM from a common company cloud account not knowing what it was for, or who it belonged to. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 4438625 commit cb3f1a5

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

cmd/create.go

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/spf13/cobra"
2020
)
2121

22-
const inletsProDefaultVersion = "0.9.25"
22+
const inletsProDefaultVersion = "0.9.28"
2323
const inletsProControlPort = 8123
2424

2525
func init() {
@@ -71,19 +71,25 @@ var createCmd = &cobra.Command{
7171
with inlets preloaded as a systemd service. The estimated cost of each
7272
VM along with what OS version and spec will be used is explained in the
7373
project docs.`,
74-
Example: ` # Create a TCP tunnel server
75-
inletsctl create \
76-
--provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \
77-
--access-token-file $HOME/access-token \
78-
--region lon1
79-
74+
Example: `
8075
# Create a HTTPS tunnel server, terminating TLS with a certificate
81-
# from Let's Encrypt
76+
# from Let's Encrypt called "tunnel-richardcase" so your team mates
77+
# don't delete your VM unintentionally.
8278
inletsctl create \
79+
tunnel-richardcase \
8380
--letsencrypt-domain inlets.example.com \
8481
--letsencrypt-email [email protected]
8582
86-
# Create a HTTPS tunnel server with multiple domains
83+
# Create a TCP tunnel server with a VM name of ssh-tunnel
84+
inletsctl create \
85+
ssh-tunnel \
86+
--tcp \
87+
--provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \
88+
--access-token-file $HOME/access-token \
89+
--region lon1
90+
91+
# Create a HTTPS tunnel server with multiple domains and an auto-generated
92+
# VM name
8793
inletsctl create \
8894
--letsencrypt-domain tunnel1.example.com \
8995
--letsencrypt-domain tunnel2.example.com \
@@ -99,6 +105,12 @@ const EquinixMetalProvider = "equinix-metal"
99105

100106
func runCreate(cmd *cobra.Command, _ []string) error {
101107

108+
// Get name from the Args, if not provided, generate a random name
109+
name := strings.Replace(names.GetRandomName(10), "_", "-", -1)
110+
if len(cmd.Flags().Args()) > 0 {
111+
name = cmd.Flags().Args()[0]
112+
}
113+
102114
inletsProVersion, err := cmd.Flags().GetString("inlets-version")
103115
if err != nil {
104116
return err
@@ -301,8 +313,6 @@ func runCreate(cmd *cobra.Command, _ []string) error {
301313
tcp = false
302314
}
303315

304-
name := strings.Replace(names.GetRandomName(10), "_", "-", -1)
305-
306316
var userData string
307317
if len(letsencryptDomains) > 0 {
308318
userData = MakeHTTPSUserdata(inletsToken,
@@ -341,9 +351,9 @@ func runCreate(cmd *cobra.Command, _ []string) error {
341351
}
342352

343353
if provider == "gce" {
344-
fmt.Printf("Requesting host: %s in %s, from %s\n", name, zone, provider)
354+
fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, zone, provider)
345355
} else {
346-
fmt.Printf("Requesting host: %s in %s, from %s\n", name, region, provider)
356+
fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, region, provider)
347357
}
348358

349359
hostRes, err := provisioner.Provision(*hostReq)

0 commit comments

Comments
 (0)