fix: nic code consistency - #930
Conversation
|
There was a problem hiding this comment.
Pull request overview
This pull request improves code consistency in the NIC resource by standardizing variable naming conventions, simplifying error handling, fixing a bug in error messages, and refactoring conditional logic for better readability.
Changes:
- Standardized variable naming from
dcid,srvid,nicidtodcID,srvID,nicIDthroughout the file - Simplified error handling by using inline
return diag.FromErr()instead of intermediate variable assignment - Fixed bug in error message at line 228 that referenced wrong variable (
*nic.Id→*createdNic.Id) - Refactored flowlog change detection logic in
ForceNewForFlowlogChangesfor better clarity - Improved error messages (e.g., "lan does not exist" → "nic does not exist" in resourceNicImport)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| diags := diag.FromErr(fmt.Errorf("error occurred while fetching a nic ID %s %w", d.Id(), err)) | ||
| return diags | ||
| return diag.FromErr(fmt.Errorf("error occurred while fetching a nic ID %s %w", nicID, err)) |
There was a problem hiding this comment.
The error message format is inconsistent with common patterns in the codebase. Consider adding a colon before the error wrapper for better readability: "error occurred while fetching a nic ID %s: %w"
| return diag.FromErr(fmt.Errorf("error occurred while fetching a nic ID %s %w", nicID, err)) | |
| return diag.FromErr(fmt.Errorf("error occurred while fetching a nic ID %s: %w", nicID, err)) |
| if err != nil { | ||
| diags := diag.FromErr(fmt.Errorf("an error occurred while deleting a nic dcId %s ID %s %s", d.Get("datacenter_id").(string), d.Id(), err)) | ||
| return diags | ||
| return diag.FromErr(fmt.Errorf("an error occurred while deleting a nic dcID %s ID %s %w", dcID, nicID, err)) |
There was a problem hiding this comment.
The error message format is inconsistent with common patterns in the codebase. Consider adding a colon before the error wrapper for better readability: "an error occurred while deleting a nic dcID %s ID %s: %w"
| return diag.FromErr(fmt.Errorf("an error occurred while deleting a nic dcID %s ID %s %w", dcID, nicID, err)) | |
| return diag.FromErr(fmt.Errorf("an error occurred while deleting a nic dcID %s ID %s: %w", dcID, nicID, err)) |



What does this fix or implement?
Checklist
feat:/fix:/doc:/test:/refactor:)