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

FR: rlock command line improvements #19

Open
pgagne opened this issue Aug 7, 2022 · 0 comments
Open

FR: rlock command line improvements #19

pgagne opened this issue Aug 7, 2022 · 0 comments

Comments

@pgagne
Copy link

pgagne commented Aug 7, 2022

I wanted to file this Feature Request to discuss some improvements that I think could be make to rlock

I can probably do help with this time permiting, or help with it. But if anyone else wants to take it on feel free to contribute.

Currently if one wants to lock a resource, they must type this very long and complicated command:

rlock --lock --server-url=<http url> --token=<long api token> --search-string=aws-resource-1 --priority=1 --signoff=pgagnesign1  --interval=100 --attempts=100

Despite being --options some of these items are required, although not for all operations

This is fine if your looking a resource in something like a jenkins pipeline but can be a bit unweildy when trying to do it from your workstation or in a personal script.

Here are some things I think we should consider fixing, in rough order of importance. There are probably others I'm forgetting, and will probably come across more as LNST works with ResourceLocker more, if others have additional suggestions please comment.

1. Better handling and checking of args.

See #18 . This could probably using something like urllib.parse.urljoin when working with urls.

2. Separate sub-commands

Currently the core functions of locking, checking and releasing are done via options like --lock --check and --release these would probably be better implemented as argparse subcommands: rlock lock , rlock check , rlock release.

This would also allow better handling of required values and would allow them to not have be specified as --options which goes against standard practice and argparse recommandions

For example the above command would look something like (assuming 3 is also implemented)

rlock lock <search string> <signoff> 
rlock lock aws-resource-1 pgagnesign1

We would probably have to think about how to handling existing scripts for this. If those aren't easily updated I purpose we create a new executable called something like rlock2 with the new argument form. Although we might be able to do it in such a way where both subcommands and --lock style operations are supported (with proper deprecation warnings) for a while.

3. Configuration files for common arguments.

We should consider allowing for a simple config file (ie ~/.rlock.conf, ~/.config/rlock.conf or $PWD/rlock.conf to allow someone to specify options like server_url , and perhaps defaults for things like attempts and interval. Specifying options on the command line would take priority over config.

This config file could also potentially be used by rlockerservices

If someone is knowledgeable about an easy way of saving/retrieving secrets like token this from a system keystore please let me know.

@pgagne pgagne changed the title FR: Fix rlock command line args, make less required. FR: rlock command line improvements Aug 7, 2022
pgagne added a commit to pgagne/rlockertools that referenced this issue Aug 8, 2022
Part of red-hat-storage#19

made use of [argparse.subparser](https://docs.python.org/3/library/argparse.html#sub-commands) to implement subcommands. ie:

`rlock lock [args]` instead of `rlock --lock --arg1 --arg2`

Arguments that are required by certain things (signoff, search string, etc) are now positional args
This makes it easy to determine if they've been specified and error out if not. Eliminating common
user issues. Server args `--server-url` form, but that should change if we start using a config file or something.

Added defaults for `--interval` and `--attempts` based on the ones in `ResourceLocker` class

Added short form for most common params (`-s`, `-t`, etc)
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

1 participant