Handle nameservers as optional field in network (#521)

* make nameservers optional

* fix typo in unit test

* update docs

* Add UseStateForUnkown

---------

Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com>
This commit is contained in:
GokceGK 2024-09-09 10:58:25 +02:00 committed by GitHub
parent aba728487f
commit 4de8552303
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View file

@ -27,12 +27,12 @@ resource "stackit_network" "example" {
### Required
- `name` (String) The name of the network.
- `nameservers` (List of String) The nameservers of the network.
- `project_id` (String) STACKIT project ID to which the network is associated.
### Optional
- `ipv4_prefix_length` (Number) The IPv4 prefix length of the network.
- `nameservers` (List of String) The nameservers of the network.
### Read-Only

View file

@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@ -139,7 +140,11 @@ func (r *networkResource) Schema(_ context.Context, _ resource.SchemaRequest, re
},
"nameservers": schema.ListAttribute{
Description: "The nameservers of the network.",
Required: true,
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
ElementType: types.StringType,
},
"ipv4_prefix_length": schema.Int64Attribute{

View file

@ -78,7 +78,7 @@ func TestMapFields(t *testing.T) {
true,
},
{
"nameservers_changed_outisde_tf",
"nameservers_changed_outside_tf",
Model{
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),