Skip to content

feat(cli): Add ps and up#224

Open
NautiluX wants to merge 2 commits intomainfrom
cs-up
Open

feat(cli): Add ps and up#224
NautiluX wants to merge 2 commits intomainfrom
cs-up

Conversation

@NautiluX
Copy link
Copy Markdown
Member

No description provided.

@NautiluX NautiluX requested a review from a team as a code owner March 25, 2026 15:51
@NautiluX NautiluX marked this pull request as draft March 25, 2026 15:51
@NautiluX NautiluX force-pushed the cs-up branch 9 times, most recently from 2e168d2 to 8e9017a Compare March 30, 2026 14:28
@NautiluX NautiluX marked this pull request as ready for review March 30, 2026 14:29
@NautiluX NautiluX force-pushed the cs-up branch 2 times, most recently from ff4c79c to 22cdf83 Compare March 30, 2026 21:05
Signed-off-by: NautiluX <2600004+NautiluX@users.noreply.github.com>
Copy link
Copy Markdown
Member

@OliverTrautvetter OliverTrautvetter left a comment

Choose a reason for hiding this comment

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

big pr, not sure if I catched everything in the first review 😄

Comment on lines 40 to 56
func (e *Environment) GetWorkspaceId() (int, error) {
prefixedId, err := e.ReadNumericEnv("CS_WORKSPACE_ID")
if prefixedId != -1 && err == nil {
return prefixedId, nil
}

upState := &UpState{}
err = upState.Load(e.statefile, &api.RealTime{}, util.NewOSFileSystem("."))

if err == nil && upState.WorkspaceId > -1 {
return upState.WorkspaceId, nil
}

return e.ReadNumericEnv("WORKSPACE_ID")
}

func (e *Environment) GetTeamId() (int, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GetWorkspaceId checks CS_WORKSPACE_ID first and after that the state file
GetTeamId loads the state file first and falls back to CS_TEAM_ID

Should we not check the env first in both cases

Comment on lines +21 to +25
type ServerStatus struct {
Server string `json:"server"`
ReplicaCount int `json:"state"`
ReplicaRunning int `json:"replica"`
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

json looks wrong for count and running

return fmt.Errorf("timeout waiting for workspace to be healthy at %s", url)
}

time.Sleep(delay)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

client.time.Sleep()

return nil
}

if time.Now().After(maxWaitTime) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

client.time.Now()

func (c *RealClient) waitForWorkspaceHealthy(devDomain string, token string, timeout time.Duration) error {
url := fmt.Sprintf("https://%s", devDomain)
delay := 5 * time.Second
maxWaitTime := time.Now().Add(timeout)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

client.time.Now()

Comment on lines +60 to +64
t := io.GetTableWriter()
t.AppendHeader(table.Row{"Server", "Replica (running/desired)"})
for _, stat := range serverStatus {
t.AppendRow(table.Row{stat.Server, fmt.Sprintf("%d/%d", stat.ReplicaRunning, stat.ReplicaCount)})
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we not sort the keys of the map first to have the same order each run? I think maps have a random iteration order by default

}
}

func NewPipelineRunnerWidthCustomDeps(client api.Client, profile string, time api.Time, timeout time.Duration, verboseOutput bool) *PipelineRunner {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo "width" should be "with"

cmd: &cobra.Command{
Use: "up",
Short: "Deploy your local code to Codesphere",
Long: io.Long(`Deploys your local code to a new or existing Codepshere workspace.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo "Codepshere"

rootCmd.PersistentFlags().IntVarP(&opts.TeamId, "team", "t", -1, "Team ID (relevant for some commands, can also be CS_TEAM_ID)")
rootCmd.PersistentFlags().IntVarP(&opts.WorkspaceId, "workspace", "w", -1, "Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID)")
rootCmd.PersistentFlags().BoolVarP(&opts.Verbose, "verbose", "v", false, "Verbose output")
rootCmd.PersistentFlags().StringVarP(&opts.StateFile, "state-file", "", ".cs-up.yaml", "Path to the state file, defaults to .cs-up.yaml")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why as a global flag, should we not use a local flag where we use it

stat.ReplicaRunning++
}
stat.ReplicaCount++
continue
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

continue is useless as we are already at the bottom of the loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants