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.
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
feat: use metal-go for device reads (data source and resource) #291
feat: use metal-go for device reads (data source and resource) #291
Changes from all commits
ff85c55
4a6d54f
eb0f974
243f372
7b79a23
8eb1424
ff04f9c
743119e
f80eb68
cfb80a7
e378823
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
nit: presumably this will never be null in a returned devices list, so this should be fine.
GetHostname()
is an option.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.
I cleaned up the unnecessary MetalGo suffixes from helper methods, but it does make some of these changes harder to review. I can back out the name change if that's preferred, but I'm going to instead try to annotate the current changes to guide review.
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.
This is replacing direct references to the
ip
struct properties with calls to theGet...()
functions. The struct properties are pointers and theGet...()
functions dereference the pointers (returning the zero value if the pointer is nil), so theGet...()
functions better reflect how the previouspackngo
implementation worked.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.
This is replacing pointer dereferences with
Get...()
calls for better protection against nil pointer errors.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.
The
NetworkType
device attribute exposed bypackngo
is not an API-provided attribute; this serves as a shim so we can use thepackngo
logic to calculateNetworkType
. We could instead either duplicate the completepackngo
logic here or copy it intometal-go
, but my understanding is thatNetworkType
is not something we want to keep around anyway, so this shim is designed to get us through the SDK transition and then be eliminated whenpackngo
is no longer used in the provider.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.
As with
getNetworkInfo
, this change replaces the innards ofgetPorts
with those ofgetPortsMetalGo
while also updating the function to useGet...()
helpers, since those helpers more closely match the behavior of thepackngo
implementation.