Skip to content

Commit

Permalink
Fix: create twingate-connector with disabled status (#453)
Browse files Browse the repository at this point in the history
* 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 c714b86.

* updated docs

---------

Co-authored-by: Bob Lee <[email protected]>
Co-authored-by: bertekintw <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2024
1 parent 10436ab commit e0c21cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/resources/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions examples/resources/twingate_connector/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions twingate/internal/provider/resource/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions twingate/internal/test/acctests/resource/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
})
}

0 comments on commit e0c21cc

Please sign in to comment.