Skip to content

Commit d4b4794

Browse files
BBBmauDawid212
authored andcommitted
Revert "feature: add Ephemeral WriteOnly attributes support" (GoogleCloudPlatform#13134)
1 parent f7d9c62 commit d4b4794

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+73
-951
lines changed

mmv1/api/resource.go

-17
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,6 @@ func (r Resource) SensitiveProps() []*Type {
561561
})
562562
}
563563

564-
func (r Resource) WriteOnlyProps() []*Type {
565-
props := r.AllNestedProperties(r.RootProperties())
566-
return google.Select(props, func(p *Type) bool {
567-
return p.WriteOnly
568-
})
569-
}
570-
571564
func (r Resource) SensitivePropsToString() string {
572565
var props []string
573566

@@ -578,16 +571,6 @@ func (r Resource) SensitivePropsToString() string {
578571
return strings.Join(props, ", ")
579572
}
580573

581-
func (r Resource) WriteOnlyPropsToString() string {
582-
var props []string
583-
584-
for _, prop := range r.WriteOnlyProps() {
585-
props = append(props, fmt.Sprintf("`%s`", prop.Lineage()))
586-
}
587-
588-
return strings.Join(props, ", ")
589-
}
590-
591574
// All settable properties in the resource.
592575
// Fingerprints aren't *really" settable properties, but they behave like one.
593576
// At Create, they have no value but they can just be read in anyways, and after a Read

mmv1/api/resource/custom_code.go

-2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,4 @@ type CustomCode struct {
137137
// resource was successfully deleted. Use this if the API responds
138138
// with a success HTTP code for deleted resources
139139
TestCheckDestroy string `yaml:"test_check_destroy"`
140-
141-
ValidateRawResourceConfigFuncs string `yaml:"raw_resource_config_validation"`
142140
}

mmv1/api/resource/docs.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ type Docs struct {
3232

3333
OptionalProperties string `yaml:"optional_properties"`
3434

35-
WriteOnlyProperties string `yaml:"write_only_properties"`
36-
3735
Attributes string
3836
}

mmv1/api/type.go

+1-35
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ type Type struct {
171171

172172
Sensitive bool `yaml:"sensitive,omitempty"` // Adds `Sensitive: true` to the schema
173173

174-
WriteOnly bool `yaml:"write_only,omitempty"` // Adds `WriteOnly: true` to the schema
175-
176174
// Does not set this value to the returned API value. Useful for fields
177175
// like secrets where the returned API value is not helpful.
178176
IgnoreRead bool `yaml:"ignore_read,omitempty"`
@@ -363,14 +361,6 @@ func (t *Type) Validate(rName string) {
363361
log.Fatalf("'default_value' and 'default_from_api' cannot be both set in resource %s", rName)
364362
}
365363

366-
if t.WriteOnly && (t.DefaultFromApi || t.Output) {
367-
log.Fatalf("Property %s cannot be write_only and default_from_api or output at the same time in resource %s", t.Name, rName)
368-
}
369-
370-
if t.WriteOnly && t.Sensitive {
371-
log.Fatalf("Property %s cannot be write_only and sensitive at the same time in resource %s", t.Name, rName)
372-
}
373-
374364
t.validateLabelsField()
375365

376366
switch {
@@ -692,30 +682,6 @@ func (t Type) NestedProperties() []*Type {
692682
return props
693683
}
694684

695-
// Returns write-only properties for this property.
696-
func (t Type) WriteOnlyProperties() []*Type {
697-
props := make([]*Type, 0)
698-
699-
switch {
700-
case t.IsA("Array"):
701-
if t.ItemType.IsA("NestedObject") {
702-
props = google.Reject(t.ItemType.WriteOnlyProperties(), func(p *Type) bool {
703-
return t.Exclude
704-
})
705-
}
706-
case t.IsA("NestedObject"):
707-
props = google.Select(t.UserProperties(), func(p *Type) bool {
708-
return p.WriteOnly
709-
})
710-
case t.IsA("Map"):
711-
props = google.Reject(t.ValueType.WriteOnlyProperties(), func(p *Type) bool {
712-
return t.Exclude
713-
})
714-
default:
715-
}
716-
return props
717-
}
718-
719685
func (t Type) Removed() bool {
720686
return t.RemovedMessage != ""
721687
}
@@ -1124,7 +1090,7 @@ func (t *Type) IsForceNew() bool {
11241090
}
11251091

11261092
parent := t.Parent()
1127-
return !t.WriteOnly && (!t.Output || t.IsA("KeyValueEffectiveLabels")) &&
1093+
return (!t.Output || t.IsA("KeyValueEffectiveLabels")) &&
11281094
(t.Immutable ||
11291095
(t.ResourceMetadata.Immutable && t.UpdateUrl == "" &&
11301096
(parent == nil ||

mmv1/products/bigquerydatatransfer/Config.yaml

+2-22
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ custom_code:
4141
post_create: 'templates/terraform/post_create/set_computed_name.tmpl'
4242
pre_update: 'templates/terraform/pre_update/bigquerydatatransfer_config.tmpl'
4343
custom_import: 'templates/terraform/custom_import/bigquery_data_transfer_self_link_as_name_set_location.go.tmpl'
44-
raw_resource_config_validation: 'templates/terraform/validation/bigquery_data_transfer_config.go.tmpl'
4544
custom_diff:
4645
- 'sensitiveParamCustomizeDiff'
4746
- 'paramsCustomizeDiff'
@@ -211,12 +210,6 @@ properties:
211210
**NOTE** : If you are attempting to update a parameter that cannot be updated (due to api limitations) [please force recreation of the resource](https://www.terraform.io/cli/state/taint#forcing-re-creation-of-resources).
212211
required: true
213212
custom_flatten: 'templates/terraform/custom_flatten/json_to_string_map.go.tmpl'
214-
215-
- name: 'sensitiveParamsWoVersion'
216-
type: Integer
217-
immutable: true
218-
description: |
219-
The version of the sensitive params - used to trigger updates of the write-only params
220213
- name: 'sensitiveParams'
221214
type: NestedObject
222215
description: |
@@ -233,19 +226,6 @@ properties:
233226
type: String
234227
description: |
235228
The Secret Access Key of the AWS account transferring data from.
229+
230+
required: true
236231
sensitive: true
237-
at_least_one_of:
238-
- 'sensitive_params.0.secretAccessKey'
239-
- 'sensitive_params.0.secretAccessKeyWo'
240-
conflicts:
241-
- 'sensitive_params.0.secretAccessKeyWo'
242-
- name: 'secretAccessKeyWo' # Wo is convention for write-only properties
243-
type: String
244-
description: |
245-
The Secret Access Key of the AWS account transferring data from.
246-
write_only: true
247-
at_least_one_of:
248-
- 'sensitive_params.0.secretAccessKeyWo'
249-
- 'sensitive_params.0.secretAccessKey'
250-
conflicts:
251-
- 'sensitive_params.0.secretAccessKey'

mmv1/products/compute/Disk.yaml

+2-50
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ references:
3737
docs:
3838
base_url: 'projects/{{project}}/zones/{{zone}}/disks'
3939
has_self_link: true
40+
immutable: true
4041
timeouts:
4142
insert_minutes: 20
4243
update_minutes: 20
@@ -62,7 +63,6 @@ custom_code:
6263
update_encoder: 'templates/terraform/update_encoder/hyper_disk.go.tmpl'
6364
decoder: 'templates/terraform/decoders/disk.tmpl'
6465
pre_delete: 'templates/terraform/pre_delete/detach_disk.tmpl'
65-
raw_resource_config_validation: 'templates/terraform/validation/compute_disk.go.tmpl'
6666
custom_diff:
6767
- 'customdiff.ForceNewIfChange("size", IsDiskShrinkage)'
6868
- 'hyperDiskIopsUpdateDiffSuppress'
@@ -72,11 +72,6 @@ examples:
7272
primary_resource_name: 'fmt.Sprintf("tf-test-test-disk%s", context["random_suffix"])'
7373
vars:
7474
disk_name: 'test-disk'
75-
- name: 'disk_basic_wo'
76-
primary_resource_id: 'default'
77-
primary_resource_name: 'fmt.Sprintf("tf-test-test-disk%s", context["random_suffix"])'
78-
vars:
79-
disk_name: 'test-disk'
8075
- name: 'disk_async'
8176
primary_resource_id: 'primary'
8277
primary_resource_name: 'fmt.Sprintf("tf-test-test-disk%s", context["random_suffix"])'
@@ -173,62 +168,21 @@ properties:
173168
If you do not provide an encryption key when creating the disk, then
174169
the disk will be encrypted using an automatically generated key and
175170
you do not need to provide a key to use the disk later.
171+
immutable: true
176172
properties:
177173
- name: 'rawKey'
178174
type: String
179175
description: |
180176
Specifies a 256-bit customer-supplied encryption key, encoded in
181177
RFC 4648 base64 to either encrypt or decrypt this resource.
182178
sensitive: true
183-
immutable: true
184-
custom_flatten: 'templates/terraform/custom_flatten/compute_key_flatten.go.tmpl'
185-
conflicts:
186-
- 'disk_encryption_key.0.rawKeyWo'
187-
- name: 'rawKeyWoVersion'
188-
type: Integer
189-
description: |
190-
Triggers update of write-only rawKey
191-
immutable: true
192-
default_value: 0
193-
ignore_read: true
194-
- name: 'rawKeyWo'
195-
type: String
196-
description: |
197-
Specifies a 256-bit customer-supplied encryption key, encoded in
198-
RFC 4648 base64 to either encrypt or decrypt this resource.
199-
write_only: true
200-
required_with:
201-
- 'disk_encryption_key.0.rawKeyWoVersion'
202-
conflicts:
203-
- 'disk_encryption_key.0.rawKey'
204-
- name: 'rsaEncryptedKeyWoVersion'
205-
type: Integer
206-
description: |
207-
Triggers update of write-only rsaEncryptedKey
208-
immutable: true
209-
default_value: 0
210-
ignore_read: true
211179
- name: 'rsaEncryptedKey'
212180
type: String
213-
immutable: true
214-
custom_flatten: 'templates/terraform/custom_flatten/compute_rsa_key_flatten.go.tmpl'
215181
description: |
216182
Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit
217183
customer-supplied encryption key to either encrypt or decrypt
218184
this resource. You can provide either the rawKey or the rsaEncryptedKey.
219185
sensitive: true
220-
conflicts:
221-
- 'disk_encryption_key.0.rsaEncryptedKeyWo'
222-
- name: 'rsaEncryptedKeyWo'
223-
type: String
224-
description: |
225-
Specifies a 256-bit customer-supplied encryption key, encoded in
226-
RFC 4648 base64 to either encrypt or decrypt this resource.
227-
write_only: true
228-
required_with:
229-
- 'disk_encryption_key.0.rsaEncryptedKeyWoVersion'
230-
conflicts:
231-
- 'disk_encryption_key.0.rsaEncryptedKey'
232186
- name: 'sha256'
233187
type: String
234188
description: |
@@ -237,7 +191,6 @@ properties:
237191
output: true
238192
- name: 'kmsKeySelfLink'
239193
type: String
240-
immutable: true
241194
description: |
242195
The self link of the encryption key used to encrypt the disk. Also called KmsKeyName
243196
in the cloud console. Your project's Compute Engine System service account
@@ -248,7 +201,6 @@ properties:
248201
diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths'
249202
- name: 'kmsKeyServiceAccount'
250203
type: String
251-
immutable: true
252204
description: |
253205
The service account used for the encryption request for the given KMS key.
254206
If absent, the Compute Engine Service Agent service account is used.

mmv1/products/compute/RegionDisk.yaml

+1-30
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ custom_code:
6161
encoder: 'templates/terraform/encoders/disk.tmpl'
6262
decoder: 'templates/terraform/decoders/disk.tmpl'
6363
pre_delete: 'templates/terraform/pre_delete/detach_disk.tmpl'
64-
raw_resource_config_validation: 'templates/terraform/validation/compute_region_disk.go.tmpl'
6564
custom_diff:
6665
- 'customdiff.ForceNewIfChange("size", IsDiskShrinkage)'
6766
- 'hyperDiskIopsUpdateDiffSuppress'
@@ -73,13 +72,6 @@ examples:
7372
region_disk_name: 'my-region-disk'
7473
disk_name: 'my-disk'
7574
snapshot_name: 'my-snapshot'
76-
- name: 'region_disk_disk_encryption_key_wo'
77-
primary_resource_id: 'regiondisk'
78-
primary_resource_name: 'fmt.Sprintf("tf-test-my-region-disk%s", context["random_suffix"])'
79-
vars:
80-
region_disk_name: 'my-region-disk'
81-
disk_name: 'my-disk'
82-
snapshot_name: 'my-snapshot'
8375
- name: 'region_disk_async'
8476
primary_resource_id: 'primary'
8577
primary_resource_name: 'fmt.Sprintf("tf-test-my-region-disk%s", context["random_suffix"])'
@@ -132,34 +124,14 @@ properties:
132124
If you do not provide an encryption key when creating the disk, then
133125
the disk will be encrypted using an automatically generated key and
134126
you do not need to provide a key to use the disk later.
127+
immutable: true
135128
properties:
136129
- name: 'rawKey'
137130
type: String
138131
description: |
139132
Specifies a 256-bit customer-supplied encryption key, encoded in
140133
RFC 4648 base64 to either encrypt or decrypt this resource.
141134
sensitive: true
142-
immutable: true
143-
custom_flatten: 'templates/terraform/custom_flatten/compute_key_flatten.go.tmpl'
144-
conflicts:
145-
- 'disk_encryption_key.0.rawKeyWo'
146-
- name: 'rawKeyWo'
147-
type: String
148-
description: |
149-
Specifies a 256-bit customer-supplied encryption key, encoded in
150-
RFC 4648 base64 to either encrypt or decrypt this resource.
151-
write_only: true
152-
required_with:
153-
- 'disk_encryption_key.0.rawKeyWoVersion'
154-
conflicts:
155-
- 'disk_encryption_key.0.rawKey'
156-
- name: 'rawKeyWoVersion'
157-
type: Integer
158-
description: |
159-
Triggers update of write-only rawKey
160-
ignore_read: true
161-
default_value: 0
162-
immutable: true
163135
- name: 'sha256'
164136
type: String
165137
description: |
@@ -169,7 +141,6 @@ properties:
169141
# TODO(chrisst) Change to ResourceRef once KMS is in Magic Modules
170142
- name: 'kmsKeyName'
171143
type: String
172-
immutable: true
173144
description: |
174145
The name of the encryption key that is stored in Google Cloud KMS.
175146
- name: 'sourceSnapshotEncryptionKey'

mmv1/products/secretmanager/SecretVersion.yaml

+3-34
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ custom_code:
4141
custom_update: 'templates/terraform/custom_update/secret_version.go.tmpl'
4242
pre_delete: 'templates/terraform/pre_delete/secret_version_deletion_policy.go.tmpl'
4343
custom_import: 'templates/terraform/custom_import/secret_version.go.tmpl'
44-
raw_resource_config_validation: 'templates/terraform/validation/secret_version.go.tmpl'
4544
# Sweeper skipped as this resource has customized deletion.
4645
exclude_sweeper: true
4746
examples:
@@ -50,11 +49,6 @@ examples:
5049
vars:
5150
secret_id: 'secret-version'
5251
data: 'secret-data'
53-
- name: 'secret_version_basic_write_only'
54-
primary_resource_id: 'secret-version-basic-write-only'
55-
vars:
56-
secret_id: 'secret-version-write-only'
57-
data: 'secret-data-write-only'
5852
- name: 'secret_version_deletion_policy_abandon'
5953
primary_resource_id: 'secret-version-deletion-policy'
6054
vars:
@@ -78,15 +72,6 @@ examples:
7872
'data': '"./test-fixtures/binary-file.pfx"'
7973
ignore_read_extra:
8074
- 'is_secret_data_base64'
81-
- name: 'secret_version_with_base64_string_secret_data_write_only'
82-
primary_resource_id: 'secret-version-base64-write-only'
83-
vars:
84-
secret_id: 'secret-version-base64-write-only'
85-
data: 'secret-data-base64-write-only.pfx'
86-
test_vars_overrides:
87-
'data': '"./test-fixtures/binary-file.pfx"'
88-
ignore_read_extra:
89-
- 'is_secret_data_base64'
9075
virtual_fields:
9176
- name: 'deletion_policy'
9277
description: |
@@ -145,29 +130,13 @@ properties:
145130
description: The secret payload of the SecretVersion.
146131
required: true
147132
custom_flatten: 'templates/terraform/custom_flatten/secret_version_access.go.tmpl'
148-
custom_expand: 'templates/terraform/custom_expand/secret_version_access.go.tmpl'
149133
flatten_object: true
150134
properties:
151-
- name: 'secretData'
135+
- name: 'secret_data'
152136
type: String
153137
description: The secret data. Must be no larger than 64KiB.
154138
api_name: data
155-
conflicts:
156-
- 'secretDataWo'
139+
required: true
157140
immutable: true
158141
sensitive: true
159-
- name: 'secretDataWo'
160-
type: String
161-
description: The secret data. Must be no larger than 64KiB.
162-
api_name: data
163-
required_with:
164-
- 'SecretDataWoVersion'
165-
conflicts:
166-
- 'payload.0.secretData'
167-
write_only: true
168-
- name: 'SecretDataWoVersion'
169-
type: Integer
170-
default_value: 0
171-
ignore_read: true
172-
description: Triggers update of secret data write-only
173-
immutable: true
142+
custom_expand: 'templates/terraform/custom_expand/secret_version_secret_data.go.tmpl'

0 commit comments

Comments
 (0)