Skip to content

Commit bee5162

Browse files
MMv1 field: changed write_only to write_only_legacy and marked field as deprecated (#15022)
1 parent e0ff702 commit bee5162

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

docs/content/reference/field.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Example:
107107
sensitive: true
108108
```
109109

110-
### `write_only`
110+
### `write_only_legacy` (deprecated)
111111
If true, the field is considered "write-only", which means that its value will
112112
be obscured in Terraform output as well as not be stored in state. This field is meant to replace `sensitive` as it doesn't store the value in state.
113113
See [Ephemerality in Resources - Use Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral/write-only)
@@ -121,9 +121,11 @@ This field cannot be used in conjuction with `immutable` or `sensitive`.
121121
Example:
122122

123123
```yaml
124-
write_only: true
124+
write_only_legacy: true
125125
```
126126

127+
**Deprecated**: This field is deprecated and will be removed in a future release.
128+
127129
### `ignore_read`
128130
If true, the provider sets the field's value in the resource state based only
129131
on the user's configuration. If false or unset, the provider sets the field's

mmv1/api/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ func (r Resource) SensitiveProps() []*Type {
617617
func (r Resource) WriteOnlyProps() []*Type {
618618
props := r.AllNestedProperties(r.RootProperties())
619619
return google.Select(props, func(p *Type) bool {
620-
return p.WriteOnly
620+
return p.WriteOnlyLegacy
621621
})
622622
}
623623

mmv1/api/type.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ 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
174+
// TODO: remove this field after all references are migrated
175+
// see: https://github.com/GoogleCloudPlatform/magic-modules/pull/14933#pullrequestreview-3166578379
176+
WriteOnlyLegacy bool `yaml:"write_only_legacy,omitempty"` // Adds `WriteOnlyLegacy: true` to the schema
175177

176178
// Does not set this value to the returned API value. Useful for fields
177179
// like secrets where the returned API value is not helpful.
@@ -395,11 +397,11 @@ func (t *Type) Validate(rName string) {
395397
log.Fatalf("'default_value' and 'default_from_api' cannot be both set in resource %s", rName)
396398
}
397399

398-
if t.WriteOnly && (t.DefaultFromApi || t.Output) {
400+
if t.WriteOnlyLegacy && (t.DefaultFromApi || t.Output) {
399401
log.Fatalf("Property %s cannot be write_only and default_from_api or output at the same time in resource %s", t.Name, rName)
400402
}
401403

402-
if t.WriteOnly && t.Sensitive {
404+
if t.WriteOnlyLegacy && t.Sensitive {
403405
log.Fatalf("Property %s cannot be write_only and sensitive at the same time in resource %s", t.Name, rName)
404406
}
405407

@@ -750,7 +752,7 @@ func (t Type) WriteOnlyProperties() []*Type {
750752
}
751753
case t.IsA("NestedObject"):
752754
props = google.Select(t.UserProperties(), func(p *Type) bool {
753-
return p.WriteOnly
755+
return p.WriteOnlyLegacy
754756
})
755757
case t.IsA("Map"):
756758
props = google.Reject(t.ValueType.WriteOnlyProperties(), func(p *Type) bool {
@@ -1224,8 +1226,8 @@ func (t *Type) IsForceNew() bool {
12241226
return t.Immutable
12251227
}
12261228

1227-
// WriteOnly fields are never immutable
1228-
if t.WriteOnly {
1229+
// WriteOnlyLegacy fields are never immutable
1230+
if t.WriteOnlyLegacy {
12291231
return false
12301232
}
12311233

mmv1/products/bigquerydatatransfer/Config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ properties:
243243
type: String
244244
description: |
245245
The Secret Access Key of the AWS account transferring data from.
246-
write_only: true
246+
write_only_legacy: true
247247
at_least_one_of:
248248
- 'sensitive_params.0.secretAccessKeyWo'
249249
- 'sensitive_params.0.secretAccessKey'

mmv1/products/monitoring/UptimeCheckConfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ properties:
259259
- 'password'
260260
required_with:
261261
- 'http_check.0.auth_info.0.password_wo_version'
262-
write_only: true
262+
write_only_legacy: true
263263
- name: 'passwordWoVersion'
264264
type: String
265265
immutable: true

mmv1/products/secretmanager/SecretVersion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ properties:
172172
- 'SecretDataWoVersion'
173173
conflicts:
174174
- 'payload.0.secretData'
175-
write_only: true
175+
write_only_legacy: true
176176
- name: 'SecretDataWoVersion'
177177
type: Integer
178178
default_value: 0

mmv1/templates/terraform/custom_flatten/dataplex_entry_aspects.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
1515
transformed = append(transformed, map[string]interface{}{
1616

1717
{{- range $prop := $.ItemType.UserProperties }}
18-
{{- if not (or $prop.IgnoreRead $prop.WriteOnly) }}
18+
{{- if not (or $prop.IgnoreRead $prop.WriteOnlyLegacy) }}
1919
"{{ underscore $prop.Name }}": flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}{{$prop.TitlelizeProperty}}(original["{{ $prop.ApiName }}"], d, config),
2020
{{- end }}
2121
{{- end }}

mmv1/templates/terraform/flatten_property_method.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License. */ -}}
1515
{{- define "flattenPropertyMethod" }}
16-
{{- if $.WriteOnly }}
16+
{{- if $.WriteOnlyLegacy }}
1717
{{- else if and $.CustomFlatten (not $.ShouldIgnoreCustomFlatten) }}
1818
{{- $.CustomTemplate $.CustomFlatten false -}}
1919
{{- else -}}
@@ -34,7 +34,7 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
3434
{{- end }}
3535
transformed := make(map[string]interface{})
3636
{{- range $prop := $.UserProperties }}
37-
{{- if $prop.WriteOnly }}
37+
{{- if $prop.WriteOnlyLegacy }}
3838
{{- else if $prop.FlattenObject }}
3939
if {{ $prop.ApiName }} := flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}{{$prop.TitlelizeProperty}}(original["{{ $prop.ApiName }}"], d, config); {{ $prop.ApiName }} != nil {
4040
obj := {{ $prop.ApiName }}.([]interface{})[0]
@@ -80,7 +80,7 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
8080
{{- end }}
8181

8282
{{- range $prop := $.ItemType.UserProperties }}
83-
{{- if not (or $prop.IgnoreRead $prop.WriteOnly) }}
83+
{{- if not (or $prop.IgnoreRead $prop.WriteOnlyLegacy) }}
8484
"{{ underscore $prop.Name }}": flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}{{$prop.TitlelizeProperty}}(original["{{ $prop.ApiName }}"], d, config),
8585
{{- end }}
8686
{{- end }}

mmv1/templates/terraform/nested_property_write_only_documentation.html.markdown.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{ "" }}
44
{{- if $.NestedProperties }}
55
{{- range $np := $.NestedProperties }}
6-
{{- if $np.WriteOnly }}
6+
{{- if $np.WriteOnlyLegacy }}
77
{{- trimTemplate "property_documentation.html.markdown.tmpl" $np -}}
88
{{- end -}}
99
{{- end -}}

mmv1/templates/terraform/property_documentation.html.markdown.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{{- if $.Sensitive }}
3737
**Note**: This property is sensitive and will not be displayed in the plan.
3838
{{- end }}
39-
{{- if $.WriteOnly }}
39+
{{- if $.WriteOnlyLegacy }}
4040
**Note**: This property is write-only and will not be read from the API.
4141
{{- end }}
4242
{{- if and (not $.FlattenObject) $.NestedProperties }}

0 commit comments

Comments
 (0)