Skip to content

chore: Add listing proxies to cli 'coder proxy ls' #7376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 3, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Ignore errors
  • Loading branch information
Emyrk committed May 2, 2023
commit 7b6c4648d5b5980092fa10e67206cc0c5c8c6e30
46 changes: 22 additions & 24 deletions enterprise/cli/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,30 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
}

func (r *RootCmd) listProxies() *clibase.Cmd {
var (
formatter = cliui.NewOutputFormatter(
cliui.TableFormat([]codersdk.WorkspaceProxy{}, []string{"name", "url", "status status"}),
cliui.JSONFormat(),
cliui.ChangeFormatterData(cliui.TextFormat(), func(data any) (any, error) {
resp, ok := data.([]codersdk.WorkspaceProxy)
if !ok {
return nil, xerrors.Errorf("unexpected type %T", data)
formatter := cliui.NewOutputFormatter(
cliui.TableFormat([]codersdk.WorkspaceProxy{}, []string{"name", "url", "status status"}),
cliui.JSONFormat(),
cliui.ChangeFormatterData(cliui.TextFormat(), func(data any) (any, error) {
resp, ok := data.([]codersdk.WorkspaceProxy)
if !ok {
return nil, xerrors.Errorf("unexpected type %T", data)
}
var str strings.Builder
_, _ = str.WriteString("Workspace Proxies:\n")
sep := ""
for i, proxy := range resp {
_, _ = str.WriteString(sep)
_, _ = str.WriteString(fmt.Sprintf("%d: %s %s %s", i, proxy.Name, proxy.URL, proxy.Status.Status))
for _, errMsg := range proxy.Status.Report.Errors {
_, _ = str.WriteString(color.RedString("\n\tErr: %s", errMsg))
}
var str strings.Builder
str.WriteString("Workspace Proxies:\n")
sep := ""
for i, proxy := range resp {
str.WriteString(sep)
str.WriteString(fmt.Sprintf("%d: %s %s %s", i, proxy.Name, proxy.URL, proxy.Status.Status))
for _, errMsg := range proxy.Status.Report.Errors {
str.WriteString(color.RedString("\n\tErr: %s", errMsg))
}
for _, warnMsg := range proxy.Status.Report.Errors {
str.WriteString(color.YellowString("\n\tWarn: %s", warnMsg))
}
sep = "\n"
for _, warnMsg := range proxy.Status.Report.Errors {
_, _ = str.WriteString(color.YellowString("\n\tWarn: %s", warnMsg))
}
return str.String(), nil
}),
)
sep = "\n"
}
return str.String(), nil
}),
)

client := new(codersdk.Client)
Expand Down