Terraform search [IPAM] - added implementation for bulkhostnametemplate & vlanview#492
Open
AnilGadiyarHJ wants to merge 20 commits into
Open
Terraform search [IPAM] - added implementation for bulkhostnametemplate & vlanview#492AnilGadiyarHJ wants to merge 20 commits into
AnilGadiyarHJ wants to merge 20 commits into
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/search) support for two IPAM object types—vlanview and bulk_hostname_template—by introducing new list resources and wiring up managed resources with identity schemas so query results can reference stable object identities (ref).
Changes:
- Added list resources for
nios_ipam_vlanviewandnios_ipam_bulk_hostname_templatewith filtering support and pagination. - Added resource identity schema/behavior for VLAN View and Bulk Hostname Template managed resources (identity attribute
ref) and persisted identity during CRUD. - Added acceptance tests plus example/query files and generated documentation for the new list resources.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/service/ipam/vlanview_resource.go | Adds identity schema/behavior and sets identity during CRUD/import for VLAN Views. |
| internal/service/ipam/vlanview_list.go | New list resource implementation for VLAN Views (filters, extattrfilters, include_resource). |
| internal/service/ipam/vlanview_list_test.go | Acceptance tests for VLAN View list queries (basic, filters, extattrfilters). |
| internal/service/ipam/bulkhostnametemplate_resource.go | Adds identity schema/behavior and sets identity during CRUD/import for Bulk Hostname Templates. |
| internal/service/ipam/bulkhostnametemplate_list.go | New list resource implementation for Bulk Hostname Templates (filters/extattrfilters, include_resource). |
| internal/service/ipam/bulkhostnametemplate_list_test.go | Acceptance tests for Bulk Hostname Template list queries (basic, filters). |
| internal/provider/provider.go | Registers the new list resources with the provider. |
| examples/list-resources/nios_ipam_vlanview/list-resource.tfquery.hcl | Example query configurations for VLAN View list resource. |
| examples/list-resources/nios_ipam_bulk_hostname_template/list-resource.tfquery.hcl | Example query configurations for Bulk Hostname Template list resource. |
| docs/list-resources/ipam_vlanview.md | Generated docs for VLAN View list resource. |
| docs/list-resources/ipam_bulk_hostname_template.md | Generated docs for Bulk Hostname Template list resource. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
141
to
145
| 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 create Vlanview due inherited Extensible attributes, got error: %s", err)) | ||
| return |
Comment on lines
465
to
+469
| func (r *VlanviewResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { | ||
| if req.Identity.Raw.IsKnown() { | ||
| diags := req.Identity.GetAttribute(ctx, path.Root("ref"), &req.ID) | ||
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) |
Comment on lines
232
to
235
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) | ||
| resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Error while reading Vlanview due inherited Extensible attributes, got error: %s", diags)) | ||
| return |
Comment on lines
386
to
390
| res.ExtAttrs, data.ExtAttrsAll, diags = RemoveInheritedExtAttrs(ctx, planExtAttrs, *res.ExtAttrs) | ||
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) | ||
| resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Error while update Vlanview due inherited Extensible attributes, got error: %s", diags)) | ||
| return |
Comment on lines
+173
to
+191
| 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 := FlattenVlanview(ctx, &item, &result.Diagnostics) | ||
| result.Diagnostics.Append(result.Resource.Set(ctx, &result1)...) | ||
| if result.Diagnostics.HasError() { | ||
| if !push(result) { | ||
| return | ||
| } | ||
| continue | ||
| } | ||
|
|
Comment on lines
+105
to
+112
| request := l.client.IPAMAPI. | ||
| BulkhostnametemplateAPI. | ||
| List(ctx). | ||
| Filters(flex.ExpandFrameworkMapString(ctx, data.Filters, &diags)). | ||
| ReturnAsObject(1). | ||
| ReturnFieldsPlus(readableAttributesForBulkhostnametemplate). | ||
| Paging(paging). | ||
| MaxResults(maxResultsPerPage) |
Comment on lines
291
to
+295
| func (r *BulkhostnametemplateResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { | ||
| if req.Identity.Raw.IsKnown() { | ||
| diags := req.Identity.GetAttribute(ctx, path.Root("ref"), &req.ID) | ||
| if diags.HasError() { | ||
| resp.Diagnostics.Append(diags...) |
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.