Terraform search integration in ipam List resource #502
Open
AnilGadiyarHJ wants to merge 19 commits into
Open
Conversation
…nios into list_record_a
…s into list_record_a
…s into list_record_a
…s into list_record_a
…s into list_record_a
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Terraform list/query support for IPAM VLANs and aligns the existing VLAN resource with Terraform’s identity-based querying/import behavior.
Changes:
- Added
nios_ipam_vlanList Resource implementation with filter and extensible-attribute filter support, plus optionalinclude_resource. - Added resource identity schema support to the existing
nios_ipam_vlanresource and wired identity handling into CRUD + import. - Registered the new list resource in the provider and added acceptance tests + docs/examples.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/service/ipam/vlan_resource.go | Adds resource identity schema/behavior and sets identity during CRUD/import. |
| internal/service/ipam/vlan_list.go | Implements the VLAN list/query resource with paging, filters, and optional full resource inclusion. |
| internal/service/ipam/vlan_list_test.go | Adds acceptance tests for VLAN list resource basic and filtered queries. |
| internal/provider/provider.go | Registers the new VLAN list resource with the provider. |
| examples/list-resources/nios_ipam_vlan/list-resource.tfquery.hcl | Adds example queries for VLAN list usage (filters, EA filters, include_resource). |
| docs/list-resources/ipam_vlan.md | Adds generated documentation for the VLAN list resource. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+96
to
+100
| // If total limit is set by user and is less than maxResultsPerPage, use it as maxResultsPerPage for API call to optimize the number of results. | ||
| // If limit > maxResultsPerPage, terraform automatically breaks connection to the provider after limit is reached. | ||
| if limit < maxResultsPerPage { | ||
| maxResultsPerPage = limit | ||
| } |
Comment on lines
+133
to
+138
| // If limit is reached , we do not need to continue to make API calls, we can return the results and empty nextPageID to stop pagination. | ||
| if len(res) >= int(limit) { | ||
| nextPageID = "" | ||
| tflog.Info(ctx, "Limit reached, stopped fetching more pages.") | ||
| return res, nextPageID, nil | ||
| } |
Comment on lines
+173
to
+190
| if req.IncludeResource { | ||
| var extAttrsAll types.Map | ||
| item.ExtAttrs, extAttrsAll, diags = RemoveInheritedExtAttrs(ctx, extAttrsAll, *item.ExtAttrs) | ||
| result.Diagnostics.Append(result.Resource.SetAttribute(ctx, path.Root("extattrs_all"), extAttrsAll)...) | ||
| if result.Diagnostics.HasError() { | ||
| if !push(result) { | ||
| return | ||
| } | ||
| continue | ||
| } | ||
| result1 := FlattenVlan(ctx, &item, &result.Diagnostics) | ||
| result.Diagnostics.Append(result.Resource.Set(ctx, &result1)...) | ||
| if result.Diagnostics.HasError() { | ||
| if !push(result) { | ||
| return | ||
| } | ||
| continue | ||
| } |
Comment on lines
141
to
144
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) | ||
| resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Error while create Vlan due inherited Extensible attributes, got error: %s", err)) | ||
| return |
Comment on lines
228
to
232
| res.ExtAttrs, data.ExtAttrsAll, diags = RemoveInheritedExtAttrs(ctx, data.ExtAttrs, *res.ExtAttrs) | ||
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) | ||
| resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Error while reading Vlan due inherited Extensible attributes, got error: %s", diags)) | ||
| return |
Comment on lines
+71
to
+75
| "extattrfilters": schema.MapAttribute{ | ||
| MarkdownDescription: "External Attribute Filters are used to return a more specific list of results by filtering on external attributes. If you specify multiple filters, the results returned will have only resources that match all the specified filters.", | ||
| ElementType: types.StringType, | ||
| Optional: true, | ||
| }, |
Comment on lines
+48
to
+49
| - `extattrfilters` (Map of String) External Attribute Filters are used to return a more specific list of results by filtering on external attributes. If you specify multiple filters, the results returned will have only resources that match all the specified filters. | ||
| - `filters` (Map of String) Filters are used to return a more specific list of results. Filters can be used to match resources by specific attributes, e.g. name. If you specify multiple filters, the results returned will have only resources that match all the specified filters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.