fix: complete target diagnostics and reset inspection

This commit is contained in:
proxyctl coordinator
2026-07-17 10:29:41 +08:00
parent f6c6ead325
commit 0fbaa71e37
14 changed files with 366 additions and 10 deletions
+29 -1
View File
@@ -154,7 +154,10 @@ type Adapter struct {
files FileSystem
}
var _ target.Target = (*Adapter)(nil)
var (
_ target.Target = (*Adapter)(nil)
_ target.Diagnosable = (*Adapter)(nil)
)
func New(configuration Configuration, files FileSystem) *Adapter {
if files == nil {
@@ -174,6 +177,31 @@ func (a *Adapter) Description() target.Description {
}
func (a *Adapter) Confirmation(bool) string { return "" }
// DiagnosticChecks validates the readable JSON surfaces and observes write
// authority without taking the adapter lock or creating any files.
func (a *Adapter) DiagnosticChecks(_ context.Context, _ *profile.Profile) []target.Check {
commandCheck := target.Check{Name: "required commands", OK: true, Evidence: "Docker client defaults require no external commands"}
schemaCheck := target.Check{Name: "configuration schema", OK: true, Evidence: "Docker client configuration and recovery metadata are absent or valid JSON objects"}
if config, _, err := a.readConfig(); err != nil {
schemaCheck.OK = false
schemaCheck.Evidence = profile.RedactText("Docker client config.json is invalid or unreadable: " + err.Error())
} else if proxies, _, err := childObject(config, "proxies"); err != nil {
schemaCheck.OK = false
schemaCheck.Evidence = profile.RedactText(err.Error())
} else if _, _, err := childObject(proxies, "default"); err != nil {
schemaCheck.OK = false
schemaCheck.Evidence = profile.RedactText(err.Error())
} else if _, _, err := a.readRecovery(); err != nil && !errors.Is(err, fs.ErrNotExist) {
schemaCheck.OK = false
schemaCheck.Evidence = profile.RedactText("Docker client recovery metadata is invalid or unreadable: " + err.Error())
}
return []target.Check{
commandCheck,
schemaCheck,
target.ReadOnlyWriteAuthority(a.configuration.ConfigFile, a.configuration.RecoveryFile),
}
}
func (a *Adapter) Availability(context.Context) target.Availability {
if !a.usablePath(a.configuration.ConfigFile) || !a.usablePath(a.configuration.RecoveryFile) {
return target.Availability{Evidence: "standard Docker client configuration paths are not usable for the owning user"}