Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dist/
# binary
brev-cli
brev
brev.log

# golang executable
go1.*
Expand Down
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@
"--model",
"llama2",
],
},
{
"name": "create",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"args": [
"create",
"test-workspace",
],
}
]
}
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/brevdev/brev-cli

go 1.22.6
go 1.23.4

toolchain go1.24.2

require (
github.com/alessio/shellescape v1.4.1
Expand Down Expand Up @@ -108,6 +110,7 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/rmhubbert/bubbletea-overlay v0.3.2 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
Expand All @@ -121,6 +124,7 @@ require (
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/zhengkyl/pearls v0.1.1 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rmhubbert/bubbletea-overlay v0.3.2 h1:IvlwNFwcgx4gWQ1P8mXXZxFTzxbw1t6gAm/qvidCw7I=
github.com/rmhubbert/bubbletea-overlay v0.3.2/go.mod h1:eGY/M6yyUP6IRildHOhDMHBscFm816Im2oSB1nLZMoo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -521,6 +523,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zhengkyl/pearls v0.1.1 h1:eo4wNFK/ZhUfg9AgjRJ7aCqEdimDB26nJXWG8Y/OLuw=
github.com/zhengkyl/pearls v0.1.1/go.mod h1:ofzYZ2ahVGxLSldoRpgsetRURct7ZVQd+PyD61CoMSg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
17 changes: 17 additions & 0 deletions pkg/tui/drew/data_cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package drew

type Cloud int

const (
CloudCrusoe Cloud = iota
CloudLambda
)

var cloudName = map[Cloud]string{
CloudCrusoe: "Crusoe",
CloudLambda: "Lambda",
}

func (c Cloud) Name() string {
return cloudName[c]
}
70 changes: 70 additions & 0 deletions pkg/tui/drew/data_container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package drew

import (
"github.com/charmbracelet/bubbles/spinner"
lipgloss "github.com/charmbracelet/lipgloss"
)

type Container struct {
Name string
Image string
Status ContainerStatus
}

type ContainerStatus int

const (
ContainerStatusRunning ContainerStatus = iota
ContainerStatusError
ContainerStatusBuilding
ContainerStatusStarting
ContainerStatusStopping
ContainerStatusStopped
ContainerStatusDeleting
)

var containerStatuses = map[ContainerStatus]string{
ContainerStatusRunning: "Running",
ContainerStatusError: "Error",
ContainerStatusBuilding: "Building",
ContainerStatusStarting: "Starting",
ContainerStatusStopping: "Stopping",
ContainerStatusStopped: "Stopped",
ContainerStatusDeleting: "Deleting",
}

func (s ContainerStatus) Name() string {
return containerStatuses[s]
}

func (s ContainerStatus) IsTemporary() bool {
return s == ContainerStatusBuilding || s == ContainerStatusStarting || s == ContainerStatusStopping || s == ContainerStatusDeleting
}

func (s ContainerStatus) StatusView(spinner spinner.Model) string {
var styledName string

switch s {
case ContainerStatusRunning:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("118")).Render(s.Name())
case ContainerStatusError:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("196")).Render(s.Name())
case ContainerStatusBuilding:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("33")).Render(s.Name())
case ContainerStatusStarting:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("220")).Render(s.Name())
case ContainerStatusStopping:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Render(s.Name())
case ContainerStatusStopped:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("255")).Render(s.Name())
case ContainerStatusDeleting:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Render(s.Name())
default:
styledName = s.Name()
}

if s.IsTemporary() {
return styledName + " " + spinner.View()
}
return styledName
}
85 changes: 85 additions & 0 deletions pkg/tui/drew/data_environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package drew

import (
"github.com/charmbracelet/bubbles/spinner"
lipgloss "github.com/charmbracelet/lipgloss"
)

type Environment struct {
ID string
Name string
InstanceType InstanceType
Storage string
Status EnvironmentStatus
Containers []Container
PortMappings []PortMapping
Tunnels []Tunnel
}

type EnvironmentStatus int

const (
EnvironmentStatusRunning EnvironmentStatus = iota
EnvironmentStatusError
EnvironmentStatusBuilding
EnvironmentStatusStarting
EnvironmentStatusStopping
EnvironmentStatusStopped
EnvironmentStatusDeleting
)

var environmentStatusName = map[EnvironmentStatus]string{
EnvironmentStatusRunning: "Running",
EnvironmentStatusError: "Error",
EnvironmentStatusBuilding: "Building",
EnvironmentStatusStarting: "Starting",
EnvironmentStatusStopping: "Stopping",
EnvironmentStatusStopped: "Stopped",
EnvironmentStatusDeleting: "Deleting",
}

func (e EnvironmentStatus) Name() string {
return environmentStatusName[e]
}

func (e EnvironmentStatus) IsTemporary() bool {
return e == EnvironmentStatusBuilding || e == EnvironmentStatusStarting || e == EnvironmentStatusStopping || e == EnvironmentStatusDeleting
}

func (e EnvironmentStatus) StatusView(spinner spinner.Model) string {
var styledName string

switch e {
case EnvironmentStatusRunning:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("118")).Render(e.Name())
case EnvironmentStatusError:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("196")).Render(e.Name())
case EnvironmentStatusBuilding:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("33")).Render(e.Name())
case EnvironmentStatusStarting:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("220")).Render(e.Name())
case EnvironmentStatusStopping:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Render(e.Name())
case EnvironmentStatusStopped:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("255")).Render(e.Name())
case EnvironmentStatusDeleting:
styledName = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Render(e.Name())
default:
styledName = e.Name()
}

if e.IsTemporary() {
return styledName + " " + spinner.View()
}
return styledName
}

type PortMapping struct {
HostPort string
PublicPort string
}

type Tunnel struct {
HostPort string
PublicURL string
}
85 changes: 85 additions & 0 deletions pkg/tui/drew/data_instance_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package drew

type InstanceType struct {
Cloud Cloud
GPUModel string
GPUCount int
VRAM string
CPUModel string
CPUCount int
Memory string
Storage string
}

var (
Crusoe_1x_a100_40gb InstanceType = InstanceType{
Cloud: CloudCrusoe,
GPUModel: "NVIDIA A100",
GPUCount: 1,
VRAM: "40GB",
CPUModel: "Intel Xeon (Ice Lake)",
CPUCount: 12,
Memory: "120GB",
Storage: "1x960GB",
}
Crusoe_2x_a100_40gb InstanceType = InstanceType{
Cloud: CloudCrusoe,
GPUModel: "NVIDIA A100",
GPUCount: 2,
VRAM: "40GB",
CPUModel: "Intel Xeon (Ice Lake)",
CPUCount: 24,
Memory: "240GB",
Storage: "2x960GB",
}
Crusoe_4x_a100_40gb InstanceType = InstanceType{
Cloud: CloudCrusoe,
GPUModel: "NVIDIA A100",
GPUCount: 4,
VRAM: "40GB",
CPUModel: "Intel Xeon (Ice Lake)",
CPUCount: 48,
Memory: "480GB",
Storage: "4x960GB",
}
Crusoe_8x_a100_40gb InstanceType = InstanceType{
GPUModel: "NVIDIA A100",
GPUCount: 8,
VRAM: "40GB",
CPUModel: "Intel Xeon (Ice Lake)",
CPUCount: 96,
Memory: "960GB",
Storage: "8x960GB",
}

Lambda_1x_a100_40gb InstanceType = InstanceType{
Cloud: CloudLambda,
GPUModel: "NVIDIA A100",
GPUCount: 1,
VRAM: "40GB",
CPUModel: "Intel Xeon (Sapphire Rapids)",
CPUCount: 30,
Memory: "225GiB",
Storage: "512GiB",
}
Lambda_2x_a100_40gb InstanceType = InstanceType{
Cloud: CloudLambda,
GPUModel: "NVIDIA A100",
GPUCount: 2,
VRAM: "40GB",
CPUModel: "Intel Xeon (Sapphire Rapids)",
CPUCount: 60,
Memory: "450GiB",
Storage: "1TiB",
}
Lambda_4x_a100_40gb InstanceType = InstanceType{
Cloud: CloudLambda,
GPUModel: "NVIDIA A100",
GPUCount: 4,
VRAM: "40GB",
CPUModel: "Intel Xeon (Sapphire Rapids)",
CPUCount: 120,
Memory: "900GiB",
Storage: "1TiB",
}
)
3 changes: 3 additions & 0 deletions pkg/tui/drew/model_auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package drew


Loading