mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat: Add UI for awaiting agent connections (#578)
* feat: Add stage to build logs This adds a stage property to logs, and refactors the job logs cliui. It also adds tests to the cliui for build logs! * feat: Add stage to build logs This adds a stage property to logs, and refactors the job logs cliui. It also adds tests to the cliui for build logs! * feat: Add config-ssh and tests for resiliency * Rename "Echo" test to "ImmediateExit" * Fix Terraform resource agent association * Fix logs post-cancel * Fix select on Windows * Remove terraform init logs * Move timer into it's own loop * Fix race condition in provisioner jobs * Fix requested changes
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@ -62,10 +63,11 @@ func main() {
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "select",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
_, err := cliui.Select(cmd, cliui.SelectOptions{
|
||||
value, err := cliui.Select(cmd, cliui.SelectOptions{
|
||||
Options: []string{"Tomato", "Banana", "Onion", "Grape", "Lemon"},
|
||||
Size: 3,
|
||||
})
|
||||
fmt.Printf("Selected: %q\n", value)
|
||||
return err
|
||||
},
|
||||
})
|
||||
@ -156,6 +158,35 @@ func main() {
|
||||
},
|
||||
})
|
||||
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "agent",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
resource := codersdk.WorkspaceResource{
|
||||
Type: "google_compute_instance",
|
||||
Name: "dev",
|
||||
Agent: &codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentDisconnected,
|
||||
},
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(3 * time.Second)
|
||||
resource.Agent.Status = codersdk.WorkspaceAgentConnected
|
||||
}()
|
||||
err := cliui.Agent(cmd, cliui.AgentOptions{
|
||||
WorkspaceName: "dev",
|
||||
Fetch: func(ctx context.Context) (codersdk.WorkspaceResource, error) {
|
||||
return resource, nil
|
||||
},
|
||||
WarnInterval: 2 * time.Second,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Completed!\n")
|
||||
return nil
|
||||
},
|
||||
})
|
||||
|
||||
err := root.Execute()
|
||||
if err != nil {
|
||||
_, _ = fmt.Println(err.Error())
|
||||
|
Reference in New Issue
Block a user