Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI argument parsing is broken #51

Open
jkodroff opened this issue Jan 5, 2023 · 2 comments
Open

CLI argument parsing is broken #51

jkodroff opened this issue Jan 5, 2023 · 2 comments

Comments

@jkodroff
Copy link
Contributor

jkodroff commented Jan 5, 2023

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
Copy link
Owner

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

  • If you set the values as configuration in ~/.connecti.yaml it works great
  • If you set the values as env vars, it works great
  • if you remove the call to viper.GetString things appear to be better

@jaxxstorm
Copy link
Owner

I've opened spf13/cobra#1890 to see if I can get some insight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants