vultr/vultr-cli

[BUG] - Using "--notify false" still notify me by email

yarikdevcom opened this issue ยท 8 comments

Describe the bug
Email notification is not disabled by flag "--notify false"

To Reproduce
vultr-cli instance create --os 477 --plan vhf-1c-1gb --region cdg --label dev-db-redis-1 --host dev-db-redis-1 --private-network true --notify false --ssh-keys *** --auto-backup false

Expected behavior
No email about server creation

Desktop (please complete the following information where applicable:

  • OS: macos
  • Language Version go1.16.6 darwin/amd64

@mortyspace You need to wrap the bool in quotes --notify="false" or --notify=false

Maybe add this to README? because this is not obvious at all. In examples there are only --param value version

for --private-network it worked just --private-network true

@mortyspace I'll look into this for you.

We'll also update the readme

@mortyspace This boolean behavior is due to the way cobra, the cli framework, handles booleans.

If you run the command --notify false it doesn't assign the false value it just assumes a true.

I added in some printlns

fmt.Println(opt.ActivationEmail)
fmt.Println(*opt.ActivationEmail)
fmt.Println(notify)
os.Exit(1)

Here is the output

โ˜  vultr-cli [master] โšก  go run main.go instance create --plan vc2-1vcpu-1gb --region ewr --os 477 --notify false
0xc0000b361c
true
true
exit status 1
โ˜  vultr-cli [master] โšก  go run main.go instance create --plan vc2-1vcpu-1gb --region ewr --os 477 --notify=false
0xc0000b361a
false
false
exit status 1
โ˜  vultr-cli [master] โšก  go run main.go instance create --plan vc2-1vcpu-1gb --region ewr --os 477 --notify      
0xc00002b70c
true
true
exit status 1

This is why private network worked. It's default state is false so when you do --private-network it assumes true which is what you want.

We'll update the README to make it clear that with booleans its recommend to =.

What I'll do is set the default value for notify to be false so you won't have to use the flag only if you want to be notified. This will make it fall more in line with the other booleans which all default to false

thank you!

@mortyspace No problem (accidentally hit the confused emoji sorry!!)

No problem, thanks for fast response!)