mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli): support bundle: show links to docs/admin/healthcheck (#12974)
This commit is contained in:
@@ -120,14 +120,14 @@ type HealthcheckReport struct {
|
||||
}
|
||||
|
||||
// Summarize returns a summary of all errors and warnings of components of HealthcheckReport.
|
||||
func (r *HealthcheckReport) Summarize() []string {
|
||||
func (r *HealthcheckReport) Summarize(docsURL string) []string {
|
||||
var msgs []string
|
||||
msgs = append(msgs, r.AccessURL.Summarize("Access URL:")...)
|
||||
msgs = append(msgs, r.Database.Summarize("Database:")...)
|
||||
msgs = append(msgs, r.DERP.Summarize("DERP:")...)
|
||||
msgs = append(msgs, r.ProvisionerDaemons.Summarize("Provisioner Daemons:")...)
|
||||
msgs = append(msgs, r.Websocket.Summarize("Websocket:")...)
|
||||
msgs = append(msgs, r.WorkspaceProxy.Summarize("Workspace Proxies:")...)
|
||||
msgs = append(msgs, r.AccessURL.Summarize("Access URL:", docsURL)...)
|
||||
msgs = append(msgs, r.Database.Summarize("Database:", docsURL)...)
|
||||
msgs = append(msgs, r.DERP.Summarize("DERP:", docsURL)...)
|
||||
msgs = append(msgs, r.ProvisionerDaemons.Summarize("Provisioner Daemons:", docsURL)...)
|
||||
msgs = append(msgs, r.Websocket.Summarize("Websocket:", docsURL)...)
|
||||
msgs = append(msgs, r.WorkspaceProxy.Summarize("Workspace Proxies:", docsURL)...)
|
||||
return msgs
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ type BaseReport struct {
|
||||
|
||||
// Summarize returns a list of strings containing the errors and warnings of BaseReport, if present.
|
||||
// All strings are prefixed with prefix.
|
||||
func (b *BaseReport) Summarize(prefix string) []string {
|
||||
func (b *BaseReport) Summarize(prefix, docsURL string) []string {
|
||||
if b == nil {
|
||||
return []string{}
|
||||
}
|
||||
@@ -165,6 +165,7 @@ func (b *BaseReport) Summarize(prefix string) []string {
|
||||
_, _ = sb.WriteString("Warn: ")
|
||||
_, _ = sb.WriteString(warn.String())
|
||||
msgs = append(msgs, sb.String())
|
||||
msgs = append(msgs, "See: "+warn.URL(docsURL))
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
@@ -41,18 +41,24 @@ func TestSummarize(t *testing.T) {
|
||||
expected := []string{
|
||||
"Access URL: Error: test error",
|
||||
"Access URL: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
"Database: Error: test error",
|
||||
"Database: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
"DERP: Error: test error",
|
||||
"DERP: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
"Provisioner Daemons: Error: test error",
|
||||
"Provisioner Daemons: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
"Websocket: Error: test error",
|
||||
"Websocket: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
"Workspace Proxies: Error: test error",
|
||||
"Workspace Proxies: Warn: TEST: testing",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test",
|
||||
}
|
||||
actual := hr.Summarize()
|
||||
actual := hr.Summarize("")
|
||||
assert.Equal(t, expected, actual)
|
||||
})
|
||||
|
||||
@@ -87,7 +93,9 @@ func TestSummarize(t *testing.T) {
|
||||
expected: []string{
|
||||
"Error: testing",
|
||||
"Warn: TEST01: testing one",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test01",
|
||||
"Warn: TEST02: testing two",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test02",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -109,14 +117,16 @@ func TestSummarize(t *testing.T) {
|
||||
expected: []string{
|
||||
"TEST: Error: testing",
|
||||
"TEST: Warn: TEST01: testing one",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test01",
|
||||
"TEST: Warn: TEST02: testing two",
|
||||
"See: https://coder.com/docs/v2/latest/admin/healthcheck#test02",
|
||||
},
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actual := tt.br.Summarize(tt.pfx)
|
||||
actual := tt.br.Summarize(tt.pfx, "")
|
||||
if len(tt.expected) == 0 {
|
||||
assert.Empty(t, actual)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user