Conversation
2e168d2 to
8e9017a
Compare
ff4c79c to
22cdf83
Compare
Signed-off-by: NautiluX <2600004+NautiluX@users.noreply.github.com>
OliverTrautvetter
left a comment
There was a problem hiding this comment.
big pr, not sure if I catched everything in the first review 😄
| 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) { |
There was a problem hiding this comment.
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
| type ServerStatus struct { | ||
| Server string `json:"server"` | ||
| ReplicaCount int `json:"state"` | ||
| ReplicaRunning int `json:"replica"` | ||
| } |
There was a problem hiding this comment.
json looks wrong for count and running
| return fmt.Errorf("timeout waiting for workspace to be healthy at %s", url) | ||
| } | ||
|
|
||
| time.Sleep(delay) |
| return nil | ||
| } | ||
|
|
||
| if time.Now().After(maxWaitTime) { |
| 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) |
| 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)}) | ||
| } |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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. |
| 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") |
There was a problem hiding this comment.
why as a global flag, should we not use a local flag where we use it
| stat.ReplicaRunning++ | ||
| } | ||
| stat.ReplicaCount++ | ||
| continue |
There was a problem hiding this comment.
continue is useless as we are already at the bottom of the loop
No description provided.