config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLocalFile

func DefaultLocalFile() string

DefaultLocalFile returns the default Caddyfile path: a "Caddyfile" sitting next to the config file (e.g. ~/.config/hl/Caddyfile), expressed with a leading ~ when it lives under the home directory so it reads cleanly and stays portable across machines.

func DefaultPath

func DefaultPath() string

DefaultPath returns the config file path: $XDG_CONFIG_HOME/hl/config.yaml if XDG_CONFIG_HOME is set, otherwise ~/.config/hl/config.yaml on both macOS and Linux.

func Exists

func Exists(path string) bool

Exists reports whether a config file is already present at path.

func Render

func Render(v InitValues) string

Render produces a complete, grouped config file from v. Every string value is emitted quoted so user input containing YAML-significant characters (a colon, a leading #, *, [, {, ~, or an IPv6 host like [fd00::1]) round-trips intact.

func ResolveSecret

func ResolveSecret(ctx context.Context, s string) (string, error)

ResolveSecret turns a configured secret value into its literal form:

  • an "op://vault/item/field" reference is read via the 1Password CLI (`op read`)
  • a value containing "${VAR}" is expanded from the environment
  • any other value is returned unchanged

This lets the Technitium token be stored as a literal, an env reference, or a 1Password reference without a login step.

func SuggestedAgentSocket

func SuggestedAgentSocket() string

SuggestedAgentSocket returns a stable ssh-agent socket to show as a hint during onboarding: the platform's 1Password agent socket. It is only a placeholder — leaving agent_socket empty makes hl fall back to $SSH_AUTH_SOCK at run time, which is the right default for the macOS built-in agent (whose socket lives under /var/run/com.apple.launchd.*/Listeners and rotates every login, so it must never be persisted).

func Write

func Write(path, content string) error

Write writes content to path (creating parent dirs), overwriting any existing file. Use Exists to decide whether to confirm an overwrite first.

Types

type Caddy

type Caddy struct {
	LocalFile  string `yaml:"local_file"`
	Remote     Remote `yaml:"remote"`
	ManagedTag string `yaml:"managed_tag"`
}

type Config

type Config struct {
	Technitium Technitium `yaml:"technitium"`
	Caddy      Caddy      `yaml:"caddy"`
	// contains filtered or unexported fields
}

func Load

func Load(path string) (*Config, error)

Load reads the config file at path (or the default path when empty), starting from built-in defaults and layering the file then HLDNS_* environment variables on top. A missing file is not an error; defaults and environment variables still apply.

func (*Config) Path

func (c *Config) Path() string

type InitValues

type InitValues struct {
	URL         string
	Token       string
	LocalFile   string
	RemoteHost  string
	RemoteUser  string
	RemotePort  int
	SSHKey      string // set for key-file auth; empty otherwise
	AgentSocket string // set for ssh-agent auth; empty falls back to $SSH_AUTH_SOCK
	RemotePath  string
	ReloadCmd   string
	ValidateCmd string
	ManagedTag  string
}

InitValues holds the answers gathered by `hl config init` and rendered into a complete config file. All fields are present so the written file never omits a setting the user needs to fill.

func DefaultInitValues

func DefaultInitValues() InitValues

DefaultInitValues returns the starting point for the init wizard / template.

type Remote

type Remote struct {
	Host        string `yaml:"host"`
	User        string `yaml:"user"`
	Port        int    `yaml:"port"`
	Key         string `yaml:"key"`
	AgentSocket string `yaml:"agent_socket"`
	RemotePath  string `yaml:"remote_path"`
	ReloadCmd   string `yaml:"reload_cmd"`
	ValidateCmd string `yaml:"validate_cmd"`
}

type Technitium

type Technitium struct {
	URL   string `yaml:"url"`
	Token string `yaml:"token"`
}

Jump to

Keyboard shortcuts

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