Skip to content

feat: Support defining records by dns zone format#1360

Merged
kwitsch merged 22 commits into0xERR0R:mainfrom
BenMcH:zonefile
Feb 9, 2024
Merged

feat: Support defining records by dns zone format#1360
kwitsch merged 22 commits into0xERR0R:mainfrom
BenMcH:zonefile

Conversation

@BenMcH
Copy link
Copy Markdown
Contributor

@BenMcH BenMcH commented Jan 31, 2024

Closes #1355

As I got to looking at the issue above, it became obvious to me that support for DNS zone files only requires a very small change to my previous PR.

Outstanding questions for others:

  • Do we remove the CNAME() method under mappings? This hasn't been published as far as I can tell, so we have the option to remove it before it hits the mainline if we don't like/want that syntax moving forward for non-A records.
  • What is needed in terms of testing or documentation surrounding the $INCLUDE directive?
  • Should we document the $GENERATE directive and expect others to use it?
  • Currently, TTLs from the zone file are unused, as we always use the TTL from the customDNS.customTTL field. Is this expected behavior? Should we respect TTLs set by the zone file as it's advanced configuration?

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (178dbb7) 93.96% compared to head (efa5283) 93.97%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1360      +/-   ##
==========================================
+ Coverage   93.96%   93.97%   +0.01%     
==========================================
  Files          78       78              
  Lines        6343     6361      +18     
==========================================
+ Hits         5960     5978      +18     
  Misses        294      294              
  Partials       89       89              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kwitsch
Copy link
Copy Markdown
Collaborator

kwitsch commented Jan 31, 2024

My thoughts on the open questions:

  • Do we remove the CNAME() method under mappings? This hasn't been published as far as I can tell, so we have the option to remove it before it hits the mainline if we don't like/want that syntax moving forward for non-A records.

I opt for removal since it's not released yet.

  • What is needed in terms of testing or documentation surrounding the $INCLUDE directive?

There is a struct in helpertest to generate temporary folders and subsequently string based files for testing. If you look for the usages it should be obvious how to use it in tests. 😉

  • Should we document the $GENERATE directive and expect others to use it?

It should be enough to list what is currently not/supported and a link to an proper zonefile documentation (documenting it ourselves is a bit out of scope). 🤔

  • Currently, TTLs from the zone file are unused, as we always use the TTL from the customDNS.customTTL field. Is this expected behavior? Should we respect TTLs set by the zone file as it's advanced configuration?

customDNS.customTTL should only apply to the old format (documentation should mention it) in my opinion.

| customTTL | duration (no unit is minutes) | no | 1h |
| rewrite | string: string (domain: domain) | no | |
| mapping | string: string (hostname: address or CNAME) | no | |
| zoneFileMapping | multiline string containing a DNS Zone File | no | |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it supports already more than the simple mapping and is no file by itself I would opt for zone as config key. 🤔

@BenMcH
Copy link
Copy Markdown
Contributor Author

BenMcH commented Jan 31, 2024

Perfect! Thank you for your input @kwitsch. I'll implement these changes as I have some free time in the next day or 2

Copy link
Copy Markdown
Collaborator

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this!

I agree with everything @kwitsch said above :)
Just have very minor comments.

return err
}

result := make(ZoneFileDNS, len(input))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor copy-paste typo (1 seems sensible since you're probably at least going to have a domain if you specify the option):

Suggested change
result := make(ZoneFileDNS, len(input))
result := make(ZoneFileDNS, 1)

})

Describe("UnmarshalYAML", func() {
Describe("#CustomDNSEntries UnmarshalYAML", func() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does # do anything here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! I will remove it when I work on this next

@BenMcH
Copy link
Copy Markdown
Contributor Author

BenMcH commented Feb 1, 2024

This should be ready for another round of reviews 😄

@kwitsch
Copy link
Copy Markdown
Collaborator

kwitsch commented Feb 1, 2024

Gonna look into it tomorrow. 🙂👍

Copy link
Copy Markdown
Collaborator

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stuff, except the $INCLUDE thing which is a bit bigger but hopefully has enough guidance to follow!

Copy link
Copy Markdown
Collaborator

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two details, besides that everything looks good to me!

Copy link
Copy Markdown
Collaborator

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, this is great!

@ThinkChaos
Copy link
Copy Markdown
Collaborator

@kwitsch I didn't merge in case you had somethign to add. Anything left? If not can you press the green button? :)

@kwitsch kwitsch merged commit 9f633f1 into 0xERR0R:main Feb 9, 2024
@kwitsch
Copy link
Copy Markdown
Collaborator

kwitsch commented Feb 9, 2024

@kwitsch I didn't merge in case you had somethign to add. Anything left? If not can you press the green button? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support DNS Zone File Syntax

3 participants