-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Use netip types in API structs #50944
Copy link
Copy link
Closed
Labels
area/apiAPIAPIimpact/apiimpact/go-sdkNoteworthy (compatibility changes) in the Go SDKNoteworthy (compatibility changes) in the Go SDKkind/refactorPR's that refactor, or clean-up codePR's that refactor, or clean-up coderelease-blockerPRs we want to block a release onPRs we want to block a release onstatus/0-triage
Milestone
Metadata
Metadata
Assignees
Labels
area/apiAPIAPIimpact/apiimpact/go-sdkNoteworthy (compatibility changes) in the Go SDKNoteworthy (compatibility changes) in the Go SDKkind/refactorPR's that refactor, or clean-up codePR's that refactor, or clean-up coderelease-blockerPRs we want to block a release onPRs we want to block a release onstatus/0-triage
Description
We represent IP addresses and prefixes as CIDR-notation JSON strings over the wire in the Engine API. Our Go API struct definitions also use string as the type of fields representing IP addresses and prefixes, which inconveniently requires application code to parse and marshal the strings. The
"net/netip".Addrand.Prefixtypes implementencoding.TextMarshalerandencoding.TextUnmarshalerinterfaces, which means fields of these types will un/marshal from/to JSON strings automagically. We should take advantage of this opportunity to make breaking changes to the API module and change these fields to netip types for improved ergonomics.Note: we don't have to boil the ocean. Since the wire format is identical, we can move the stringly-typed struct definitions into the daemon and use those until we have the time to refactor. We only have to change the API definitions themselves and the client module to unblock the release.
NB: the types being removed in #50846 have not been included in the list.