Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/cmd/stop/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func stopAllWorkspaces(t *terminal.Terminal, stopStore StopStore, piped bool) er
var stoppedNames []string
for _, v := range workspaces {
if v.Status == entity.Running {
if err := validateWorkspaceStoppable(&v); err != nil {
if !piped {
t.Vprintf("%s", t.Yellow("\n%s skipped (does not support stop)", v.Name))
}
continue
}
_, err = stopStore.StopWorkspace(v.ID)
if err != nil {
return breverrors.WrapAndTrace(err)
Expand Down Expand Up @@ -168,6 +174,9 @@ func stopWorkspace(workspaceName string, t *terminal.Terminal, stopStore StopSto
}
}
}
if err = validateWorkspaceStoppable(workspace); err != nil {
return err
}
workspaceID = workspace.ID
}

Expand All @@ -186,3 +195,12 @@ func stopWorkspace(workspaceName string, t *terminal.Terminal, stopStore StopSto

return nil
}

func validateWorkspaceStoppable(workspace *entity.Workspace) error {
if workspace.InstanceTypeInfo != nil && workspace.InstanceTypeInfo.Stoppable {
return nil
}
return breverrors.NewValidationError(fmt.Sprintf(
"instance %q does not support stop.",
workspace.Name))
}
5 changes: 5 additions & 0 deletions pkg/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ type WorkspaceGroup struct {
TenantType string `json:"tenantType"`
} // @Name WorkspaceGroup

type InstanceTypeInfo struct {
Stoppable bool `json:"stoppable"`
}

type Workspace struct {
ID string `json:"id"`
Name string `json:"name"`
Expand All @@ -287,6 +291,7 @@ type Workspace struct {
WorkspaceClassID string `json:"workspaceClassId"` // WorkspaceClassID is resources, like "2x8"
InstanceType string `json:"instanceType,omitempty"`
CreatedByUserID string `json:"createdByUserId"`
InstanceTypeInfo *InstanceTypeInfo `json:"instanceTypeInfo,omitempty"`
DNS string `json:"dns"`
Status string `json:"status"`
Password string `json:"password"`
Expand Down
Loading