69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
// Package target defines the application-facing seam implemented by configuration Targets.
|
|
package target
|
|
|
|
import (
|
|
"context"
|
|
|
|
"proxyctl/internal/profile"
|
|
)
|
|
|
|
// State is the detected state of a Target's actual configuration.
|
|
type State string
|
|
|
|
const (
|
|
Enabled State = "Enabled"
|
|
Disabled State = "Disabled"
|
|
External State = "External"
|
|
Drifted State = "Drifted"
|
|
)
|
|
|
|
type Description struct {
|
|
Name string
|
|
Summary string
|
|
Details string
|
|
}
|
|
|
|
type Availability struct {
|
|
Available bool
|
|
Evidence string
|
|
}
|
|
|
|
type Inspection struct {
|
|
State State
|
|
Evidence string
|
|
}
|
|
|
|
// OperationResult reports the adapter's immediate operation outcome. When Err
|
|
// is non-nil, Inspection is advisory because it may have been captured before a
|
|
// partial write or command failure. The Application explicitly calls Inspect
|
|
// before publishing the final state of a failed operation.
|
|
type OperationResult struct {
|
|
Inspection Inspection
|
|
Err error
|
|
}
|
|
|
|
// Check is one read-only diagnostic observation with the evidence behind it.
|
|
type Check struct {
|
|
Name string
|
|
OK bool
|
|
Evidence string
|
|
}
|
|
|
|
// Diagnosable is the optional Target capability for command and write-authority
|
|
// checks which cannot be inferred from availability and inspection alone.
|
|
type Diagnosable interface {
|
|
DiagnosticChecks(context.Context, *profile.Profile) []Check
|
|
}
|
|
|
|
// Target hides platform paths and commands from the application and TUI.
|
|
type Target interface {
|
|
ID() string
|
|
Description() Description
|
|
Availability(context.Context) Availability
|
|
Inspect(context.Context, *profile.Profile) Inspection
|
|
// Confirmation returns a warning that must be accepted before SetDesired.
|
|
// An empty string means the operation needs no confirmation.
|
|
Confirmation(enabled bool) string
|
|
SetDesired(context.Context, bool, *profile.Profile) OperationResult
|
|
}
|