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

Print warning to stdout #6233

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

stephenmsachs
Copy link
Contributor

Description of changes

  • This enables the use of pcluster dcv-connect -n <cluster> | pbcopy to copy the url directly into macOS paste buffer.

This enables the use of `pcluster dcv-connect -n <cluster> | pbcopy` to copy the url directly into macOS paste buffer.
@stephenmsachs stephenmsachs requested review from a team as code owners May 2, 2024 07:26
@@ -64,10 +64,11 @@ def _dcv_connect(args):

try:
url = _retry(_retrieve_dcv_session_url, func_args=[cmd, args.cluster_name, head_node_ip], attempts=4)
url_message = f"Please use the following one-time URL in your browser within 30 seconds:\n{url}"
url_message = f"Please use the following one-time URL in your browser within 30 seconds:"
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a test that should be changed accordingly:

assert_that(result.stdout).matches(
r"Please use the following one-time URL in your browser within 30 seconds:\n"
r"https:\/\/(\b(?:\d{1,3}\.){3}\d{1,3}\b):" + str(dcv_port) + r"\?authToken=(.*)"
)

@@ -64,10 +64,11 @@ def _dcv_connect(args):

try:
url = _retry(_retrieve_dcv_session_url, func_args=[cmd, args.cluster_name, head_node_ip], attempts=4)
url_message = f"Please use the following one-time URL in your browser within 30 seconds:\n{url}"
url_message = f"Please use the following one-time URL in your browser within 30 seconds:"
Copy link
Contributor

Choose a reason for hiding this comment

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

With this change we are removing an explicative message from stdout to make it easier to consume the url.
What if this command returns a JSON, such as:

{
    "message": "Please use the following one-time URL in your browser within 30 seconds",
    "url": "https://...."
}

This would be consistent with the other pcluster commands returning JSON and would make possible to consume the url easily with jq or, even better, with the --query option of the pcluster CLI.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. Please feel free to change it.

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

Successfully merging this pull request may close these issues.

2 participants