updater

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package updater implements the core DNS update flow shared by the cron path (cmd/update.go) and the serve handler (internal/server).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSClient

type DNSClient interface {
	GetCurrentIP(ctx context.Context) (string, error)
	UpdateIP(ctx context.Context, newIP string) error
}

DNSClient is the subset of internal/dns.Route53Client that the updater exercises. Declaring it here lets tests inject a mock without constructing a real AWS client. dns.Route53Client satisfies this interface.

type Options

type Options struct {
	Force      bool
	DryRun     bool
	Quiet      bool
	Verbose    bool   // emit per-step diagnostic output (source choice, interface, TTL)
	OverrideIP string // empty = resolve via myip.GetPublicIP (default cron behavior)

	// Client, if set, replaces the Route53 client the updater would otherwise
	// construct from cfg. Intended for tests and for the serve handler.
	Client DNSClient
}

Options controls a single update run.

type Result

type Result struct {
	Action   string // "updated" | "nochg-cache" | "nochg-dns" | "dry-run"
	OldIP    string
	NewIP    string
	Hostname string
}

Result describes the outcome of Update.

func Update

func Update(ctx context.Context, cfg *config.Config, opts Options) (*Result, error)

Update performs the full update flow: resolve IP → compare cache → compare DNS → upsert → update cache.

Jump to

Keyboard shortcuts

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