Documentation
¶
Overview ¶
Package preflight answers one question before a deploy runs: what, on THIS machine, will stop this service earning?
The catalog shows one generic earnings range per service. A user cannot tell, before deploying, whether a service will work at all in their situation — and several will not. They find out weeks later, when it has earned nothing.
This is the Go port of the web repository's app/preflight.py, and it keeps that module's two rules:
- Informed consent, not a nanny. Where the answer is "this will earn nothing for you", say so plainly and let the deploy proceed. Nothing here blocks.
- Never imply a check we did not run. Desktop cannot see what kind of internet connection it is on, how fast it is, or how much disk is free. Requirements that depend on those are reported as unverified preconditions in the user's own words, never as a pass, and everything unknown is listed by name.
Three things are deliberately NOT a straight copy of the web module, because on a desktop they would be wrong:
- The web module warns when the SAME service is already deployed on the same worker, treating it as a second instance. Desktop deploys one container per service (cashpilot-<slug>), so redeploying a service replaces it. Firing "a second instance earns nothing" there would warn every user who simply re-deploys, which is the false alarm this whole feature exists to avoid.
- The web module can confirm that two workers leave through the same public address and states a documented per-IP conflict as fact. Desktop knows the names and services of the other machines in the fleet but not their egress, so the same conflict is reported as something to check, conditional on the machines sharing one connection. A warning we cannot stand behind is stated as a question, never as a verdict.
- The web module swaps in the per-architecture image on deploy (arch.image_for), so an entry with image_by_arch really does run everywhere it declares. Desktop deploys docker.image and nothing else, so on a CPU that has an override the image the user actually gets is the x86-64 one. This module reports what is deployed today, not what the catalog could offer: counting the override as a pass would promise a build nobody will ever pull. When the deploy path learns to pick the override, this finding goes away with it.
Index ¶
- Constants
- func Builds(docker catalog.DockerConfig) string
- func DaemonArch(ctx context.Context) string
- func Family(machine string) string
- func Label(family string) string
- func Supports(docker catalog.DockerConfig, machine string) (supported bool, known bool)
- type Device
- type Finding
- type Input
- type Report
- type Target
Constants ¶
const ( EarnsNothing = "will_earn_nothing" Reduced = "reduced_earnings" CheckYourself = "check_these" LooksFine = "looks_fine" )
The four verdicts, worst first. Same vocabulary as the web repository, so a finding means the same thing in both products.
Variables ¶
This section is empty.
Functions ¶
func Builds ¶ added in v0.20.0
func Builds(docker catalog.DockerConfig) string
Builds is describeBuilds for callers outside this package.
func DaemonArch ¶
DaemonArch reports the CPU architecture of the container runtime, as the runtime itself reports it ("arm64", "x86_64", "amd64").
The container runs on the DAEMON, not on the Desktop binary, and the two are not always the same machine: a remote Docker context, a Lima or Colima VM, or Podman in a virtual machine all move the real target elsewhere. Reading the Desktop binary's own architecture instead would be a guess dressed as a check, so an unreachable runtime returns "" and the assessment says the CPU was not checked.
Works with Docker and with Podman, which serves the same API over DOCKER_HOST.
func Family ¶
Family folds a reported machine name to one of the three families: "aarch64" -> "arm64", a family name to itself, anything unknown to "".
func Supports ¶ added in v0.20.0
func Supports(docker catalog.DockerConfig, machine string) (supported bool, known bool)
Supports is supports for callers outside this package. The compose export asks it before writing a file for a chosen architecture, so the same rule that warns in the wizard refuses an export that could not run: one answer, not two.
Types ¶
type Device ¶
Device is one other machine in the fleet, reduced to what a preflight needs: what to call it, and what it already runs.
type Input ¶
type Input struct {
// Service is the catalog entry about to be deployed.
Service catalog.Service
// Fleet is the OTHER machines registered with this Desktop. The local machine is
// not in here: Desktop runs one container per service, so its own deployments are
// a redeploy rather than a second device.
Fleet []Device
// DaemonArch is what the container runtime reports about the CPU it runs on
// ("arm64", "x86_64"). Empty means it could not be read, which is reported as
// unchecked rather than guessed — the Desktop binary's own architecture is not
// the same fact when the runtime is a VM or a remote context.
DaemonArch string
}
Input is everything the assessment reads. Every field is optional: with an empty Input the assessment degrades to what the catalog entry alone says and keeps listing what it could not check.
type Report ¶
type Report struct {
Slug string `json:"slug"`
Name string `json:"name"`
Verdict string `json:"verdict"`
Summary string `json:"summary"`
Findings []Finding `json:"findings"`
NotChecked []string `json:"notChecked"`
// MachineArch is the architecture the assessment used, empty when unknown.
MachineArch string `json:"machineArch"`
Blocking bool `json:"blocking"`
}
Report is the whole answer, ready to render. Blocking is always false: this informs a decision, it never takes it.