estela-cli: Add command to save different contexts#42
Open
raymond1242 wants to merge 3 commits intomasterfrom
Open
estela-cli: Add command to save different contexts#42raymond1242 wants to merge 3 commits intomasterfrom
raymond1242 wants to merge 3 commits intomasterfrom
Conversation
mgonnav
suggested changes
Sep 19, 2023
| from estela_cli.templates import ESTELA_AUTH_NAME, ESTELA_CONFIG_NAME, OK_EMOJI, BAD_EMOJI | ||
|
|
||
|
|
||
| SHORT_HELP = "Show your current context" |
Contributor
There was a problem hiding this comment.
We should update the description of the command here to also indicate that it serves to update/change the context
| get_estela_config_path, | ||
| ) | ||
| from estela_cli.templates import ESTELA_AUTH_NAME, OK_EMOJI, BAD_EMOJI | ||
| from estela_cli.templates import ESTELA_AUTH_NAME, ESTELA_CONFIG_NAME, OK_EMOJI, BAD_EMOJI |
Contributor
There was a problem hiding this comment.
Please apply black to format the code
| @click.command(name="context", short_help=SHORT_HELP) | ||
| def estela_command(): | ||
| @click.argument("name", required=False) | ||
| def estela_command(name): |
Contributor
There was a problem hiding this comment.
Please add context delete functionality.
| click.echo( | ||
| "Context {} not found.\nInitializing context...".format(name) | ||
| ) | ||
| estela_client = prompt_context(name, username, password, host) |
Contributor
There was a problem hiding this comment.
If I use incorrect credentials, I get this output:
Checking your current context for bad-local...
Context bad-prod not found.
Initializing context...
Host: https://127.0.0.1
Username: mgonnav
Password:
Successful login. Context bad-prod stored in ~/.estela-config.yaml.
Traceback (most recent call last):
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/estela-0.2.7-py3.9.egg/estela_cli/context.py", line 71, in prompt_context
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/estela-0.2.7-py3.9.egg/estela_cli/estela_client.py", line 23, in __init__
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/estela-0.2.7-py3.9.egg/estela_cli/estela_client.py", line 113, in check_status
Exception: ['Unable to log in with provided credentials.']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mgonnav/.pyenv/versions/estela-cli/bin/estela", line 33, in <module>
sys.exit(load_entry_point('estela==0.2.7', 'console_scripts', 'estela')())
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/estela-0.2.7-py3.9.egg/estela_cli/context.py", line 105, in estela_command
File "/home/mgonnav/.pyenv/versions/estela-cli/lib/python3.9/site-packages/estela-0.2.7-py3.9.egg/estela_cli/context.py", line 74, in prompt_context
Exception: Unable to login with provided credentials.
You can see "Successful login" and errors because I provided incorrect credentials. If the credentials are incorrect, the context should simply not be saved.
mgonnav
reviewed
Sep 19, 2023
| @click.command(name="context", short_help=SHORT_HELP) | ||
| def estela_command(): | ||
| @click.argument("name", required=False) | ||
| def estela_command(name): |
Contributor
There was a problem hiding this comment.
Please add a docstring explaining what we can do with the command. You can see other commands such as estela create job as an example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.