Skip to content

Commit de8f5cf

Browse files
provider: eliminated the need to manually add *_wo and *_wo_version for write-only properties (#14230) (#23921)
[upstream:1ba53f07571dfaf62185aa55130b24913f4b4d01] Signed-off-by: Modular Magician <[email protected]>
1 parent 87d8bb6 commit de8f5cf

9 files changed

+71
-69
lines changed

.changelog/14230.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
provider: eliminated the need to manually add `*_wo` and `*_wo_version` for write-only properties
3+
```

google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,24 @@ to a different credential configuration in the config will require an apply to u
287287
Elem: &schema.Resource{
288288
Schema: map[string]*schema.Schema{
289289
"secret_access_key": {
290-
Type: schema.TypeString,
291-
Optional: true,
292-
Description: `The Secret Access Key of the AWS account transferring data from.`,
293-
Sensitive: true,
294-
ConflictsWith: []string{"sensitive_params.0.secret_access_key_wo"},
295-
AtLeastOneOf: []string{"sensitive_params.0.secret_access_key", "sensitive_params.0.secret_access_key_wo"},
290+
Type: schema.TypeString,
291+
Optional: true,
292+
Description: `The Secret Access Key of the AWS account transferring data from.`,
293+
Sensitive: true,
296294
},
297295
"secret_access_key_wo": {
298-
Type: schema.TypeString,
299-
Optional: true,
300-
Description: `The Secret Access Key of the AWS account transferring data from.`,
301-
WriteOnly: true,
302-
ConflictsWith: []string{"sensitive_params.0.secret_access_key"},
303-
AtLeastOneOf: []string{"sensitive_params.0.secret_access_key_wo", "sensitive_params.0.secret_access_key"},
296+
Type: schema.TypeString,
297+
Optional: true,
298+
Description: `The Secret Access Key of the AWS account transferring data from.
299+
Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
300+
WriteOnly: true,
301+
ExactlyOneOf: []string{"sensitive_params.0.secret_access_key", "sensitive_params.0.secret_access_key_wo"},
302+
RequiredWith: []string{"sensitive_params.0.secret_access_key_wo_version"},
304303
},
305304
"secret_access_key_wo_version": {
306-
Type: schema.TypeInt,
305+
Type: schema.TypeString,
307306
Optional: true,
308-
Description: `The version of the sensitive params - used to trigger updates of the write-only params. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
307+
Description: `Triggers update of secret_access_key_wo write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
309308
RequiredWith: []string{"sensitive_params.0.secret_access_key_wo"},
310309
},
311310
},

google/services/monitoring/resource_monitoring_uptime_check_config.go

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,23 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
172172
Description: `The username to authenticate.`,
173173
},
174174
"password": {
175-
Type: schema.TypeString,
176-
Optional: true,
177-
Description: `The password to authenticate.`,
178-
Sensitive: true,
179-
ExactlyOneOf: []string{},
175+
Type: schema.TypeString,
176+
Optional: true,
177+
Description: `The password to authenticate.`,
178+
Sensitive: true,
180179
},
181180
"password_wo": {
182181
Type: schema.TypeString,
183182
Optional: true,
184-
Description: `The password to authenticate.`,
183+
Description: `The password to authenticate. Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
185184
WriteOnly: true,
186-
ExactlyOneOf: []string{},
185+
ExactlyOneOf: []string{"http_check.0.auth_info.0.password", "http_check.0.auth_info.0.password_wo"},
187186
RequiredWith: []string{"http_check.0.auth_info.0.password_wo_version"},
188187
},
189188
"password_wo_version": {
190189
Type: schema.TypeString,
191190
Optional: true,
192-
ForceNew: true,
193-
Description: `The password write-only version.`,
191+
Description: `Triggers update of password_wo write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
194192
RequiredWith: []string{"http_check.0.auth_info.0.password_wo"},
195193
},
196194
},
@@ -1093,24 +1091,24 @@ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfo(v interface{}, d *schem
10931091
transformed := make(map[string]interface{})
10941092
transformed["password"] =
10951093
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword(original["password"], d, config)
1096-
transformed["password_wo_version"] =
1097-
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(original["passwordWoVersion"], d, config)
10981094
transformed["username"] =
10991095
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(original["username"], d, config)
1096+
transformed["password_wo_version"] =
1097+
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(original["passwordWoVersion"], d, config)
11001098
return []interface{}{transformed}
11011099
}
11021100
func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
11031101
return d.Get("http_check.0.auth_info.0.password")
11041102
}
11051103

1106-
func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1107-
return d.Get("http_check.0.auth_info.0.password_wo_version")
1108-
}
1109-
11101104
func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
11111105
return v
11121106
}
11131107

1108+
func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1109+
return d.Get("http_check.0.auth_info.0.password_wo_version")
1110+
}
1111+
11141112
func flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
11151113
if v == nil {
11161114
return nil
@@ -1629,11 +1627,18 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfo(v interface{}, d tpgreso
16291627
transformed["password"] = transformedPassword
16301628
}
16311629

1630+
transformedUsername, err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(original["username"], d, config)
1631+
if err != nil {
1632+
return nil, err
1633+
} else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1634+
transformed["username"] = transformedUsername
1635+
}
1636+
16321637
transformedPasswordWo, err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWo(original["password_wo"], d, config)
16331638
if err != nil {
16341639
return nil, err
16351640
} else if val := reflect.ValueOf(transformedPasswordWo); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1636-
transformed["passwordWo"] = transformedPasswordWo
1641+
transformed["password"] = transformedPasswordWo
16371642
}
16381643

16391644
transformedPasswordWoVersion, err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(original["password_wo_version"], d, config)
@@ -1643,29 +1648,22 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfo(v interface{}, d tpgreso
16431648
transformed["passwordWoVersion"] = transformedPasswordWoVersion
16441649
}
16451650

1646-
transformedUsername, err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(original["username"], d, config)
1647-
if err != nil {
1648-
return nil, err
1649-
} else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1650-
transformed["username"] = transformedUsername
1651-
}
1652-
16531651
return transformed, nil
16541652
}
16551653

16561654
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
16571655
return v, nil
16581656
}
16591657

1660-
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWo(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1658+
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
16611659
return v, nil
16621660
}
16631661

1664-
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1662+
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWo(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
16651663
return v, nil
16661664
}
16671665

1668-
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1666+
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
16691667
return v, nil
16701668
}
16711669

google/services/monitoring/resource_monitoring_uptime_check_config_generated_meta.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ fields:
1515
- field: 'http_check.accepted_response_status_codes.status_value'
1616
- field: 'http_check.auth_info.password'
1717
- field: 'http_check.auth_info.password_wo'
18+
api_field: 'http_check.auth_info.password'
1819
- field: 'http_check.auth_info.password_wo_version'
20+
provider_only: true
1921
- field: 'http_check.auth_info.username'
2022
- field: 'http_check.body'
2123
- field: 'http_check.content_type'

google/services/monitoring/resource_monitoring_uptime_check_config_generated_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(t *testing.
5151
ResourceName: "google_monitoring_uptime_check_config.http",
5252
ImportState: true,
5353
ImportStateVerify: true,
54-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
54+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
5555
},
5656
},
5757
})
@@ -121,7 +121,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpPasswordWoExample(t
121121
ResourceName: "google_monitoring_uptime_check_config.http",
122122
ImportState: true,
123123
ImportStateVerify: true,
124-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
124+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
125125
},
126126
},
127127
})
@@ -195,7 +195,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigStatusCodeExample(t *te
195195
ResourceName: "google_monitoring_uptime_check_config.status_code",
196196
ImportState: true,
197197
ImportStateVerify: true,
198-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
198+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
199199
},
200200
},
201201
})
@@ -267,7 +267,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpsExample(t *testing
267267
ResourceName: "google_monitoring_uptime_check_config.https",
268268
ImportState: true,
269269
ImportStateVerify: true,
270-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
270+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
271271
},
272272
},
273273
})
@@ -328,7 +328,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckTcpExample(t *testing.T) {
328328
ResourceName: "google_monitoring_uptime_check_config.tcp_group",
329329
ImportState: true,
330330
ImportStateVerify: true,
331-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
331+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
332332
},
333333
},
334334
})
@@ -381,7 +381,7 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigSyntheticMonitorExample
381381
ResourceName: "google_monitoring_uptime_check_config.synthetic_monitor",
382382
ImportState: true,
383383
ImportStateVerify: true,
384-
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo_version"},
384+
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password_wo"},
385385
},
386386
},
387387
})

google/services/secretmanager/resource_secret_manager_secret_version.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,27 @@ func ResourceSecretManagerSecretVersion() *schema.Resource {
9090
},
9191

9292
Schema: map[string]*schema.Schema{
93-
"secret_data_wo_version": {
94-
Type: schema.TypeInt,
93+
"secret_data": {
94+
Type: schema.TypeString,
9595
Optional: true,
9696
ForceNew: true,
97-
Description: `Triggers update of secret data write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
98-
Default: 0,
99-
},
100-
"secret_data": {
101-
Type: schema.TypeString,
102-
Optional: true,
103-
ForceNew: true,
104-
Description: `The secret data. Must be no larger than 64KiB.`,
105-
Sensitive: true,
106-
ConflictsWith: []string{},
97+
Description: `The secret data. Must be no larger than 64KiB.`,
98+
Sensitive: true,
10799
},
108100
"secret_data_wo": {
109101
Type: schema.TypeString,
110102
Optional: true,
111-
Description: `The secret data. Must be no larger than 64KiB. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
103+
Description: `The secret data. Must be no larger than 64KiB. Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
112104
WriteOnly: true,
113105
ConflictsWith: []string{"secret_data"},
114-
RequiredWith: []string{},
106+
RequiredWith: []string{"secret_data_wo_version"},
107+
},
108+
"secret_data_wo_version": {
109+
Type: schema.TypeString,
110+
Optional: true,
111+
ForceNew: true,
112+
Description: `Triggers update of secret_data_wo write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
113+
RequiredWith: []string{"secret_data_wo"},
115114
},
116115

117116
"secret": {

google/services/secretmanager/resource_secret_manager_secret_version_generated_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestAccSecretManagerSecretVersion_secretVersionBasicExample(t *testing.T) {
4949
ResourceName: "google_secret_manager_secret_version.secret-version-basic",
5050
ImportState: true,
5151
ImportStateVerify: true,
52-
ImportStateVerifyIgnore: []string{"secret"},
52+
ImportStateVerifyIgnore: []string{"secret", "secret_data_wo"},
5353
},
5454
},
5555
})
@@ -97,7 +97,7 @@ func TestAccSecretManagerSecretVersion_secretVersionBasicWriteOnlyExample(t *tes
9797
ResourceName: "google_secret_manager_secret_version.secret-version-basic-write-only",
9898
ImportState: true,
9999
ImportStateVerify: true,
100-
ImportStateVerifyIgnore: []string{"secret"},
100+
ImportStateVerifyIgnore: []string{"secret", "secret_data_wo"},
101101
},
102102
},
103103
})
@@ -145,7 +145,7 @@ func TestAccSecretManagerSecretVersion_secretVersionDeletionPolicyAbandonExample
145145
ResourceName: "google_secret_manager_secret_version.secret-version-deletion-policy",
146146
ImportState: true,
147147
ImportStateVerify: true,
148-
ImportStateVerifyIgnore: []string{"deletion_policy", "secret"},
148+
ImportStateVerifyIgnore: []string{"deletion_policy", "secret", "secret_data_wo"},
149149
},
150150
},
151151
})
@@ -193,7 +193,7 @@ func TestAccSecretManagerSecretVersion_secretVersionDeletionPolicyDisableExample
193193
ResourceName: "google_secret_manager_secret_version.secret-version-deletion-policy",
194194
ImportState: true,
195195
ImportStateVerify: true,
196-
ImportStateVerifyIgnore: []string{"deletion_policy", "secret"},
196+
ImportStateVerifyIgnore: []string{"deletion_policy", "secret", "secret_data_wo"},
197197
},
198198
},
199199
})
@@ -242,7 +242,7 @@ func TestAccSecretManagerSecretVersion_secretVersionWithBase64StringSecretDataEx
242242
ResourceName: "google_secret_manager_secret_version.secret-version-base64",
243243
ImportState: true,
244244
ImportStateVerify: true,
245-
ImportStateVerifyIgnore: []string{"is_secret_data_base64", "secret"},
245+
ImportStateVerifyIgnore: []string{"is_secret_data_base64", "secret", "secret_data_wo"},
246246
},
247247
},
248248
})
@@ -291,7 +291,7 @@ func TestAccSecretManagerSecretVersion_secretVersionWithBase64StringSecretDataWr
291291
ResourceName: "google_secret_manager_secret_version.secret-version-base64-write-only",
292292
ImportState: true,
293293
ImportStateVerify: true,
294-
ImportStateVerifyIgnore: []string{"is_secret_data_base64", "secret"},
294+
ImportStateVerifyIgnore: []string{"is_secret_data_base64", "secret", "secret_data_wo"},
295295
},
296296
},
297297
})

website/docs/r/bigquery_data_transfer_config.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ The following write-only attributes are supported:
296296
* `secret_access_key_wo` -
297297
(Optional)
298298
The Secret Access Key of the AWS account transferring data from.
299+
Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
299300
**Note**: This property is write-only and will not be read from the API.
300301

301302
## Attributes Reference

website/docs/r/secret_manager_secret_version.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ The following arguments are supported:
234234

235235
* `secret_data_wo_version` -
236236
(Optional)
237-
Triggers update of secret data write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
237+
Triggers update of secret_data_wo write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
238238

239239
* `deletion_policy` - (Optional) The deletion policy for the secret version. Setting `ABANDON` allows the resource
240240
to be abandoned rather than deleted. Setting `DISABLE` allows the resource to be
@@ -252,15 +252,15 @@ The following write-only attributes are supported:
252252

253253
* `secret_data_wo` -
254254
(Optional)
255-
The secret data. Must be no larger than 64KiB. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
255+
The secret data. Must be no larger than 64KiB. Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
256256
**Note**: This property is write-only and will not be read from the API.
257257

258258

259259
<a name="nested_payload"></a>The `payload` block supports:
260260

261261
* `secret_data_wo` -
262262
(Optional)
263-
The secret data. Must be no larger than 64KiB. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
263+
The secret data. Must be no larger than 64KiB. Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
264264
**Note**: This property is write-only and will not be read from the API.
265265

266266
## Attributes Reference

0 commit comments

Comments
 (0)