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:
Kyle Carberry
2022-03-28 18:19:28 -06:00
committed by GitHub
parent 620c889842
commit 82dfd6c72f
26 changed files with 539 additions and 231 deletions

View File

@ -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())