Documentation
¶
Overview ¶
Package wbconfig resolves the user-level WB configuration file that several commands share (recipes for wb run, the remote section for wb remote).
Index ¶
Constants ¶
const ( MinCockpitPullRequestHourlyBudget = 10 MaxCockpitPullRequestHourlyBudget = 400 )
The bounds of cockpit.pull_request_hourly_budget. An observation of an open pull request is 6 GitHub reads, so the ceiling is at most 2,400 reads an hour (half of an authenticated token's 5,000), the default of 120 at most 720.
const CodeIndexProviderCodeGrapher = "codegrapher"
CodeIndexProviderCodeGrapher is the one code-index provider there is.
const DefaultCockpitCodeBrowserURL = "https://codegrapher.dev/"
DefaultCockpitCodeBrowserURL is the code browser Cockpit links to unless cockpit.code_browser_url says otherwise.
const DefaultCockpitHostedURL = "https://sneat.dev/wb/cockpit/"
DefaultCockpitHostedURL is the one place the hosted Cockpit address is spelled; every consumer reads it through CockpitConfig.
const MaxCockpitPullRequestLimit = 200
MaxCockpitPullRequestLimit bounds cockpit.pull_request_limit, so one pass cannot be configured into an unbounded number of GitHub reads.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns $XDG_CONFIG_HOME/wb/wb.yaml when configured, otherwise ~/.config/wb/wb.yaml.
func SetPeersUpstream ¶ added in v0.150.1
SetPeersUpstream writes wb.yaml's peers.upstream section (peer-connectivity#req:invite-and-join). It touches only the top-level "peers:" key and leaves every other byte of the file — including the entire `remote:` block, at whatever indentation, comment style, line ending or key order the operator wrote it in — untouched. Remote state, claims and peer events are deliberately independent.
Round 3 and round 4 each tried to derive the exact line range an existing "peers:" key occupies from decoded YAML structure (a node's line number, or the newlines embedded in a decoded scalar's value) and each time a different construction — a multi-line quoted scalar, a folded plain scalar, a block scalar — made that derived range wrong in one direction or the other: too short (leaking a sibling's lines into the replacement and duplicating them) or too long (deleting a second document, a trailing comment block, or a comment that merely happens to sit nearby), sometimes even producing a range past the end of the file's own line count.
Round 5's answer is to stop trying to handle arbitrary YAML. This function supports exactly two shapes and refuses everything else outright, leaving the file completely untouched:
- Shape A: no top-level "peers:" key exists yet. A new block is appended — before a trailing "---" or "..." document marker if the file has one, otherwise at EOF.
- Shape B: an existing block-style "peers:" key sits at column 0 (matched by the literal, exact line "peers:" — no quoting, no trailing comment, no unusual spacing), and every line of its body, up to the first line whose first character is not a space, is either blank or a single-line "key: value" pair (a single-line plain or single-line quoted scalar, no escape sequences) — with at most one nested sub-block, "upstream:", whose own children follow the exact same single-line-scalar rule one level deeper. The block's extent is found with nothing but a plain line scan (isPeersBodyLine, scanPeersBlockEnd): never from a decoded node's line number or a decoded scalar's length, so a construction that confused the old line-range derivation cannot confuse this one — it simply fails to match this narrow grammar and falls through to the refusal below.
Anything else — a flow-style root or a flow-style peers: value, a multi-line quoted or plain scalar anywhere in the body, a block scalar, an anchor, alias or tag, a comment inside the body or immediately above "peers:", more than one "upstream:" child, or a body that fails to parse as YAML at all — is refused with a clear, actionable message rather than guessed at.
verifyPeersUpstreamEdit then re-parses the result independently of every line-scan decision splicePeersBody made — decoding every YAML document (not just the first) and requiring every one but the first to be unchanged, decoding the first document's top-level keys and every peers: child besides "upstream" for a structural deep-equal, and separately re-running the same plain line scan against both the original and the updated text to require every byte outside the block's own range to be identical — before the staged file is ever renamed into place. Any mismatch refuses and leaves the original file untouched.
func SetRemoteHub ¶ added in v0.116.0
SetRemoteHub updates only the remote provider fields owned by hub enrollment. Other top-level configuration and remote settings are retained.
Types ¶
type CockpitConfig ¶ added in v0.173.0
type CockpitConfig struct {
// HostedURL is the hosted Cockpit origin and path.
HostedURL string
// CodeBrowserURL is where Cockpit's code links point.
CodeBrowserURL string
// AnonymousMetadata allows a loopback request with no session to read
// fleet metadata.
AnonymousMetadata bool
// RefreshInterval is how often the daemon refreshes the fleet snapshot.
// Zero means unset: the consumer chooses its default.
RefreshInterval time.Duration
// PullRequestLimit is the most pull requests the daemon observes on GitHub
// in one pass (cockpit-views#req:pull-request-fields). Zero means unset:
// the consumer chooses its default.
PullRequestLimit int
// PullRequestHourlyBudget is the most pull request observations in a
// rolling hour. Zero means unset: the consumer chooses its default.
PullRequestHourlyBudget int
// CodeIndexProvider names the code-index provider whose statistics the
// panels show; empty means none is configured, which is a normal state.
CodeIndexProvider string
// CodeIndexIndexer is the hooks executor whose receipts the provider
// follows; empty means the provider's own default.
CodeIndexIndexer string
// RemoteHTTP lets the daemon read other machines' export envelopes over
// HTTP from the machines that have an HTTP route configured
// (cockpit-views#req:remote-exporter-transports). It is on unless
// cockpit.remote_http is false.
RemoteHTTP bool
// RemoteSSH is the same switch for the SSH fallback, on unless
// cockpit.remote_ssh is false. It is accepted here so that a configuration
// that opts out is valid before the SSH transport exists; the transport
// reads it when it is added.
RemoteSSH bool
}
CockpitConfig is wb.yaml's cockpit: section, after defaults.
func DefaultCockpitConfig ¶ added in v0.173.0
func DefaultCockpitConfig() CockpitConfig
DefaultCockpitConfig is the section's value when wb.yaml sets nothing.
func LoadCockpit ¶ added in v0.173.0
func LoadCockpit(path string) (CockpitConfig, error)
LoadCockpit reads the cockpit: section from path. An absent file or section is not an error: the defaults apply.
type PeersUpstreamConfig ¶ added in v0.150.1
PeersUpstreamConfig is the peers.upstream section `wb peers list` reads on the laptop (upstream) side.
func LoadPeersUpstream ¶ added in v0.150.1
func LoadPeersUpstream(path string) (PeersUpstreamConfig, bool, error)
LoadPeersUpstream reads peers.upstream from path. found is false when the file, the peers section, or the upstream section is absent — the laptop simply has no configured hub yet, which is not an error.