Skip to content

Commit 3860f0a

Browse files
fix: terraform plan always shows diff for storage field (CSD-74) (#133)
* fix: terraform plan always shows diff for storage field (CSD-74) - The `storage` field in the `zedcloud_application` is read-only, so I mark it as `computed`. * remove optional=true from read-onlu fields
1 parent d218b5c commit 3860f0a

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ gen/
1212
terraform.log
1313
main.tf
1414
dev.tfrc
15+
.vscode/
16+
*.plan

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@ test-run:
5959
updatedeps:
6060
go get -f -t -u ./...
6161
go get -f -u ./...
62+
63+
.PHONY: tfclean
64+
tfclean:
65+
rm -rf ./.terraform
66+
rm -f .terraform.lock.hcl
67+
rm -f terraform.log
68+
rm -f terraform.tfstate

v2/resources/application.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func CreateApplication(ctx context.Context, d *schema.ResourceData, m interface{
9696

9797
// the zedcloud API does not return the partially updated object but a custom response.
9898
// thus, we need to fetch the object and populate the state.
99-
if errs := ReadApplication(ctx, d, m); err != nil {
99+
if errs := ReadApplication(ctx, d, m); errs != nil {
100100
return append(diags, errs...)
101101
}
102102

@@ -247,7 +247,7 @@ func UpdateApplication(ctx context.Context, d *schema.ResourceData, m interface{
247247

248248
// the zedcloud API does not return the partially updated object but a custom response.
249249
// thus, we need to fetch the object and populate the state.
250-
if errs := ReadApplication(ctx, d, m); err != nil {
250+
if errs := ReadApplication(ctx, d, m); errs != nil {
251251
return append(diags, errs...)
252252
}
253253

v2/schemas/application.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func Application() map[string]*schema.Schema {
217217
"cpus": {
218218
Description: `user defined cpus for bundle`,
219219
Type: schema.TypeInt,
220-
Optional: true,
221220
Computed: true,
222221
},
223222

@@ -272,7 +271,6 @@ func Application() map[string]*schema.Schema {
272271
"memory": {
273272
Description: `user defined memory for bundle`,
274273
Type: schema.TypeInt,
275-
Optional: true,
276274
Computed: true,
277275
},
278276

@@ -328,7 +326,7 @@ func Application() map[string]*schema.Schema {
328326
"storage": {
329327
Description: `user defined storage for bundle`,
330328
Type: schema.TypeInt,
331-
Optional: true,
329+
Computed: true,
332330
},
333331

334332
"title": {

0 commit comments

Comments
 (0)