catalogsync

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package catalogsync vendors the CashPilot web catalog into this repository and applies the small set of Desktop-only deltas declared in catalog-overlay/.

The design constraint that shapes everything here: a vendored file must stay as close to the web original as possible, byte for byte, so that reading it tells the truth and so that reviewing a sync commit shows what the web catalog actually changed. Re-serialising the YAML would reflow every folded block and drop every blank line, burying one real change in five hundred cosmetic ones. So the upstream bytes are copied verbatim and the overlay is applied as two narrow, exactly specified edits:

  • an image pin replaces the single physical line that holds docker.image, whose position is found by parsing the YAML (never by pattern-matching the text);
  • an append adds a whole top-level block to the end of the file.

Anything a future slice needs beyond those two should be a third named operation with its own guard, not a general-purpose merge: a merge that can silently rewrite any field is exactly how a vendored copy drifts without anyone noticing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(upstream map[string][]byte, overlay *Overlay) (map[string][]byte, error)

Apply returns what the vendored services/ tree must contain: every upstream file with its declared overlay applied, plus any Desktop-only entry that exists only in the overlay. Keys are slash-separated paths relative to the catalog root.

It fails rather than producing a plausible-looking tree when the overlay and the web catalog disagree, because every such disagreement is a way for the vendored copy to go quietly wrong:

  • a pin for a slug the web catalog no longer ships, or that is retired, or that upstream already pins itself — the pin is stale and would pin nothing;
  • a pin whose repository or tag differs from the web entry's image — upstream moved the image (the ProxyBase migration did exactly this) and the pin would hold Desktop on the retired one, which looks healthy and earns nothing;
  • a live upstream image with no pin at all — that is the digest-pin rule being dropped on the floor, and it would only surface later as a failing test.

func NormaliseEOL

func NormaliseEOL(body []byte) []byte

NormaliseEOL rewrites CRLF line endings to LF.

The catalog is compared byte for byte, and on Windows Git for Windows checks every file out through core.autocrlf=true by default: the working tree holds CRLF, the repository holds LF. Comparing raw bytes there reports the entire catalog as drifted — every file, on a checkout nobody has touched — which is a gate that can only cry wolf. .gitattributes pins these paths to LF so a fresh clone is clean; this keeps an already-CRLF working tree from lying too, and keeps the bytes written back out as LF.

Types

type Drift

type Drift struct {
	Path string
	Kind DriftKind
}

Drift is one vendored file that does not match the web catalog.

func Diff

func Diff(want, have map[string][]byte) []Drift

Diff reports every file in which have (the vendored tree) differs from want (the web catalog with the declared overlay applied), sorted by path. Line endings are normalised on both sides: a CRLF working tree is a checkout artefact, not drift.

type DriftKind

type DriftKind string

DriftKind says how a vendored file differs from what the overlay-applied web catalog says it should be.

const (
	// DriftMissing: the web catalog has this entry and the vendored copy does not.
	DriftMissing DriftKind = "missing"
	// DriftExtra: the vendored copy has an entry the web catalog no longer ships.
	DriftExtra DriftKind = "extra"
	// DriftChanged: both have the entry and the bytes differ.
	DriftChanged DriftKind = "changed"
)

type ImagePin

type ImagePin struct {
	// Image is the full pinned reference, e.g. "repo/name:tag@sha256:<64 hex>".
	Image string `yaml:"image"`
	// Why records what the pin is for, so a reader of catalog-overlay/image-pins.yml
	// does not have to guess. Free text; not interpreted.
	Why string `yaml:"why"`
}

ImagePin is one declared Desktop-only image pin: the digest-pinned reference that replaces the web catalog's floating docker.image for a service.

type Overlay

type Overlay struct {
	// ImagePins maps a service slug to its digest-pinned image reference.
	ImagePins map[string]ImagePin
	// Appends maps a catalog-relative path ("bandwidth/mysterium.yml") to raw YAML
	// text appended to the vendored file. When the web catalog has no such file, the
	// text is written on its own as a Desktop-only entry.
	Appends map[string][]byte
}

Overlay is the parsed contents of catalog-overlay/: every Desktop-only difference from the web catalog, declared in one place.

func LoadOverlay

func LoadOverlay(dir string) (*Overlay, error)

LoadOverlay reads catalog-overlay/ from disk. A missing directory is an empty overlay, which is a legitimate state (no declared deltas), not an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL