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

feat(gitpod-cli): add tasks cmd #8890

Merged
merged 1 commit into from
Mar 21, 2022
Merged

feat(gitpod-cli): add tasks cmd #8890

merged 1 commit into from
Mar 21, 2022

Conversation

andreafalzetti
Copy link
Contributor

@andreafalzetti andreafalzetti commented Mar 18, 2022

Description

Adds a command with 2 sub-commands to gitpod-cli.

  • gp tasks list
  • gp tasks attach

Related Issue(s)

Fixes #7016

How to test

  1. Create a new workspace of gitpod-io/gitpod
  2. Go to ./components/gitpod-cli
  3. Run go get
  4. Run go build
  5. List the workspace tasks ./gitpod-cli tasks list
  6. Attach to another terminal ./gitpod-cli tasks attach (See the prompt)
  7. Try attaching to a specific task by specifing the terminal ID ./gitpod-cli tasks attach <terminalId>

Release Notes

Added a new root cmd to Gitpod CLI. The tasks cmd allows listing tasks and attaching to them.

Documentation

https://github.com/gitpod-io/website/issues/1791

Token string
}

func AttachToTerminal(ctx context.Context, client api.TerminalServiceClient, alias string, opts AttachToTerminalOpts) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same as

func attachToTerminal(ctx context.Context, client api.TerminalServiceClient, alias string, opts attachToTerminalOpts) {

We agreed with @akosyakov to duplicate the logic instead of trying to share it between the two CLIs.

Copy link
Contributor Author

@andreafalzetti andreafalzetti Mar 18, 2022

Choose a reason for hiding this comment

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

Also, this function comes with a problem - if a terminal attaches to itself, it will go into a loop. In tasks cmd, we try avoiding going into that situation but it's not easy to detect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, in the context of the running terminal, there could be an environment variable indicating it's a Task Terminal, so the attach command could check this env variable, and if detected someone trying run gp tasks attach on it, it would just print a message saying, for example: "It's not possible to attach to a task terminal from another task terminal. Please start a new terminal and run 'gp tasks attach' from there."

@andreafalzetti
Copy link
Contributor Author

andreafalzetti commented Mar 18, 2022

/werft run

👍 started the job as gitpod-build-af-feat-gp-cli-tasks-cmd.3

Copy link
Contributor

@felladrin felladrin left a comment

Choose a reason for hiding this comment

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

I've checked and tested it, and it looks great!

I think this could even be used in #8338

@roboquat roboquat merged commit e5ea511 into main Mar 21, 2022
@roboquat roboquat deleted the af/feat-gp-cli-tasks-cmd branch March 21, 2022 13:01
@roboquat roboquat added deployed: IDE IDE change is running in production deployed Change is completely running in production labels Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production deployed Change is completely running in production release-note size/XL team: IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gp cli] tasks support
3 participants