-
-
Notifications
You must be signed in to change notification settings - Fork 74
Create RR.ProviderData (close #119) #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(Super skeptical of an AI review but I'm curious, so...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new field to the RR struct to store provider-specific data and adds JSON serialization tags to several existing fields to prepare for version 1.0.
- Added JSON tags to Name, TTL, Type, and Data fields.
- Introduced a new field, ProviderData, for provider-specific data.
Comments suppressed due to low confidence (1)
record.go:112
- Consider adding the 'omitempty' option to the JSON tag for ProviderData (e.g.,
json:"provider_data,omitempty"
) to simplify the JSON output when no provider-specific data is present.
ProviderData any `json:"provider_data"`
seems simple enough, and btw AI is good enough to find issues (I use it near daily), but very far away from replacing us :P. @mholt i would add |
Thanks; I think only |
👍
Hmm, yeah, you're probably right here. So then calling Or, maybe it would be better to only have
The main problem that I can see is that we'll either need to document that Lines 13 to 15 in 10a2b0b
which might be annoying since that means that there's no “easy” way to compare records, or document that The other problem that I can think of is that weird things might happen if you try and copy But overall, I'm very much in favour of this. |
@gucci-on-fleek Great points, thanks!! Super helpful as usual. I now agree that we shouldn't put this in the It's a bit annoying, though, to put it in the individual struct types, so I just had an idea. What about this: type ProviderRecord struct {
Record
// Optional data associated with the provider serving this record.
// See the package godoc for important details on this field.
ProviderData any
} This way, provider packages can return Of course... this breaks callers' type-switches, which might be a deal-breaker. They'd have to specifically type-assert for this struct, then access the Record field to use it. Hmm. Yeah, maybe just putting it on each of the individual record type structs is better. I'll work on that. |
@gucci-on-fleek Okay, I reworked it so that ProviderData is in each individual struct type, not the RR struct. I also added some package-level godoc surrounding it. Since packages are supposed to return the individual struct types anyway, they can just attach their custom data in this field, and callers' type assertions will still work. Obviously, the provider-specific data is lost with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, hopefully this helps make it easier to port implementations to v1.0.
Co-authored-by: Max Chernoff <git@maxchernoff.ca>
Awesome, thanks! |
This is my proposal for being able to attach provider-specific (meta?)data to an RR. See #119.
However, since provider implementations are supposed to return the concrete struct types, not RRs, we'll likely need to add this field to all the specific structs (Address, TXT, CNAME, etc...).
I also added JSON tags to the RR struct, in preparation for 1.0, since JSON-serialization seems like it could be a common pattern. (Caddy/CertMagic do not do this, but I could see having separate JSON identifiers being handy.)
Finally, I am torn between
Meta
,Metadata
, andProviderData
for the field name. Any thoughts?@gucci-on-fleek What do you think?