Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/go.temporal.io/sdk-1.30.1
Browse files Browse the repository at this point in the history
  • Loading branch information
briankassouf authored Dec 3, 2024
2 parents 7b33b55 + 7ccb9e8 commit 2c2cdaa
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
13 changes: 0 additions & 13 deletions docs/resources/apikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,3 @@ Optional:

- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.

## Import

Import is supported using the following syntax:

```shell
# API Keys can be imported to incorporate existing API Keys into your Terraform pipeline.
# To import an API Key, you need
# - a resource configuration in your Terraform configuration file/module to accept the imported API Key. In the example below, the placeholder is "temporalcloud_apikey" "tfapikey"
# - the API Key's ID, which is found when clicking into an API Key in the Temporal Cloud UI. In the example below, this is zJV5zQ3IhsAbw75dAkVNEMsAd3a5AemC

terraform import temporalcloud_apikey.tfapikey zJV5zQ3IhsAbw75dAkVNEMsAd3a5AemC
```
6 changes: 0 additions & 6 deletions examples/resources/temporalcloud_apikey/import.sh

This file was deleted.

11 changes: 3 additions & 8 deletions internal/provider/apikey_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
"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"
Expand Down Expand Up @@ -39,9 +38,8 @@ type (
)

var (
_ resource.Resource = (*apiKeyResource)(nil)
_ resource.ResourceWithConfigure = (*apiKeyResource)(nil)
_ resource.ResourceWithImportState = (*apiKeyResource)(nil)
_ resource.Resource = (*apiKeyResource)(nil)
_ resource.ResourceWithConfigure = (*apiKeyResource)(nil)
)

func NewApiKeyResource() resource.Resource {
Expand Down Expand Up @@ -357,10 +355,6 @@ func (r *apiKeyResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
}

func (r *apiKeyResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
}

func updateApiKeyModelFromSpec(state *apiKeyResourceModel, apikey *identityv1.ApiKey) error {
state.ID = types.StringValue(apikey.GetId())
stateStr, err := enums.FromResourceState(apikey.GetState())
Expand All @@ -379,5 +373,6 @@ func updateApiKeyModelFromSpec(state *apiKeyResourceModel, apikey *identityv1.Ap
state.Description = types.StringValue(apikey.GetSpec().GetDescription())
}
state.ExpiryTime = types.StringValue(apikey.GetSpec().GetExpiryTime().AsTime().Format(time.RFC3339))

return nil
}
20 changes: 20 additions & 0 deletions internal/provider/namespace_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ PEM
{
Config: config(name, 14),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_namespace.terraform",
},
// Delete testing automatically occurs in TestCase
},
})
Expand Down Expand Up @@ -118,6 +123,11 @@ resource "temporalcloud_namespace" "terraform" {
{
Config: config(name, 14),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_namespace.terraform",
},
// Delete testing automatically occurs in TestCase
},
})
Expand Down Expand Up @@ -174,6 +184,11 @@ PEM
{
Config: config(name, 14),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_namespace.test",
},
// Delete testing automatically occurs in TestCase
},
})
Expand Down Expand Up @@ -307,6 +322,11 @@ PEM
return nil
},
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_namespace.test",
},
{
// remove codec server
Config: config(configArgs{
Expand Down
20 changes: 15 additions & 5 deletions internal/provider/service_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ resource "temporalcloud_service_account" "terraform" {
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: config(name, "Read"),
Config: config(name, "read"),
},
{
Config: config(name, "Developer"),
Config: config(name, "developer"),
},
{
Config: config(name, "Admin"),
Config: config(name, "admin"),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_service_account.terraform",
},
},
})
Expand Down Expand Up @@ -149,8 +154,8 @@ resource "temporalcloud_service_account" "terraform" {
Config: config(configArgs{
Name: name,
NamespaceName: randomString(),
NamespacePerm: "Write",
AccountPerm: "Read",
NamespacePerm: "write",
AccountPerm: "read",
}),
Check: func(state *terraform.State) error {
id := state.RootModule().Resources["temporalcloud_service_account.terraform"].Primary.Attributes["id"]
Expand Down Expand Up @@ -182,6 +187,11 @@ resource "temporalcloud_service_account" "terraform" {
return nil
},
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_service_account.terraform",
},
},
})
}
Expand Down
20 changes: 15 additions & 5 deletions internal/provider/user_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,18 @@ resource "temporalcloud_user" "terraform" {
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: config(emailAddr, "Read"),
Config: config(emailAddr, "read"),
},
{
Config: config(emailAddr, "Developer"),
Config: config(emailAddr, "developer"),
},
{
Config: config(emailAddr, "Admin"),
Config: config(emailAddr, "admin"),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_user.terraform",
},
},
})
Expand Down Expand Up @@ -154,8 +159,8 @@ resource "temporalcloud_user" "terraform" {
Config: config(configArgs{
Email: emailAddr,
NamespaceName: randomString(),
NamespacePerm: "Write",
AccountPerm: "Read",
NamespacePerm: "write",
AccountPerm: "read",
}),
Check: func(state *terraform.State) error {
id := state.RootModule().Resources["temporalcloud_user.terraform"].Primary.Attributes["id"]
Expand Down Expand Up @@ -187,6 +192,11 @@ resource "temporalcloud_user" "terraform" {
return nil
},
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "temporalcloud_user.terraform",
},
},
})
}
Expand Down

0 comments on commit 2c2cdaa

Please sign in to comment.