Skip to content

Commit

Permalink
fix: minor fix for workspace creation logging (#291)
Browse files Browse the repository at this point in the history
Signed-off-by: Toma Puljak <toma.puljak@hotmail.com>
  • Loading branch information
Tpuljak authored Mar 26, 2024
1 parent 1def298 commit 07454e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions pkg/cmd/workspace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"net/url"
"os"
"strings"
"time"

tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -132,14 +133,14 @@ var CreateCmd = &cobra.Command{
cleanUpTerminal(statusProgram, apiclient.HandleErrorResponse(res, err))
}

started = true

dialStartTime := time.Now()
dialTimeout := 3 * time.Minute
statusProgram.Send(status.ResultMsg{Line: "Establishing connection with the workspace"})

waitForDial(tsConn, *createdWorkspace.Id, *createdWorkspace.Projects[0].Name, dialStartTime, dialTimeout, statusProgram)

started = true

cleanUpTerminal(statusProgram, nil)

wsInfo, res, err := apiClient.WorkspaceAPI.GetWorkspace(ctx, workspaceName).Execute()
Expand Down Expand Up @@ -321,7 +322,10 @@ func scanWorkspaceLogs(activeProfile config.Profile, workspaceName string, statu
return
}

statusProgram.Send(status.ResultMsg{Line: string(msg)})
messages := strings.Split(string(msg), "\r")
for _, msg := range messages {
statusProgram.Send(status.ResultMsg{Line: msg})
}
if *started {
statusProgram.Send(status.ResultMsg{Line: "END_SIGNAL"})
break
Expand Down
3 changes: 1 addition & 2 deletions pkg/views/workspace/status/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package status

import (
"fmt"
"strings"

"github.com/charmbracelet/bubbles/spinner"
Expand All @@ -31,7 +30,7 @@ func (r ResultMsg) String() string {
if r.Dots {
return dotStyle.Render(strings.Repeat(".", 30))
}
return fmt.Sprintf(r.Line)
return r.Line
}

type model struct {
Expand Down

0 comments on commit 07454e0

Please sign in to comment.