Skip to content

Commit 6abdd35

Browse files
Added workspaces secured, general cleanup
1 parent 49d4a3a commit 6abdd35

4 files changed

+17
-28
lines changed

internal/provider/data_source_hyok_customer_key_version.go

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/hashicorp/terraform-plugin-framework/datasource"
1010
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1111
"github.com/hashicorp/terraform-plugin-framework/types"
12-
"log"
1312
"time"
1413
)
1514

@@ -27,13 +26,12 @@ type dataSourceHYOKCustomerKeyVersion struct {
2726
}
2827

2928
type HYOKCustomerKeyVersionDataSourceModel struct {
30-
ID types.String `tfsdk:"id"`
31-
Status types.String `tfsdk:"status"`
32-
Error types.String `tfsdk:"error"`
33-
KeyVersion types.String `tfsdk:"key_version"`
34-
CreatedAt types.String `tfsdk:"created_at"`
35-
UpdatedAt types.String `tfsdk:"updated_at"`
36-
RevokedAt types.String `tfsdk:"revoked_at"`
29+
ID types.String `tfsdk:"id"`
30+
Status types.String `tfsdk:"status"`
31+
Error types.String `tfsdk:"error"`
32+
KeyVersion types.String `tfsdk:"key_version"`
33+
CreatedAt types.String `tfsdk:"created_at"`
34+
WorkspacesSecured types.Int64 `tfsdk:"workspaces_secured"`
3735
}
3836

3937
func (d *dataSourceHYOKCustomerKeyVersion) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
@@ -74,19 +72,15 @@ func (d *dataSourceHYOKCustomerKeyVersion) Schema(ctx context.Context, req datas
7472
Computed: true,
7573
},
7674
"key_version": schema.StringAttribute{
77-
Description: "The version number of the customer key.",
75+
Description: "The version number of the customer key version.",
7876
Computed: true,
7977
},
80-
"created_at": schema.StringAttribute{
81-
Description: "The timestamp when the key version was created.",
82-
Computed: true,
83-
},
84-
"updated_at": schema.StringAttribute{
85-
Description: "The timestamp when the key version was last updated.",
78+
"workspaces_secured": schema.Int64Attribute{
79+
Description: "The number workspaces secured by this customer key version.",
8680
Computed: true,
8781
},
88-
"revoked_at": schema.StringAttribute{
89-
Description: "The timestamp when the key version was revoked, if applicable.",
82+
"created_at": schema.StringAttribute{
83+
Description: "The timestamp when the key version was created.",
9084
Computed: true,
9185
},
9286
},
@@ -102,8 +96,6 @@ func (d *dataSourceHYOKCustomerKeyVersion) Read(ctx context.Context, req datasou
10296
return
10397
}
10498

105-
log.Printf("[DEBUG] Reading HYOK customer key version: %s", data.ID.ValueString())
106-
10799
// Make API call to fetch the HYOK customer key version
108100
keyVersion, err := d.config.Client.HYOKCustomerKeyVersions.Read(ctx, data.ID.ValueString())
109101
if err != nil {
@@ -114,9 +106,8 @@ func (d *dataSourceHYOKCustomerKeyVersion) Read(ctx context.Context, req datasou
114106
// Set the computed attributes from the API response
115107
data.Status = types.StringValue(string(keyVersion.Status))
116108
data.KeyVersion = types.StringValue(keyVersion.KeyVersion)
117-
data.CreatedAt = types.StringValue(keyVersion.CreatedAt.Format(time.RFC3339)) // TODO DOM: Check this format
118-
data.UpdatedAt = types.StringValue(keyVersion.UpdatedAt.Format(time.RFC3339)) // TODO DOM: Check this format
119-
data.RevokedAt = types.StringValue(keyVersion.RevokedAt.Format(time.RFC3339)) // TODO DOM: Check this format
109+
data.CreatedAt = types.StringValue(keyVersion.CreatedAt.Format(time.RFC3339))
110+
data.WorkspacesSecured = types.Int64Value(int64(keyVersion.WorkspacesSecured))
120111
data.Error = types.StringValue(keyVersion.Error)
121112

122113
// Save data into Terraform state

internal/provider/data_source_hyok_customer_key_version_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func TestAccTFEHYOKCustomerKeyVersionDataSource_basic(t *testing.T) {
1616
}
1717

1818
resource.Test(t, resource.TestCase{
19-
PreCheck: func() { testAccPreCheck(t) },
20-
ProtoV5ProviderFactories: testAccMuxedProviders,
19+
PreCheck: func() { testAccPreCheck(t) },
2120
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
2221
"echo": echoprovider.NewProviderServer(),
2322
},
@@ -29,7 +28,7 @@ func TestAccTFEHYOKCustomerKeyVersionDataSource_basic(t *testing.T) {
2928
resource.TestCheckResourceAttrSet("data.tfe_hyok_customer_key_version.test", "status"),
3029
resource.TestCheckResourceAttrSet("data.tfe_hyok_customer_key_version.test", "key_version"),
3130
resource.TestCheckResourceAttrSet("data.tfe_hyok_customer_key_version.test", "created_at"),
32-
resource.TestCheckResourceAttrSet("data.tfe_hyok_customer_key_version.test", "updated_at"),
31+
resource.TestCheckResourceAttrSet("data.tfe_hyok_customer_key_version.test", "workspaces_secured"),
3332
),
3433
},
3534
},

internal/provider/data_source_hyok_encrypted_data_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (d *dataSourceHYOKEncryptedDataKey) Read(ctx context.Context, req datasourc
9494
}
9595

9696
// Set the computed attributes from the API response
97-
data.EncryptedDEK = types.StringValue(string(keyVersion.EncryptedDEK))
97+
data.EncryptedDEK = types.StringValue(keyVersion.EncryptedDEK)
9898
data.CustomerKeyName = types.StringValue(keyVersion.CustomerKeyName)
9999
data.CreatedAt = types.StringValue(keyVersion.CreatedAt.Format(time.RFC3339)) // TODO DOM: Check this format
100100

internal/provider/data_source_hyok_encrypted_data_key_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func TestAccTFEHYOKEncryptedDataKeyDataSource_basic(t *testing.T) {
1616
}
1717

1818
resource.Test(t, resource.TestCase{
19-
PreCheck: func() { testAccPreCheck(t) },
20-
ProtoV5ProviderFactories: testAccMuxedProviders,
19+
PreCheck: func() { testAccPreCheck(t) },
2120
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
2221
"echo": echoprovider.NewProviderServer(),
2322
},

0 commit comments

Comments
 (0)