Skip to content

Commit f1f8414

Browse files
committed
feat(objectstorage): Min/Max acceptance tests
Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
1 parent ab7245c commit f1f8414

18 files changed

Lines changed: 191 additions & 134 deletions

docs/data-sources/objectstorage_bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ data "stackit_objectstorage_bucket" "example" {
3333

3434
### Read-Only
3535

36-
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`name`".
36+
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`region`,`name`".
3737
- `url_path_style` (String)
3838
- `url_virtual_hosted_style` (String)

docs/data-sources/objectstorage_credential.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ data "stackit_objectstorage_credential" "example" {
3636
### Read-Only
3737

3838
- `expiration_timestamp` (String)
39-
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`credentials_group_id`,`credential_id`".
39+
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`credentials_group_id`,`credential_id`".
4040
- `name` (String)

docs/data-sources/objectstorage_credentials_group.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ data "stackit_objectstorage_credentials_group" "example" {
2424

2525
### Required
2626

27+
- `credentials_group_id` (String) The credentials group ID.
2728
- `project_id` (String) Object Storage Project ID to which the credentials group is associated.
2829

2930
### Optional
3031

31-
- `credentials_group_id` (String) The credentials group ID.
32-
- `name` (String) The credentials group's display name.
3332
- `region` (String) The resource region. If not defined, the provider region is used.
3433

3534
### Read-Only
3635

37-
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`credentials_group_id`".
36+
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`region`,`credentials_group_id`".
37+
- `name` (String) The credentials group's display name.
3838
- `urn` (String) Credentials group uniform resource name (URN)

docs/resources/objectstorage_bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ resource "stackit_objectstorage_bucket" "example" {
3333

3434
### Read-Only
3535

36-
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`name`".
36+
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`name`".
3737
- `url_path_style` (String)
3838
- `url_virtual_hosted_style` (String)

docs/resources/objectstorage_credential.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ resource "stackit_objectstorage_credential" "example" {
3737

3838
- `access_key` (String)
3939
- `credential_id` (String) The credential ID.
40-
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`credentials_group_id`,`credential_id`".
40+
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`credentials_group_id`,`credential_id`".
4141
- `name` (String)
4242
- `secret_access_key` (String, Sensitive)

docs/resources/objectstorage_credentials_group.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ resource "stackit_objectstorage_credentials_group" "example" {
3434
### Read-Only
3535

3636
- `credentials_group_id` (String) The credentials group ID
37-
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`credentials_group_id`".
37+
- `id` (String) Terraform's internal data source identifier. It is structured as "`project_id`,`region`,`credentials_group_id`".
3838
- `urn` (String) Credentials group uniform resource name (URN)

stackit/internal/services/objectstorage/bucket/datasource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (r *bucketDataSource) Configure(ctx context.Context, req datasource.Configu
6060
func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
6161
descriptions := map[string]string{
6262
"main": "ObjectStorage bucket data source schema. Must have a `region` specified in the provider configuration.",
63-
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`name`\".",
63+
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`region`,`name`\".",
6464
"name": "The bucket name. It must be DNS conform.",
6565
"project_id": "STACKIT Project ID to which the bucket is associated.",
6666
"url_path_style": "URL in path style.",

stackit/internal/services/objectstorage/bucket/resource.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (r *bucketResource) Configure(ctx context.Context, req resource.ConfigureRe
109109
func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
110110
descriptions := map[string]string{
111111
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.",
112-
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`name`\".",
112+
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`name`\".",
113113
"name": "The bucket name. It must be DNS conform.",
114114
"project_id": "STACKIT Project ID to which the bucket is associated.",
115115
"url_path_style": "URL in path style.",
@@ -304,16 +304,17 @@ func (r *bucketResource) Delete(ctx context.Context, req resource.DeleteRequest,
304304
// The expected format of the resource import identifier is: project_id,name
305305
func (r *bucketResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
306306
idParts := strings.Split(req.ID, core.Separator)
307-
if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" {
307+
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
308308
core.LogAndAddError(ctx, &resp.Diagnostics,
309309
"Error importing bucket",
310-
fmt.Sprintf("Expected import identifier with format [project_id],[name], got %q", req.ID),
310+
fmt.Sprintf("Expected import identifier with format [project_id],[region],[name], got %q", req.ID),
311311
)
312312
return
313313
}
314314

315315
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
316-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[1])...)
316+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...)
317+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[2])...)
317318
tflog.Info(ctx, "ObjectStorage bucket state imported")
318319
}
319320

@@ -331,6 +332,7 @@ func mapFields(bucketResp *objectstorage.GetBucketResponse, model *Model, region
331332

332333
idParts := []string{
333334
model.ProjectId.ValueString(),
335+
region,
334336
model.Name.ValueString(),
335337
}
336338
model.Id = types.StringValue(

stackit/internal/services/objectstorage/bucket/resource_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, proj
2727
}
2828

2929
func TestMapFields(t *testing.T) {
30+
const testRegion = "eu01"
31+
id := fmt.Sprintf("%s,%s,%s", "pid", testRegion, "bname")
3032
tests := []struct {
3133
description string
3234
input *objectstorage.GetBucketResponse
@@ -39,7 +41,7 @@ func TestMapFields(t *testing.T) {
3941
Bucket: &objectstorage.Bucket{},
4042
},
4143
Model{
42-
Id: types.StringValue("pid,bname"),
44+
Id: types.StringValue(id),
4345
Name: types.StringValue("bname"),
4446
ProjectId: types.StringValue("pid"),
4547
URLPathStyle: types.StringNull(),
@@ -57,7 +59,7 @@ func TestMapFields(t *testing.T) {
5759
},
5860
},
5961
Model{
60-
Id: types.StringValue("pid,bname"),
62+
Id: types.StringValue(id),
6163
Name: types.StringValue("bname"),
6264
ProjectId: types.StringValue("pid"),
6365
URLPathStyle: types.StringValue("url/path/style"),
@@ -75,7 +77,7 @@ func TestMapFields(t *testing.T) {
7577
},
7678
},
7779
Model{
78-
Id: types.StringValue("pid,bname"),
80+
Id: types.StringValue(id),
7981
Name: types.StringValue("bname"),
8082
ProjectId: types.StringValue("pid"),
8183
URLPathStyle: types.StringValue(""),

stackit/internal/services/objectstorage/credential/datasource.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
7171
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
7272
descriptions := map[string]string{
7373
"main": "ObjectStorage credential data source schema. Must have a `region` specified in the provider configuration.",
74-
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`credentials_group_id`,`credential_id`\".",
74+
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`credentials_group_id`,`credential_id`\".",
7575
"credential_id": "The credential ID.",
7676
"credentials_group_id": "The credential group ID.",
7777
"project_id": "STACKIT Project ID to which the credential group is associated.",
@@ -208,6 +208,7 @@ func mapDataSourceFields(credentialResp *objectstorage.AccessKey, model *DataSou
208208

209209
idParts := []string{
210210
model.ProjectId.ValueString(),
211+
region,
211212
model.CredentialsGroupId.ValueString(),
212213
credentialId,
213214
}

0 commit comments

Comments
 (0)