Files
orca/internal/cli/doctor.go
T
Jon Chery df58bc25a3 docs(milestone): complete scheduling-streaming (v0.3)
---ci---
project: orca
phase: 3
milestone: v0.3
status: complete
requirements:
  covered: [REQ-022, REQ-030, REQ-032]
  partial: []
---/ci---

v0.3 milestone merged to main. Includes all v0.2 work (P08-P10) that
was previously on the milestone branch but not yet merged to main, plus
the v0.3 completion work (iter.Seq streaming + doctor network/db).

v0.2 phases included: P08 (mTLS), P09 (scheduling), P10 (security scan).
v0.3 phases: P0 (pre-execution), P1 (iter.Seq streaming), P2 (doctor),
P3 (final review+ship).

Total: 40 requirements, all complete. No new go.mod dependencies.
Full test suite passes under -race. gofmt + go vet clean.
2026-08-01 20:06:47 +00:00

76 lines
1.9 KiB
Go

package cli
import (
"fmt"
"github.com/spf13/cobra"
"git.cloudinit.dev/coreci/orca/internal/doctor"
)
var doctorCmd = &cobra.Command{
Use: "doctor",
Short: "Run self-checks on the orca installation",
Long: "Verify CA, server cert, expiry, fingerprint, network, and DB. Reports PASS/WARN/FAIL per check.",
RunE: func(cmd *cobra.Command, args []string) error {
report := doctor.Run(cmd.Context())
if jsonOutput {
return printJSON(report.Checks)
}
fmt.Fprint(cmd.OutOrStdout(), report.Print())
return nil
},
}
var doctorCertCmd = &cobra.Command{
Use: "cert",
Short: "Run only the cert self-checks",
RunE: func(cmd *cobra.Command, args []string) error {
checks := []doctor.Check{
doctor.CertCA(),
doctor.CertServer(),
doctor.CertExpiry(),
doctor.CertFingerprint(),
}
results := make([]doctor.CheckResult, 0, len(checks))
for _, c := range checks {
r, msg := c.Run(cmd.Context())
results = append(results, doctor.CheckResult{Name: c.Name, Result: r, Message: msg})
}
if jsonOutput {
return printJSON(results)
}
for _, r := range results {
fmt.Fprintf(cmd.OutOrStdout(), "%-20s %-5s %s\n", r.Name, r.Result, r.Message)
}
return nil
},
}
var doctorNetworkCmd = &cobra.Command{
Use: "network",
Short: "Run the network self-check (P02 impl)",
RunE: func(cmd *cobra.Command, args []string) error {
c := doctor.Network()
r, msg := c.Run(cmd.Context())
fmt.Fprintf(cmd.OutOrStdout(), "%-20s %-5s %s\n", c.Name, r, msg)
return nil
},
}
var doctorDBCmd = &cobra.Command{
Use: "db",
Short: "Run the database self-check (P02 impl)",
RunE: func(cmd *cobra.Command, args []string) error {
c := doctor.DB()
r, msg := c.Run(cmd.Context())
fmt.Fprintf(cmd.OutOrStdout(), "%-20s %-5s %s\n", c.Name, r, msg)
return nil
},
}
func init() {
doctorCmd.AddCommand(doctorCertCmd, doctorNetworkCmd, doctorDBCmd)
rootCmd.AddCommand(doctorCmd)
}