configsvc

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configsvc renders, checks, and shows the SSH config. All three modes drive the ONE renderer, so the verifier and the writer can never disagree; check changes nothing.

Index

Constants

View Source
const ShadowFix = "delete or rename that block, or remove those lines from it " +
	"(authama does not edit content outside its managed block)"

ShadowFix says how to resolve a shadow. authama never edits content outside its managed block, so the fix is the user's to make.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	FileDiffs map[string]string
	Missing   []string
	Orphan    []string
	// SSHErrors is filled only when Check ran with validateSSH; callers that
	// skip the ssh leg get an empty map and an InSync that ignores it.
	SSHErrors map[string]string
	// Shadowed lists managed aliases that foreign content above the managed
	// block takes over, so ssh does not do what the manifest says for them.
	Shadowed []Shadow
	// Duplicates lists Host patterns the managed files define more than once.
	Duplicates []Duplicate
}

CheckResult reports config drift. InSync is the gate.

func (*CheckResult) BlockInSync

func (r *CheckResult) BlockInSync() bool

BlockInSync reports whether every managed file on disk matches the manifest byte for byte - the part `config render` can fix.

func (*CheckResult) Format

func (r *CheckResult) Format() string

Format renders a human report.

func (*CheckResult) InSync

func (r *CheckResult) InSync() bool

InSync reports whether the on-disk config matches the manifest and, when it was asked, whether ssh can parse it. A config ssh refuses breaks every host, so it is never in sync even when every managed byte matches. Nor is one where a foreign block ssh reads first overrides a managed alias: the bytes match, but ssh resolves something else.

type Duplicate

type Duplicate struct {
	Pattern string
	Files   []string // in the order ssh reads them
}

Duplicate is a Host pattern that authama's managed files define more than once. ssh uses only the first, so the later blocks are dead weight that reads as if it applied.

func (Duplicate) String

func (d Duplicate) String() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service renders/checks/writes the managed config under an ~/.ssh dir.

func New

func New(sshDir string, m *manifest.Manifest, emitUseKeychain bool) *Service

New builds a Service. emitUseKeychain is true only on macOS.

func (*Service) Check

func (s *Service) Check(validateSSH bool) (*CheckResult, error)

Check verifies the on-disk config against the manifest (read-only).

func (*Service) Rendered

func (s *Service) Rendered() (map[string]string, error)

Rendered returns {relpath -> content} for every managed file.

func (*Service) Show

func (s *Service) Show(alias string) (string, error)

Show returns the rendered config (no alias) or `ssh -G` for one alias.

func (*Service) Write

func (s *Service) Write(dryRun bool) (*WriteResult, error)

Write renders the config to disk (or previews with dryRun), preserving foreign content in the root config and pruning managed files the manifest no longer renders.

type Shadow

type Shadow struct {
	Alias    string
	File     string // the config file, as a path on disk
	Line     int    // 1-based line of the Host line (or of the first top-level option)
	Header   string // the Host line as written, or "(top level)"
	Keywords []string
}

Shadow is a foreign block above the managed block that ssh reads first for a managed alias. ssh keeps the first value it obtains for each keyword, so every keyword in Keywords comes from the user's block, not from the manifest.

func (Shadow) String

func (s Shadow) String() string

String is the one-line report: alias, file:line, and what it takes over.

type WriteResult

type WriteResult struct {
	Written   []string
	Pruned    []string
	Unchanged []string
	DryRun    bool
}

WriteResult reports what render wrote.

Jump to

Keyboard shortcuts

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