Skip to content

Commit

Permalink
Allow a custom name, not just auto-generated
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alexellis committed Feb 9, 2024
1 parent 4438625 commit 717daa2
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/spf13/cobra"
)

const inletsProDefaultVersion = "0.9.25"
const inletsProDefaultVersion = "0.9.28"
const inletsProControlPort = 8123

func init() {
Expand Down Expand Up @@ -71,19 +71,25 @@ var createCmd = &cobra.Command{
with inlets preloaded as a systemd service. The estimated cost of each
VM along with what OS version and spec will be used is explained in the
project docs.`,
Example: ` # Create a TCP tunnel server
inletsctl create \
--provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \
--access-token-file $HOME/access-token \
--region lon1
Example: `
# Create a HTTPS tunnel server, terminating TLS with a certificate
# from Let's Encrypt
# from Let's Encrypt called "tunnel-richardcase" so your team mates
# don't delete your VM unintentionally.
inletsctl create \
tunnel-richardcase \
--letsencrypt-domain inlets.example.com \
--letsencrypt-email [email protected]
# Create a HTTPS tunnel server with multiple domains
# Create a TCP tunnel server with a VM name of ssh-tunnel
inletsctl create \
ssh-tunnel \
--tcp \
--provider [digitalocean|equinix-metal|ec2|scaleway|civo|gce|azure|linode|hetzner] \
--access-token-file $HOME/access-token \
--region lon1
# Create a HTTPS tunnel server with multiple domains and an auto-generated
# VM name
inletsctl create \
--letsencrypt-domain tunnel1.example.com \
--letsencrypt-domain tunnel2.example.com \
Expand All @@ -99,6 +105,12 @@ const EquinixMetalProvider = "equinix-metal"

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

// Get name from the Args, if not provided, generate a random name
name := strings.Replace(names.GetRandomName(10), "_", "-", -1)
if len(cmd.Flags().Args()) > 0 {
name = cmd.Flags().Args()[0]
}

inletsProVersion, err := cmd.Flags().GetString("inlets-version")
if err != nil {
return err
Expand Down Expand Up @@ -301,8 +313,6 @@ func runCreate(cmd *cobra.Command, _ []string) error {
tcp = false
}

name := strings.Replace(names.GetRandomName(10), "_", "-", -1)

var userData string
if len(letsencryptDomains) > 0 {
userData = MakeHTTPSUserdata(inletsToken,
Expand Down Expand Up @@ -341,9 +351,9 @@ func runCreate(cmd *cobra.Command, _ []string) error {
}

if provider == "gce" {
fmt.Printf("Requesting host: %s in %s, from %s\n", name, zone, provider)
fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, zone, provider)
} else {
fmt.Printf("Requesting host: %s in %s, from %s\n", name, region, provider)
fmt.Printf("Provisioning exit-server: %s in %s [%s]\n", name, region, provider)
}

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

0 comments on commit 717daa2

Please sign in to comment.