Repository navigation
feat: add Add/Remove/Get-PiHoleDnsRecord - #144
Merged
Merged
Conversation
Adds DNS-specific convenience wrappers for managing Pi-hole's local
DNS records (A/AAAA host entries and CNAME records), which were
already reachable generically via Add-PiHoleConfigArrayItem /
Remove-PiHoleConfigArrayItem on dns/hosts and dns/cnameRecords - these
just make that discoverable with typed, DNS-specific parameters
(-Type A/AAAA/CNAME, -IPv4Address, -IPv6Address, -Target, -Ttl)
instead of requiring callers to know Pi-hole's raw value format
("<ip> <hostname>" or "<alias>,<target>[,<ttl>]").
Both are thin wrappers that call the existing config-array functions
internally rather than duplicating their auth/HTTP logic.
Remove-PiHoleDnsRecord implements its own ShouldProcess and passes
-Confirm:$false through to the inner call to avoid double-prompting.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds Get-PiHoleDnsRecord, completing the Get/Add/Remove set for local DNS record management. Parses Pi-hole's raw dns.hosts/dns.cnameRecords config arrays into the same typed object shape Add-/Remove-PiHoleDnsRecord already use (Type/Hostname/IPv4Address/IPv6Address/Target/Ttl), with optional -Type/-Hostname filtering. Remove-PiHoleDnsRecord now accepts that same shape via ValueFromPipelineByPropertyName, so Get-PiHoleDnsRecord's output can be piped straight into it - including removing several matched records in a single pipeline. This is the first use of pipeline input anywhere in the module; no other function currently has a matching Get/Remove object shape to make it worthwhile. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
❌ The last analysis has failed. |
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
Add-PiHoleDnsRecord/Remove-PiHoleDnsRecord/Get-PiHoleDnsRecordas DNS-specific convenience wrappers for managing Pi-hole's local DNS recordsAdd-PiHoleConfigArrayItem/Remove-PiHoleConfigArrayItem/Get-PiHoleConfigondns/hostsanddns/cnameRecords- these just make it discoverable with typed, DNS-specific parameters instead of requiring callers to know Pi-hole's raw value format:Add/Removeare thin wrappers that call the existing config-array functions internally rather than duplicating their auth/HTTP/error-handling logic.Getparses.Dns.Hosts/.Dns.CnameRecordsinto the same typed object shape (Type/Hostname/IPv4Address/IPv6Address/Target/Ttl), filterable by-Type/-Hostname-IPv4Address/-IPv6Addressare validated against the real .NET address family (so passing an IPv6 address to-IPv4Addressor vice versa fails fast with a clear error, before any network call)Remove-PiHoleDnsRecordimplements its own-WhatIf/-ConfirmviaShouldProcess, passing-Confirm:$falsethrough to the inner call to avoid double-promptingRemove-PiHoleDnsRecordacceptsGet-PiHoleDnsRecord's output viaValueFromPipelineByPropertyName, including removing several matched records in one pipeline call - the first use of pipeline input anywhere in this moduleTest plan
Get-PiHoleConfig/Get-PiHoleDnsRecord, confirmed clean removalGet-PiHoleDnsRecord | Remove-PiHoleDnsRecordpipeline, including removing multiple records (AAAA + CNAME) in one pipeline callSet-PiHoleDnsBlocking/Get-PiHoleDnsBlockingStatustests - no regressions): create/verify for all 3 types, filtering by-Type/-Hostname,RawOutput, the pipeline chain (single and multi-record), error paths (missing required param per type, invalid IPv4 format),-WhatIfperforms no request, bad passwordFunctionsToExportall regenerated🤖 Generated with Claude Code