jaxxstorm / connecti

A command line tool to quickly create a connection to cloud infrastructure
MIT License
48 stars 1 forks source link

CLI argument parsing is broken #51

Open jkodroff opened 1 year ago

jkodroff commented 1 year ago

When I run the following command:

go run cmd/connecti/main.go connect aws \
  --routes "10.0.0.0/16" \
  --region us-east-1 \
  --name "my-tailscale-bastion" \
  --subnet-ids subnet-08b322f0fec647539 \
  --api-key "abc123" \
  --tailnet "jkodroff@gmail.com"

Connecti fails:

Attempted action:

  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   0%
  Time elapsed: 0s

  Error:
    must specify a tailnet. See --help

If I dump the parsed arguments from Viper, I get the following:

viper.AllKeys = [virtualnetworkname subnetids debug aws:region routes apikey subnetname name tailnet azure:location resourcegroupname]
viper.AllSettings = map[apikey: aws:region:us-east-1 azure:location: debug:false name: resourcegroupname: routes:[] subnetids:[subnet-08b322f0fec647539] subnetname: tailnet: virtualnetworkname:]

Note that routes, apikey, routes, and tailnet are all blank despite being specified in the command.

If I specify TAILSCALE_TAILNET and TAILSCALE_API_KEY, the command will succeed, although routes still shows as blank.

jaxxstorm commented 1 year ago

This appears to be a bug with cobra at this point, but I can't determine why these values are not being set.

jaxxstorm commented 1 year ago

I've opened https://github.com/spf13/cobra/issues/1890 to see if I can get some insight