From e0c21ccb8c06401e7c541d143360f99796ba2724 Mon Sep 17 00:00:00 2001 From: Volodymyr Manilo <35466116+vmanilo@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:39:05 +0100 Subject: [PATCH] Fix: create twingate-connector with disabled status (#453) * fix connector creation with disabled status * enabled test * revert ci.yml * update doc with default * fixed spacing * change default to true * generate docs * Revert "generate docs" This reverts commit c714b86379cdcf2f10e5126a9512a58a8146edae. * updated docs --------- Co-authored-by: Bob Lee Co-authored-by: bertekintw <101608051+bertekintw@users.noreply.github.com> --- docs/resources/connector.md | 3 ++- .../resources/twingate_connector/resource.tf | 1 + .../internal/provider/resource/connector.go | 7 ++++--- .../test/acctests/resource/connector_test.go | 20 +++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/resources/connector.md b/docs/resources/connector.md index 8754a145..fcafcc75 100644 --- a/docs/resources/connector.md +++ b/docs/resources/connector.md @@ -24,6 +24,7 @@ resource "twingate_remote_network" "aws_network" { resource "twingate_connector" "aws_connector" { remote_network_id = twingate_remote_network.aws_network.id + status_updates_enabled = true } ``` @@ -37,7 +38,7 @@ resource "twingate_connector" "aws_connector" { ### Optional - `name` (String) Name of the Connector, if not provided one will be generated. -- `status_updates_enabled` (Boolean) Determines whether status notifications are enabled for the Connector. +- `status_updates_enabled` (Boolean) Determines whether status notifications are enabled for the Connector. Default is `true`. ### Read-Only diff --git a/examples/resources/twingate_connector/resource.tf b/examples/resources/twingate_connector/resource.tf index 1fceaed3..49bd461c 100644 --- a/examples/resources/twingate_connector/resource.tf +++ b/examples/resources/twingate_connector/resource.tf @@ -9,4 +9,5 @@ resource "twingate_remote_network" "aws_network" { resource "twingate_connector" "aws_connector" { remote_network_id = twingate_remote_network.aws_network.id + status_updates_enabled = true } \ No newline at end of file diff --git a/twingate/internal/provider/resource/connector.go b/twingate/internal/provider/resource/connector.go index f22f4f95..e9337368 100644 --- a/twingate/internal/provider/resource/connector.go +++ b/twingate/internal/provider/resource/connector.go @@ -91,7 +91,7 @@ func (r *connector) Schema(_ context.Context, _ resource.SchemaRequest, resp *re attr.StatusUpdatesEnabled: schema.BoolAttribute{ Optional: true, Computed: true, - Description: "Determines whether status notifications are enabled for the Connector.", + Description: "Determines whether status notifications are enabled for the Connector. Default is `true`.", }, // computed attr.ID: schema.StringAttribute{ @@ -115,8 +115,9 @@ func (r *connector) Create(ctx context.Context, req resource.CreateRequest, resp } conn, err := r.client.CreateConnector(ctx, &model.Connector{ - Name: plan.Name.ValueString(), - NetworkID: plan.RemoteNetworkID.ValueString(), + Name: plan.Name.ValueString(), + NetworkID: plan.RemoteNetworkID.ValueString(), + StatusUpdatesEnabled: getOptionalBool(plan.StatusUpdatesEnabled), }) r.helper(ctx, conn, &plan, &resp.State, &resp.Diagnostics, err, operationCreate) diff --git a/twingate/internal/test/acctests/resource/connector_test.go b/twingate/internal/test/acctests/resource/connector_test.go index 3b2e1acf..83d3bc91 100644 --- a/twingate/internal/test/acctests/resource/connector_test.go +++ b/twingate/internal/test/acctests/resource/connector_test.go @@ -282,3 +282,23 @@ func terraformResourceTwingateConnectorWithNotificationStatus(terraformRemoteNet } `, terraformResourceRemoteNetwork(terraformRemoteNetworkName, remoteNetworkName), terraformConnectorName, terraformRemoteNetworkName, notificationStatus) } + +func TestAccRemoteConnectorCreateWithNotificationStatusFalse(t *testing.T) { + const terraformResourceName = "test_c8" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, false), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"), + ), + }, + }, + }) +}