This repository was archived by the owner on Aug 30, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork18
Add environment status to "envs ls"#108
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
54 changes: 42 additions & 12 deletionscoder-sdk/env.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -11,18 +11,19 @@ import ( | ||
// Environment describes a Coder environment | ||
type Environment struct { | ||
ID string `json:"id" tab:"-"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. nit: It would be neat to align the tags. | ||
Name string `json:"name"` | ||
ImageID string `json:"image_id" tab:"-"` | ||
ImageTag string `json:"image_tag"` | ||
OrganizationID string `json:"organization_id" tab:"-"` | ||
UserID string `json:"user_id" tab:"-"` | ||
LastBuiltAt time.Time `json:"last_built_at" tab:"-"` | ||
CPUCores float32 `json:"cpu_cores"` | ||
MemoryGB int `json:"memory_gb"` | ||
DiskGB int `json:"disk_gb"` | ||
GPUs int `json:"gpus"` | ||
Updating bool `json:"updating"` | ||
LatestStat EnvironmentStat `json:"latest_stat" tab:"Status"` | ||
RebuildMessages []struct { | ||
Text string `json:"text"` | ||
Required bool `json:"required"` | ||
@@ -34,6 +35,35 @@ type Environment struct { | ||
AutoOffThreshold xjson.Duration `json:"auto_off_threshold" tab:"-"` | ||
} | ||
// EnvironmentStat represents the state of an environment | ||
type EnvironmentStat struct { | ||
Time time.Time `json:"time"` | ||
LastOnline time.Time `json:"last_online"` | ||
ContainerStatus EnvironmentStatus `json:"container_status"` | ||
StatError string `json:"stat_error"` | ||
CPUUsage float32 `json:"cpu_usage"` | ||
MemoryTotal int64 `json:"memory_total"` | ||
MemoryUsage float32 `json:"memory_usage"` | ||
DiskTotal int64 `json:"disk_total"` | ||
DiskUsed int64 `json:"disk_used"` | ||
} | ||
func (e EnvironmentStat) String() string { | ||
return string(e.ContainerStatus) | ||
} | ||
// EnvironmentStatus refers to the states of an environment. | ||
type EnvironmentStatus string | ||
// The following represent the possible environment container states | ||
const ( | ||
EnvironmentCreating EnvironmentStatus = "CREATING" | ||
EnvironmentOff EnvironmentStatus = "OFF" | ||
EnvironmentOn EnvironmentStatus = "ON" | ||
EnvironmentFailed EnvironmentStatus = "FAILED" | ||
EnvironmentUnknown EnvironmentStatus = "UNKNOWN" | ||
) | ||
// CreateEnvironmentRequest is used to configure a new environment | ||
type CreateEnvironmentRequest struct { | ||
Name string `json:"name"` | ||
12 changes: 10 additions & 2 deletionsinternal/x/xtabwriter/tabwriter.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.