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

estela-cli: Add command to save different contexts #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

raymond1242
Copy link
Contributor

No description provided.

@raymond1242 raymond1242 added the enhancement New feature or request label Sep 4, 2023
@raymond1242 raymond1242 requested a review from mgonnav September 4, 2023 16:33
@raymond1242 raymond1242 self-assigned this Sep 4, 2023
@raymond1242 raymond1242 marked this pull request as ready for review September 4, 2023 21:38
)
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


SHORT_HELP = "Show your current context"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update the description of the command here to also indicate that it serves to update/change the context

)
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add context delete functionality.

click.echo(
"Context {} not found.\nInitializing context...".format(name)
)
estela_client = prompt_context(name, username, password, host)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@click.command(name="context", short_help=SHORT_HELP)
def estela_command():
@click.argument("name", required=False)
def estela_command(name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Successfully merging this pull request may close these issues.

2 participants