Skip to content

Commit 3e8dcc5

Browse files
authored
fix: make resource/data-source specific region attribute read-only (#682)
* fix: make resource/data-source specific region attribute read-only * fix: implemented review feedback
1 parent bb47200 commit 3e8dcc5

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
8484
"project_id": "STACKIT Project ID to which the bucket is associated.",
8585
"url_path_style": "URL in path style.",
8686
"url_virtual_hosted_style": "URL in virtual hosted style.",
87-
"region": "The resource region. If not defined, the provider region is used.",
87+
"region": "The resource region. Read-only attribute that reflects the provider region.",
8888
}
8989

9090
resp.Schema = schema.Schema{
@@ -117,7 +117,8 @@ func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
117117
},
118118
"region": schema.StringAttribute{
119119
// the region cannot be found automatically, so it has to be passed
120-
Optional: true,
120+
Optional: false,
121+
Computed: true,
121122
Description: descriptions["region"],
122123
},
123124
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, res
132132
"project_id": "STACKIT Project ID to which the bucket is associated.",
133133
"url_path_style": "URL in path style.",
134134
"url_virtual_hosted_style": "URL in virtual hosted style.",
135-
"region": "The resource region. If not defined, the provider region is used.",
135+
"region": "The resource region. Read-only attribute that reflects the provider region.",
136136
}
137137

138138
resp.Schema = schema.Schema{
@@ -175,7 +175,7 @@ func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, res
175175
Computed: true,
176176
},
177177
"region": schema.StringAttribute{
178-
Optional: true,
178+
Optional: false,
179179
// must be computed to allow for storing the override value from the provider
180180
Computed: true,
181181
Description: descriptions["region"],

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
7979
"credential_id": "The credential ID.",
8080
"credentials_group_id": "The credential group ID.",
8181
"project_id": "STACKIT Project ID to which the credential group is associated.",
82-
"region": "The resource region. If not defined, the provider region is used.",
82+
"region": "The resource region. Read-only attribute that reflects the provider region.",
8383
}
8484

8585
resp.Schema = schema.Schema{
@@ -116,7 +116,8 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
116116
},
117117
"region": schema.StringAttribute{
118118
// the region cannot be found automatically, so it has to be passed
119-
Optional: true,
119+
Optional: false,
120+
Computed: true,
120121
Description: descriptions["region"],
121122
},
122123
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
176176
"credentials_group_id": "The credential group ID.",
177177
"project_id": "STACKIT Project ID to which the credential group is associated.",
178178
"expiration_timestamp": "Expiration timestamp, in RFC339 format without fractional seconds. Example: \"2025-01-01T00:00:00Z\". If not set, the credential never expires.",
179-
"region": "The resource region. If not defined, the provider region is used.",
179+
"region": "The resource region. Read-only attribute that reflects the provider region.",
180180
}
181181

182182
resp.Schema = schema.Schema{
@@ -246,7 +246,7 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
246246
},
247247
},
248248
"region": schema.StringAttribute{
249-
Optional: true,
249+
Optional: false,
250250
// must be computed to allow for storing the override value from the provider
251251
Computed: true,
252252
Description: descriptions["region"],

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (r *credentialsGroupDataSource) Schema(_ context.Context, _ datasource.Sche
8383
"name": "The credentials group's display name.",
8484
"project_id": "Object Storage Project ID to which the credentials group is associated.",
8585
"urn": "Credentials group uniform resource name (URN)",
86-
"region": "The resource region. If not defined, the provider region is used.",
86+
"region": "The resource region. Read-only attribute that reflects the provider region.",
8787
}
8888

8989
resp.Schema = schema.Schema{
@@ -117,7 +117,8 @@ func (r *credentialsGroupDataSource) Schema(_ context.Context, _ datasource.Sche
117117
},
118118
"region": schema.StringAttribute{
119119
// the region cannot be found automatically, so it has to be passed
120-
Optional: true,
120+
Optional: false,
121+
Computed: true,
121122
Description: descriptions["region"],
122123
},
123124
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRe
132132
"name": "The credentials group's display name.",
133133
"project_id": "Project ID to which the credentials group is associated.",
134134
"urn": "Credentials group uniform resource name (URN)",
135-
"region": "The resource region. If not defined, the provider region is used.",
135+
"region": "The resource region. Read-only attribute that reflects the provider region.",
136136
}
137137

138138
resp.Schema = schema.Schema{
@@ -174,7 +174,7 @@ func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRe
174174
Computed: true,
175175
},
176176
"region": schema.StringAttribute{
177-
Optional: true,
177+
Optional: false,
178178
// must be computed to allow for storing the override value from the provider
179179
Computed: true,
180180
Description: descriptions["region"],

0 commit comments

Comments
 (0)