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

Some inconsistencies in enum argument descriptions #1597

Open
zikalino opened this issue Oct 19, 2024 · 1 comment
Open

Some inconsistencies in enum argument descriptions #1597

zikalino opened this issue Oct 19, 2024 · 1 comment
Labels

Comments

@zikalino
Copy link
Contributor

Describe the Issue:

I have done some more investigation related to this PR: #1595, and I found more related issues / inconsistencies.

For instance in doctl databases topics update:

 --cleanup-policy string              Specifies the retention policy to use on log segments: Possible values are 'delete', 'compact_delete', 'compact' (default "delete")
 --compression-type string            Specifies the compression type for a kafka topic: Possible values are 'producer', 'gzip', 'snappy', 'Iz4', 'zstd', 'uncompressed' (default "producer")

but in doctl databases create and most other places:

--engine pg                          The database's engine. Possible values are: pg, `mysql`, `redis`, `mongodb`, `kafka` and `opensearch`. (default "pg")

In the first example, apostrophes don't interfere with command argument type generation and it stays defined as string.
In the second example, backticks are causing to use first value (pg) as data type for argument, which can be confusing.

I would be happy to create PR to fix this, however, I am not sure whether there's any reason attached to using backticks versus apostrophes. I am also not sure why default value is in quotes.

One possible solution is to introduce enum data type, and then argument descriptions could look like this:

--engine enum                          The database's engine. Possible enum values are: `pg`, `mysql`, `redis`, `mongodb`, `kafka` and `opensearch`. (default "pg")
@zikalino zikalino added the bug label Oct 19, 2024
@andrewsomething
Copy link
Member

Thanks for looking into this @zikalino!

The one positive to the backticks is that they display as code in the online version of the documentation:

https://docs.digitalocean.com/reference/doctl/reference/databases/create/

I am also not sure why default value is in quotes.

This behavior comes from the Cobra library. For example, notice we specify a default but don't actually add that to the description. Cobra automatically appends the (default "pg"):

AddStringFlag(cmdDatabaseCreate, doctl.ArgDatabaseEngine, "", defaultDatabaseEngine, "The database's engine. Possible values are: `pg`, `mysql`, `redis`, `mongodb`, `kafka` and `opensearch`.")

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

No branches or pull requests

2 participants