wsl

package
v1.26.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package wsl holds the WSL2-specific detection and config-patching logic that `lerd wsl:setup` and the doctor's WSL checks share. The file-patch helpers are pure (content in, content out) so they're unit-testable without touching real /etc/wsl.conf, ~/.config/containers/containers.conf, or %USERPROFILE%\.wslconfig.

Index

Constants

This section is empty.

Variables

View Source
var WSLConfigLines = []struct{ Key, Line string }{
	{"networkingMode", "networkingMode=mirrored"},
	{"dnsTunneling", "dnsTunneling=true"},
	{"firewall", "firewall=true"},
	{"autoProxy", "autoProxy=true"},
}

WSLConfigLines are the [wsl2] settings lerd recommends in %USERPROFILE%\.wslconfig: mirrored networking so Windows browsers can reach *.test / *.localhost, with the related DNS/firewall/proxy toggles. Deliberately omits localhostForwarding and pageReporting, which are a no-op under mirrored mode and an unrecognized key respectively, and so spam WSL with warnings on every terminal launch.

Functions

func EnsureSectionLine

func EnsureSectionLine(content, section, key, line string) (string, bool)

EnsureSectionLine guarantees an ini/toml file's `[section]` contains a line assigning `key`, setting it to `line` (the full `key=value` text, so callers control quoting and spacing). It returns the updated content and whether anything changed: a key already set to `line` is left untouched (idempotent), a key set to something else is rewritten, a missing key is inserted under an existing section, and a missing section is appended. Good enough for the flat, hand-edited config files WSL setup touches; not a general TOML parser.

func HasEventsLoggerJournald

func HasEventsLoggerJournald(content string) bool

HasEventsLoggerJournald reports whether a containers.conf already sets events_logger to journald, used by the doctor to flag the misconfiguration that breaks every `podman logs --follow` (and thus every dashboard log pane) on a systemd WSL host.

func IsWSL

func IsWSL() bool

IsWSL reports whether we're running inside a WSL2 distro. WSL sets WSL_DISTRO_NAME in every shell, and the kernel release carries "microsoft" (WSL2) or "WSL"; either is conclusive.

Types

This section is empty.

Jump to

Keyboard shortcuts

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