vultr / vultr-cli

Official command line tool for Vultr services
Apache License 2.0
469 stars 75 forks source link

[BUG] - Error when creating DNS record CAA #439

Closed michelgirault closed 3 months ago

michelgirault commented 3 months ago

Describe the bug when trying to create a DNS record with the vultr-CLI command: vultr-cli dns record create "domain" --name @ --type CAA --ttl 3600 --priority 0 --data 0 issuewild "letsencrypt.org."

Error message: Error: error creating domain record : {"error":"Unable to add record: Data must be in the format: [flag] [iodef|issuewild|issue] \"domain\"","status":400}

alternatively It works on the web console with the same data entry: 0 issuewild "letsencrypt.org."

To Reproduce Steps to reproduce the behavior:

  1. open prompt
  2. type the command above including domain
  3. See error

Expected behavior to be able to create the dns record and see the results in the prompt and in the online console

optik-aper commented 3 months ago

@michelgirault due to the way cobra parses command line flags, the data for the example command you provided would strip everything after the first space, leaving only 0. If you pass it but enclose the data in quotes, it works:

vultr-cli dns record create <domain> --name @ --type CAA --ttl 3600 --priority 0 --data='0 issuewild "letsencrypt.org."'                                                                 
ID                                      TYPE    NAME    DATA                            PRIORITY        TTL
d32f370a-1a3c-435c-af9e-67ee8fac3a88    CAA             0 issuewild "letsencrypt.org."  0               3600
michelgirault commented 3 months ago

@michelgirault due to the way cobra parses command line flags, the data for the example command you provided would strip everything after the first space, leaving only 0. If you pass it but enclose the data in quotes, it works:

vultr-cli dns record create <domain> --name @ --type CAA --ttl 3600 --priority 0 --data='0 issuewild "letsencrypt.org."'                                                                 
ID                                      TYPE    NAME    DATA                            PRIORITY        TTL
d32f370a-1a3c-435c-af9e-67ee8fac3a88    CAA             0 issuewild "letsencrypt.org."  0               3600

Thanks a lot, thats correct its works for me