From d18731ee10703d802150dc623842da9e19707b41 Mon Sep 17 00:00:00 2001 From: Witold Duranek Date: Wed, 17 Jan 2024 09:07:16 +0100 Subject: [PATCH] feat: add rooms support --- README.md | 34 --- docs/data-sources/room.md | 33 +++ docs/data-sources/space.md | 2 +- docs/resources/room.md | 47 ++++ docs/resources/space.md | 2 +- .../data-sources/netdata_room/data-source.tf | 4 + .../data-sources/netdata_space/data-source.tf | 2 +- examples/resources/netdata_room/import.sh | 3 + examples/resources/netdata_room/resource.tf | 5 + examples/resources/netdata_space/import.sh | 2 +- examples/spaces/main.tf | 14 +- internal/client/models.go | 6 + internal/client/rooms.go | 123 ++++++++++ internal/client/spaces.go | 2 +- internal/provider/provider.go | 2 + internal/provider/room_data_source.go | 105 +++++++++ internal/provider/room_data_source_test.go | 34 +++ internal/provider/room_resource.go | 223 ++++++++++++++++++ internal/provider/room_resource_test.go | 30 +++ internal/provider/space_resource_test.go | 14 -- 20 files changed, 633 insertions(+), 54 deletions(-) create mode 100644 docs/data-sources/room.md create mode 100644 docs/resources/room.md create mode 100644 examples/data-sources/netdata_room/data-source.tf create mode 100644 examples/resources/netdata_room/import.sh create mode 100644 examples/resources/netdata_room/resource.tf create mode 100644 internal/client/rooms.go create mode 100644 internal/provider/room_data_source.go create mode 100644 internal/provider/room_data_source_test.go create mode 100644 internal/provider/room_resource.go create mode 100644 internal/provider/room_resource_test.go diff --git a/README.md b/README.md index aee43a9..52667d9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ This provider allows you to install and manage Netdata Cloud resources using Ter * [Requirements](#requirements) * [Getting Started](#getting-started) -* [Example](#example) ## Requirements @@ -42,36 +41,3 @@ TODO ```console $ make local-build ``` - -## Example - -```hcl -terraform { - required_providers { - netdata = { - # TODO: Update this string with the published name of your provider. - source = "netdata.cloud/todo/netdata" - } - } - required_version = ">= 1.1.0" -} - -provider "netdata" { - url = "https://app.netdata.cloud" - authtoken = "" -} - -resource "netdata_space" "test" { - name = "MyTestingSpace" - description = "Created by Terraform" -} - -data "netdata_space" "test" { - id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1" -} - -output "datasource" { - value = data.netdata_space.test.name -} - -``` diff --git a/docs/data-sources/room.md b/docs/data-sources/room.md new file mode 100644 index 0000000..c48effa --- /dev/null +++ b/docs/data-sources/room.md @@ -0,0 +1,33 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "netdata_room Data Source - terraform-provider-netdata" +subcategory: "" +description: |- + +--- + +# netdata_room (Data Source) + + + +## Example Usage + +```terraform +data "netdata_room" "test" { + spaceid = "" + id = "" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of the room +- `spaceid` (String) The ID of the space + +### Read-Only + +- `description` (String) The description of the room +- `name` (String) The name of the room diff --git a/docs/data-sources/space.md b/docs/data-sources/space.md index 55b7f7b..86bf60f 100644 --- a/docs/data-sources/space.md +++ b/docs/data-sources/space.md @@ -14,7 +14,7 @@ description: |- ```terraform data "netdata_space" "test" { - id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1" + id = "" } ``` diff --git a/docs/resources/room.md b/docs/resources/room.md new file mode 100644 index 0000000..63ff9f1 --- /dev/null +++ b/docs/resources/room.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "netdata_room Resource - terraform-provider-netdata" +subcategory: "" +description: |- + +--- + +# netdata_room (Resource) + + + +## Example Usage + +```terraform +resource "netdata_room" "test" { + spaceid = "" + name = "MyTestingSpace" + description = "Created by Terraform" +} +``` + + +## Schema + +### Required + +- `name` (String) The name of the room +- `spaceid` (String) The ID of the space + +### Optional + +- `description` (String) The description of the room + +### Read-Only + +- `id` (String) The ID of the room + +## Import + +Import is supported using the following syntax: + +```shell +#!/bin/sh + +terraform import netdata_room.test spaceid,roomid +``` diff --git a/docs/resources/space.md b/docs/resources/space.md index 74ae55e..240b971 100644 --- a/docs/resources/space.md +++ b/docs/resources/space.md @@ -41,5 +41,5 @@ Import is supported using the following syntax: ```shell #!/bin/sh -terraform import netdata_space.test ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1 +terraform import netdata_space.test spaceid ``` diff --git a/examples/data-sources/netdata_room/data-source.tf b/examples/data-sources/netdata_room/data-source.tf new file mode 100644 index 0000000..3ce473f --- /dev/null +++ b/examples/data-sources/netdata_room/data-source.tf @@ -0,0 +1,4 @@ +data "netdata_room" "test" { + spaceid = "" + id = "" +} diff --git a/examples/data-sources/netdata_space/data-source.tf b/examples/data-sources/netdata_space/data-source.tf index 8776bdb..368877d 100644 --- a/examples/data-sources/netdata_space/data-source.tf +++ b/examples/data-sources/netdata_space/data-source.tf @@ -1,3 +1,3 @@ data "netdata_space" "test" { - id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1" + id = "" } diff --git a/examples/resources/netdata_room/import.sh b/examples/resources/netdata_room/import.sh new file mode 100644 index 0000000..c225151 --- /dev/null +++ b/examples/resources/netdata_room/import.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +terraform import netdata_room.test spaceid,roomid diff --git a/examples/resources/netdata_room/resource.tf b/examples/resources/netdata_room/resource.tf new file mode 100644 index 0000000..536b06a --- /dev/null +++ b/examples/resources/netdata_room/resource.tf @@ -0,0 +1,5 @@ +resource "netdata_room" "test" { + spaceid = "" + name = "MyTestingSpace" + description = "Created by Terraform" +} diff --git a/examples/resources/netdata_space/import.sh b/examples/resources/netdata_space/import.sh index 389bb77..520f0c6 100644 --- a/examples/resources/netdata_space/import.sh +++ b/examples/resources/netdata_space/import.sh @@ -1,3 +1,3 @@ #!/bin/sh -terraform import netdata_space.test ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1 +terraform import netdata_space.test spaceid diff --git a/examples/spaces/main.tf b/examples/spaces/main.tf index 1ed65c6..22641c7 100644 --- a/examples/spaces/main.tf +++ b/examples/spaces/main.tf @@ -1,6 +1,7 @@ terraform { required_providers { netdata = { + # TODO: Update this string with the published name of your provider. source = "netdata.cloud/todo/netdata" } } @@ -17,8 +18,19 @@ resource "netdata_space" "test" { description = "Created by Terraform" } +resource "netdata_room" "test" { + spaceid = netdata_space.test.id + name = "MyTestingRoom" + description = "Created by Terraform2" +} + data "netdata_space" "test" { - id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1" + id = netdata_space.test.id +} + +data "netdata_room" "test" { + id = netdata_room.test.id + spaceid = netdata_space.test.id } output "datasource" { diff --git a/internal/client/models.go b/internal/client/models.go index ff5c3f9..654b2a1 100644 --- a/internal/client/models.go +++ b/internal/client/models.go @@ -5,3 +5,9 @@ type SpaceInfo struct { Name string `json:"name"` Description string `json:"description"` } + +type RoomInfo struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` +} diff --git a/internal/client/rooms.go b/internal/client/rooms.go new file mode 100644 index 0000000..7afc167 --- /dev/null +++ b/internal/client/rooms.go @@ -0,0 +1,123 @@ +package client + +import ( + "encoding/json" + "fmt" + "net/http" + "strings" +) + +func (c *Client) GetRooms(spaceid string) (*[]RoomInfo, error) { + if spaceid == "" { + return nil, fmt.Errorf("spaceid is empty") + } + req, err := http.NewRequest("GET", fmt.Sprintf("%s/api/v2/spaces/%s/rooms", c.HostURL, spaceid), nil) + if err != nil { + return nil, err + } + + body, err := c.doRequest(req) + if err != nil { + return nil, err + } + + var rooms []RoomInfo + err = json.Unmarshal(body, &rooms) + if err != nil { + return nil, err + } + + return &rooms, nil +} + +func (c *Client) GetRoomByID(id, spaceid string) (*RoomInfo, error) { + rooms, err := c.GetRooms(spaceid) + if err != nil { + return nil, err + } + for _, room := range *rooms { + if room.ID == id { + return &room, nil + } + } + return nil, ErrNotFound +} + +func (c *Client) CreateRoom(spaceid, name, description string) (*RoomInfo, error) { + if spaceid == "" { + return nil, fmt.Errorf("spaceid is empty") + } + reqBody, err := json.Marshal(map[string]string{ + "name": name, + "description": description, + }) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", fmt.Sprintf("%s/api/v1/spaces/%s/rooms", c.HostURL, spaceid), strings.NewReader(string(reqBody))) + if err != nil { + return nil, err + } + + respBody, err := c.doRequest(req) + if err != nil { + return nil, err + } + + var room RoomInfo + err = json.Unmarshal(respBody, &room) + if err != nil { + return nil, err + } + + room.Name = name + room.Description = description + + return &room, nil +} + +func (c *Client) UpdateRoomByID(id, spaceid, name, description string) error { + if id == "" { + return fmt.Errorf("id is empty") + } + if spaceid == "" { + return fmt.Errorf("spaceid is empty") + } + reqBody, err := json.Marshal(map[string]string{ + "name": name, + "description": description, + }) + if err != nil { + return err + } + req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/api/v1/spaces/%s/rooms/%s", c.HostURL, spaceid, id), strings.NewReader(string(reqBody))) + if err != nil { + return err + } + _, err = c.doRequest(req) + if err != nil { + return err + } + return nil +} + +func (c *Client) DeleteRoomByID(id, spaceid string) error { + if id == "" { + return fmt.Errorf("id is empty") + } + if spaceid == "" { + return fmt.Errorf("spaceid is empty") + } + req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/api/v1/spaces/%s/rooms/%s", c.HostURL, spaceid, id), nil) + if err != nil { + return err + } + + _, err = c.doRequest(req) + if err != nil { + return err + } + + return nil +} diff --git a/internal/client/spaces.go b/internal/client/spaces.go index 86b4181..75c9bce 100644 --- a/internal/client/spaces.go +++ b/internal/client/spaces.go @@ -85,7 +85,7 @@ func (c *Client) UpdateSpaceByID(id, name, description string) error { } req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/api/v1/spaces/%s", c.HostURL, id), strings.NewReader(string(reqBody))) if err != nil { - return fmt.Errorf("req %+v", req) + return err } _, err = c.doRequest(req) if err != nil { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e36a3ba..1a991e3 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -88,12 +88,14 @@ func (p *netdataCloudProvider) Configure(ctx context.Context, req provider.Confi func (p *netdataCloudProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ NewSpaceResource, + NewRoomResource, } } func (p *netdataCloudProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ NewSpaceDataSource, + NewRoomDataSource, } } diff --git a/internal/provider/room_data_source.go b/internal/provider/room_data_source.go new file mode 100644 index 0000000..804e4f7 --- /dev/null +++ b/internal/provider/room_data_source.go @@ -0,0 +1,105 @@ +package provider + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/netdata/terraform-provider-netdata/internal/client" +) + +var ( + _ datasource.DataSource = &roomDataSource{} + _ datasource.DataSourceWithConfigure = &roomDataSource{} +) + +func NewRoomDataSource() datasource.DataSource { + return &roomDataSource{} +} + +type roomDataSource struct { + client *client.Client +} + +type roomDataSourceModel struct { + ID types.String `tfsdk:"id"` + SpaceID types.String `tfsdk:"spaceid"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` +} + +func (s *roomDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_room" +} + +func (s *roomDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "The ID of the room", + Required: true, + }, + "spaceid": schema.StringAttribute{ + Description: "The ID of the space", + Required: true, + }, + "name": schema.StringAttribute{ + Description: "The name of the room", + Computed: true, + }, + "description": schema.StringAttribute{ + Description: "The description of the room", + Computed: true, + }, + }, + } +} + +func (s *roomDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + s.client = client +} + +func (s *roomDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state roomDataSourceModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) + + roomInfo, err := s.client.GetRoomByID(state.ID.ValueString(), state.SpaceID.ValueString()) + + switch { + case err == client.ErrNotFound: + resp.State.RemoveResource(ctx) + return + case err != nil: + resp.Diagnostics.AddError( + "Error Getting Room", + "Could Not Read Room ID: "+state.ID.ValueString()+": err: "+err.Error(), + ) + return + default: + state.ID = types.StringValue(roomInfo.ID) + state.Name = types.StringValue(roomInfo.Name) + state.Description = types.StringValue(roomInfo.Description) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + } +} diff --git a/internal/provider/room_data_source_test.go b/internal/provider/room_data_source_test.go new file mode 100644 index 0000000..6ef649f --- /dev/null +++ b/internal/provider/room_data_source_test.go @@ -0,0 +1,34 @@ +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccRoomDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: ` + resource "netdata_space" "test" { + name = "testAcc" + } + resource "netdata_room" "test" { + spaceid = netdata_space.test.id + name = "testAcc" + } + data "netdata_room" "test" { + spaceid = netdata_space.test.id + id = netdata_room.test.id + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.netdata_room.test", "name", "testAcc"), + ), + }, + }, + }, + ) +} diff --git a/internal/provider/room_resource.go b/internal/provider/room_resource.go new file mode 100644 index 0000000..9313a17 --- /dev/null +++ b/internal/provider/room_resource.go @@ -0,0 +1,223 @@ +package provider + +import ( + "context" + "fmt" + "strings" + + "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/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/netdata/terraform-provider-netdata/internal/client" +) + +var ( + _ resource.Resource = &roomResource{} + _ resource.ResourceWithConfigure = &roomResource{} +) + +func NewRoomResource() resource.Resource { + return &roomResource{} +} + +type roomResource struct { + client *client.Client +} + +type roomResourceModel struct { + ID types.String `tfsdk:"id"` + SpaceID types.String `tfsdk:"spaceid"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` +} + +func (s *roomResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_room" +} + +func (s *roomResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "The ID of the room", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "spaceid": schema.StringAttribute{ + Description: "The ID of the space", + Required: true, + }, + "name": schema.StringAttribute{ + Description: "The name of the room", + Required: true, + }, + "description": schema.StringAttribute{ + Description: "The description of the room", + Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), + }, + }, + } +} + +func (s *roomResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + s.client = client +} + +func (s *roomResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan roomResourceModel + + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + if resp.Diagnostics.HasError() { + return + } + + roomInfo, err := s.client.CreateRoom(plan.SpaceID.ValueString(), plan.Name.ValueString(), plan.Description.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error Creating Room", + "err: "+err.Error(), + ) + return + } + + plan.ID = types.StringValue(roomInfo.ID) + plan.Name = types.StringValue(roomInfo.Name) + plan.Description = types.StringValue(roomInfo.Description) + + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +func (s *roomResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state roomResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + roomInfo, err := s.client.GetRoomByID(state.ID.ValueString(), state.SpaceID.ValueString()) + + switch { + case err == client.ErrNotFound: + resp.State.RemoveResource(ctx) + return + case err != nil: + resp.Diagnostics.AddError( + "Error Getting Room", + "Could Not Read Room ID: "+state.ID.ValueString()+": err: "+err.Error(), + ) + return + default: + state.ID = types.StringValue(roomInfo.ID) + state.Name = types.StringValue(roomInfo.Name) + state.Description = types.StringValue(roomInfo.Description) + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + } +} + +func (s *roomResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan roomResourceModel + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + err := s.client.UpdateRoomByID(plan.ID.ValueString(), plan.SpaceID.ValueString(), plan.Name.ValueString(), plan.Description.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error Updating room", + "Could Not Update Room ID: "+plan.ID.ValueString()+": err: "+err.Error(), + ) + return + } + + roomInfo, err := s.client.GetRoomByID(plan.ID.ValueString(), plan.SpaceID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error Getting Room", + "Could Not Read Room ID: "+plan.ID.ValueString()+": err: "+err.Error(), + ) + return + } + + plan.ID = types.StringValue(roomInfo.ID) + plan.Name = types.StringValue(roomInfo.Name) + plan.Description = types.StringValue(roomInfo.Description) + + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + +} + +func (s *roomResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state roomResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + err := s.client.DeleteRoomByID(state.ID.ValueString(), state.SpaceID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error Deleting Room", + "Could Not Delete Room ID: "+state.ID.ValueString()+": err: "+err.Error(), + ) + return + } +} + +func (s *roomResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + idParts := strings.Split(req.ID, ",") + + if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" { + resp.Diagnostics.AddError( + "Unexpected Import Identifier", + fmt.Sprintf("Expected import identifier with format: spaceid,id. Got: %q", req.ID), + ) + return + } + + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("spaceid"), idParts[0])...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), idParts[1])...) +} diff --git a/internal/provider/room_resource_test.go b/internal/provider/room_resource_test.go new file mode 100644 index 0000000..6eccf28 --- /dev/null +++ b/internal/provider/room_resource_test.go @@ -0,0 +1,30 @@ +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccRoomResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: ` + resource "netdata_space" "test" { + name = "testAcc" + } + resource "netdata_room" "test" { + spaceid = netdata_space.test.id + name = "testAcc" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("netdata_room.test", "name", "testAcc"), + resource.TestCheckResourceAttr("netdata_room.test", "description", ""), + ), + }, + }, + }) +} diff --git a/internal/provider/space_resource_test.go b/internal/provider/space_resource_test.go index e012914..98356b6 100644 --- a/internal/provider/space_resource_test.go +++ b/internal/provider/space_resource_test.go @@ -10,7 +10,6 @@ func TestAccSpaceResource(t *testing.T) { resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Create and Read testing { Config: `resource "netdata_space" "test" { name = "testAcc" }`, Check: resource.ComposeAggregateTestCheckFunc( @@ -18,19 +17,6 @@ func TestAccSpaceResource(t *testing.T) { resource.TestCheckResourceAttr("netdata_space.test", "description", ""), ), }, - // Update and Read testing - { - Config: ` - resource "netdata_space" "test" { - name = "testAccUpdated" - description ="testDesc" - } - `, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("netdata_space.test", "name", "testAccUpdated"), - resource.TestCheckResourceAttr("netdata_space.test", "description", "testDesc"), - ), - }, }, }) }