Skip to content

Commit c1e1cc6

Browse files
authored
Add proxy health check to CLI (#23)
Add Status and Last Checked columns to `kernel proxies list` <img width="2770" height="390" alt="image" src="https://github.com/user-attachments/assets/4beb8e5e-368c-450f-9357-4bae01f50373" />
1 parent dd88c41 commit c1e1cc6

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3737

3838
# Finder (MacOS) folder config
3939
.DS_Store
40+
kernel

cmd/proxies/list.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (p ProxyCmd) List(ctx context.Context) error {
2626

2727
// Prepare table data
2828
tableData := pterm.TableData{
29-
{"ID", "Name", "Type", "Config"},
29+
{"ID", "Name", "Type", "Config", "Status", "Last Checked"},
3030
}
3131

3232
for _, proxy := range *items {
@@ -38,11 +38,26 @@ func (p ProxyCmd) List(ctx context.Context) error {
3838
// Format config based on type
3939
configStr := formatProxyConfig(&proxy)
4040

41+
// Format status with color
42+
status := string(proxy.Status)
43+
if status == "" {
44+
status = "-"
45+
} else if status == "available" {
46+
status = pterm.Green(status)
47+
} else if status == "unavailable" {
48+
status = pterm.Red(status)
49+
}
50+
51+
// Format last checked timestamp
52+
lastChecked := util.FormatLocal(proxy.LastChecked)
53+
4154
tableData = append(tableData, []string{
4255
proxy.ID,
4356
name,
4457
string(proxy.Type),
4558
configStr,
59+
status,
60+
lastChecked,
4661
})
4762
}
4863

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/charmbracelet/fang v0.2.0
99
github.com/golang-jwt/jwt/v5 v5.2.2
1010
github.com/joho/godotenv v1.5.1
11-
github.com/onkernel/kernel-go-sdk v0.11.5
11+
github.com/onkernel/kernel-go-sdk v0.13.0
1212
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1313
github.com/pterm/pterm v0.12.80
1414
github.com/samber/lo v1.51.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe
9191
github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
9292
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
9393
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
94-
github.com/onkernel/kernel-go-sdk v0.11.5 h1:LApX5A/Ful62LwNTW+srhi/3cx3W04pzgZ361PlDEAc=
95-
github.com/onkernel/kernel-go-sdk v0.11.5/go.mod h1:MjUR92i8UPqjrmneyVykae6GuB3GGSmnQtnjf1v74Dc=
94+
github.com/onkernel/kernel-go-sdk v0.13.0 h1:yxXE8I7Blze7d5oyeyvKWna088o1mFPIAyK+rjmhw3g=
95+
github.com/onkernel/kernel-go-sdk v0.13.0/go.mod h1:MjUR92i8UPqjrmneyVykae6GuB3GGSmnQtnjf1v74Dc=
9696
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
9797
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
9898
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

0 commit comments

Comments
 (0)