-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add wake-up command and curl workspace #152
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
…oud/cs-go into wake_up_workspaces
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
…ce URL construction
…oud/cs-go into wake_up_workspaces
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds CLI support for waking up on-demand workspaces and sending authenticated HTTP requests to a workspace’s dev domain, plus corresponding client APIs, tests, and documentation updates.
Changes:
- Introduces a
cs wake-upcommand with API support (ScaleWorkspace) and both unit and integration tests to start an on-demand workspace by scaling replicas and waiting until it is running. - Adds a
cs curlcommand that constructs an authenticated URL to a workspace’s dev domain and shells out tocurl, including comprehensive unit and integration tests and new documentation. - Updates client interfaces, mocks, and workflows (integration test cleanup and docs) to support the new commands and to slightly improve workspace readiness polling behavior.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
int/util/workspace.go |
Adds a helper to call the new ScaleWorkspace API from integration utilities. |
int/integration_test.go |
Adds integration suites for wake-up and curl commands, and extends generic error-handling coverage to the new commands. |
docs/cs_wake-up.md |
Documents the new cs wake-up command, including usage, examples, and options. |
docs/cs_list_workspaces.md |
Corrects the list-workspaces example to use the -t flag, aligning docs with the CLI. |
docs/cs_curl.md |
Documents the new cs curl command, including path and curl-arg syntax, examples, and options. |
docs/cs.md |
Adds links for the new curl and wake-up subcommands in the main cs docs index. |
docs/README.md |
Mirrors the cs.md updates for the CLI command index in the docs README. |
cli/cmd/wakeup_test.go |
Introduces unit tests for the WakeUpCmd.WakeUpWorkspace logic, covering normal, already-running, and error cases. |
cli/cmd/wakeup.go |
Implements the cs wake-up command, wiring it into the root command and using the API client to scale and wait for workspace readiness. |
cli/cmd/root.go |
Registers the new wake-up and curl subcommands with the root CLI. |
cli/cmd/mocks.go |
Extends the CLI MockClient with ScaleWorkspace, WaitForWorkspaceRunning, and WorkspaceStatus methods to support new command tests. |
cli/cmd/list_workspaces.go |
Updates the example string to use -t <team-id> for listing workspaces. |
cli/cmd/curl_test.go |
Adds unit tests for CurlCmd.CurlWorkspace, covering URL construction, dev-domain absence, and workspace lookup errors. |
cli/cmd/curl.go |
Implements the cs curl command, building an authenticated URL from the workspace dev domain and delegating the HTTP request to curl. |
cli/cmd/client.go |
Extends the Client interface and NewClient to expose WorkspaceStatus, WaitForWorkspaceRunning, and ScaleWorkspace to CLI commands. |
api/workspace.go |
Adds the ScaleWorkspace API wrapper and adjusts WaitForWorkspaceRunning to retry on transient errors until timeout. |
api/openapi_client/mocks.go |
Regenerates/updates openapi client mocks with simpler type assertions in Run helpers. |
.mockery.yml |
Adjusts mockery configuration for the openapi client package (removing include-auto-generated). |
.github/workflows/integration-test.yml |
Extends orphaned workspace cleanup to include the new cli-wakeup-test-* and cli-curl-test-* workspace name prefixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…oud/cs-go into wake_up_workspaces
Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
siherrmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, please revisit.
| curl.Port = curl.cmd.Flags().IntP("port", "p", 3000, "Port to connect to") | ||
| curl.Timeout = curl.cmd.Flags().DurationP("timeout", "", 30*time.Second, "Timeout for the request") | ||
| curl.cmd.Flags().BoolVar(&curl.Insecure, "insecure", false, "skip TLS certificate verification (for testing only)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our nornal way is the last (so curl.cmd.Flags().BoolVar). Please update the other flags to the same structure (IntVar and DurationVar)
| port := 3000 | ||
| if c.Port != nil { | ||
| port = *c.Port | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be done purely with a flag that has a default, would be cleaner.
| url = fmt.Sprintf("https://%s%s", devDomain, path) | ||
| } | ||
|
|
||
| fmt.Fprintf(os.Stderr, "Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use log.Printf()?
|
|
||
| fmt.Fprintf(os.Stderr, "Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) | ||
|
|
||
| timeout := 30 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again we could use a flag with a default, we should never have nil then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, they even have the default already, I think you could remove the nil check then.
| cmdArgs := []string{"curl"} | ||
|
|
||
| // Add authentication header | ||
| cmdArgs = append(cmdArgs, "-H", fmt.Sprintf("x-forward-security: %s", token)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fair to just do:
cmdArgs := []string{"curl", "-H", fmt.Sprintf("x-forward-security: %s", token)}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even:
cmdArgs := []string{"curl", "-H", fmt.Sprintf("x-forward-security: %s", token), curlArgs...}
Then you can remove the // Add user's curl arguments
| if err != nil { | ||
| if ctx.Err() == context.DeadlineExceeded { | ||
| return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) | ||
| } | ||
| return fmt.Errorf("curl command failed: %w", err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but wouldn't be the err itself be context.DeadlineExceeded?
If so we could do:
if err != nil && err == context.DeadlineExceeded {
...
} else if err != nil {
...
}Would be a little bit cleaner I think (but please verify, I'm not sure, error could be wrapped)
| timeout := 120 * time.Second | ||
| if c.Timeout != nil { | ||
| timeout = *c.Timeout | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, if default in flag is set this value should never be nil as far as I know.
Adds the ability to wake up a workspace using the CLI.
Clickup
Adds the ability to send HTTP requests to my workspace's dev domain, so that I can test connectivity.
Clickup