Documentation
¶
Overview ¶
Package solve asks the service whether there is work for this machine.
The agent asks; the service never calls the agent. That is the decision the whole channel rests on: nothing new listens on the customer's server, so nothing new on it can be attacked. It travels on the same outgoing HTTPS and the same token the agent already uses for scans.
This package only carries messages. Running an action is #182's job, and deliberately not here — the road first, then what travels on it.
Index ¶
Constants ¶
const ( // ModeDryRun means: find out what would change, and report it. Change nothing. ModeDryRun = "dry_run" // ModeRun means: a human approved this. Do it. ModeRun = "run" )
Mode is what the service is asking this agent to do.
Variables ¶
This section is empty.
Functions ¶
func ReportDryRun ¶
func ReportDryRun(ctx context.Context, apiBaseURL, token string, report DryRunReport) error
ReportDryRun sends back what would change. The job then waits for a human.
func ReportResult ¶
func ReportResult(ctx context.Context, apiBaseURL, token string, report ResultReport) error
ReportResult sends back how the run ended, whether or not it worked.
Types ¶
type Action ¶
Action is one thing the service is asking for: a type from the agent's own catalog, and the values to fill in. Never a command.
type DryRunReport ¶
type DryRunReport struct {
MachineUUID string `json:"machine_uuid"`
JobID string `json:"-"`
PreviewID string `json:"preview_id"`
// OK is false when this machine cannot carry the actions out at all. That is
// still a preview: the answer to "what would happen here" is "nothing, and
// this is why". The service refuses to let such a preview be approved, so a
// person is not sent to a server to be told a second time.
OK bool `json:"ok"`
Detail any `json:"detail"`
}
DryRunReport is what would have changed, had the agent acted.
Detail is whatever the runtime produced, passed through untouched: the real commands, their real output and the honest ledger. Summarising it here would be choosing for the customer what they get to see.
type ResultReport ¶
type ResultReport struct {
MachineUUID string `json:"machine_uuid"`
JobID string `json:"-"`
OK bool `json:"ok"`
Detail any `json:"detail"`
}
ResultReport is how a run ended.
type Work ¶
type Work struct {
Mode string `json:"mode"`
JobID string `json:"job_id"`
Actions []Action `json:"actions"`
// Backup is whether the person asked for a copy to be taken first. It is a
// request, not an instruction: whether one is possible is measured on this
// machine, at the moment of running.
Backup bool `json:"backup"`
}
Work is the service's answer to "is there anything for me?".