-
Notifications
You must be signed in to change notification settings - Fork 47
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: convert metal_port to equinix-sdk-go #709
Conversation
State: packngo.VLANAssignmentUnassigned, | ||
vacr.VlanAssignments = append(vacr.VlanAssignments, metalv1.PortVlanAssignmentBatchCreateInputVlanAssignmentsInner{ | ||
Vlan: &v, | ||
State: metalv1.PORTVLANASSIGNMENTBATCHVLANASSIGNMENTSINNERSTATE_UNASSIGNED.Ptr(), |
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.
:cough:
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.
🤷
@@ -127,20 +130,20 @@ func resourceMetalPort() *schema.Resource { | |||
|
|||
func resourceMetalPortUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | |||
start := time.Now() | |||
cpr, _, err := getClientPortResource(d, meta) | |||
cpr, _, err := getClientPortResource(ctx, d, meta) | |||
if err != nil { | |||
return diag.FromErr(equinix_errors.FriendlyError(err)) | |||
} | |||
|
|||
for _, f := range [](func(*ClientPortResource) error){ | |||
portSanityChecks, |
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'm tempted to ask for a contextDisposal wrapper so that this one function can fit the pattern, accept a context, and noop the supplied context.
The other functions wouldn't need to be created with a context and context would be supplied at time of use.
something like:
func contextDisposal(f func(*ClientPortResource) error) func(_ context.Context, *ClientPortResource) error){
return func(_ context.Context, *ClientPortResource) error) {
return f
}
}
for _, f := range [](func(context.Context, *ClientPortResource) error){
contextDisposal(portSanityChecks),
... (the other lines would not change, so function names without arguments)
} {
if err := f(ctx, cpr); err != nil {
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.
A wrapper function wouldn't be sufficient here because the existing function bodies need to be updated to reference the context. Instead I updated the various helper functions to accept a context and a ClientPortResource so that the PR diff is easier to parse.
There were a few tests that failed that seem related to the changes in this PR, seemingly around VLANs not being able to be removed because of active port links.
|
|
This PR was, until recently, a WIP, but I left it out of draft out of laziness (have to click a whole button to run CI for a draft PR branch) and neglected to update the PR title. In any case, it is no longer a WIP and the tests should be passing as of now. |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #709 +/- ##
==========================================
- Coverage 37.91% 34.39% -3.52%
==========================================
Files 120 151 +31
Lines 19476 20640 +1164
==========================================
- Hits 7384 7100 -284
- Misses 11884 13378 +1494
+ Partials 208 162 -46 ☔ View full report in Codecov by Sentry. |
Some packngo usage was missed in #709. This completely removes packngo from metal_port, as well as calls to `FriendlyError` because that function has no impact for non-packngo errors.
Some packngo usage was missed in #709. This completely removes packngo from metal_port, as well as calls to `FriendlyError` because that function has no impact for non-packngo errors.
This replaces
packngo
withequinix-sdk-go
in the metal_port resource and datasource as part of #402. While I'm in these files I also opted to move them intointernal/resources/metal/port
to align with #106.