Add non-mutating --dry-run preflight and testable installer parameters - #12
Merged
Conversation
- set_dns.py: add argparse CLI with --dry-run and --config while preserving dispatcher positional arguments (interface/action). Dry run validates config selection/parsing, local IPv4, dispatcher arguments, and the derived FQDN, prints the intended reconciliation, and returns success without constructing a Cloudflare client or calling the API. - install.py: make install() testable via optional source_dir, dispatcher_path, and config_files parameters; production constants, defaults, paths, root check, aliases, ownership, and modes unchanged. - tests: cover dry-run client avoidance, intended-action reporting, --config selection, dispatcher argument handling, preferred-over-legacy config priority, installer targets/ownership/modes, and failure paths using tmp_path and mocks. - README/CONTRIBUTING: document --dry-run as a non-mutating preflight that does not test Cloudflare/SOPS key availability or dispatcher execution.
Patching os.getuid in a fixture ran before tmp_path setup and broke pytest's temporary-directory ownership check. Patch only around the install() invocation via context managers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a non-mutating
--dry-runpreflight mode toset_dns.pyand makesinstall.pytestable, per the authorized task design:set_dns.pygains argparse-based CLI parsing with optional--dry-runand--config PATH. Dispatcher positional arguments (interface/action) are preserved and normal behavior is unchanged when--dry-runis omitted. Dry run validates root-volume config selection/parsing, the local IPv4, dispatcher arguments, and the derived FQDN, prints the intended reconciliation, and returns success without constructing a Cloudflare client or making any API call.install.pyinstall()gains optionalsource_dir,dispatcher_path, andconfig_filesparameters. Production constants, default paths, root check, alias priority, ownership (0:0), and modes (0700/0600) are unchanged.--config, preserves dispatcher arguments, and that the installer preferscflan_-prefixed config, keeps legacy aliases valid, applies expected ownership/modes, and fails on missing dispatcher directory or non-root execution — all withtmp_pathand mocks.--dry-runprecisely: it never constructs a Cloudflare client or calls the Cloudflare API; for an encrypted selected config (cflan_sops_vars.yaml/sops_vars.yaml) it does invoke SOPS locally, exercising SOPS/key availability without writing plaintext to disk; and it does not install or execute the actual NetworkManager dispatcher hook.Type of change
Validation
Intentionally not validated: live host installation, NetworkManager dispatcher execution, and Cloudflare API behavior — out of scope and unchanged.
Impact and rollout
None beyond this repository. Source-only change; no version bump, no release, no GitOps or runtime impact. Existing installations are unaffected until they choose to upgrade.
--dry-runnever contacts the Cloudflare API and does not install or execute the NetworkManager dispatcher hook; for an encrypted selected config it invokes SOPS locally (in-process plaintext only, never written to disk).Safety and secrets
test-token; changed content was inspected for secrets before commit)This change was produced by an AI agent per an authorized task specification; scope was fixed by the requester.