Skip to content

Commit 3ae6022

Browse files
authored
Tweaked resource version guard docs to be clearer (#13852)
1 parent f191f35 commit 3ae6022

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

docs/content/develop/add-resource.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ For more information about types of resources and the generation process overall
163163
- Replace all occurrences of `github.com/hashicorp/terraform-provider-google-beta/google-beta` with `github.com/hashicorp/terraform-provider-google/google`
164164
- Remove the `Example` suffix from all test function names.
165165
- Remove the comments at the top of the file.
166-
- If beta-only fields are being tested, do the following:
167-
- Change the file suffix to `.go.tmpl`
168-
- Wrap each beta-only test in a separate version guard: `{{- if ne $.TargetVersionName "ga" -}}...{{- else }}...{{- end }}`
166+
- If any of the added Go code (including any imports) is beta-only, change the file suffix to `.go.tmpl` and wrap the beta-only code in a version guard: `{{- if ne $.TargetVersionName "ga" -}}...{{- else }}...{{- end }}`.
167+
- If the whole resource is beta-only, wrap everything except package declarations. Otherwise, individually wrap each logically-related block of code in a version guard (field, test, etc) rather than grouping adjacent version-guarded sections - it's easier to read and easier to modify as things move out of beta.
169168
5. Register the resource `handwrittenResources` in [`magic-modules/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl`](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl)
170169
- Add a version guard for any beta-only resources.
171170
6. Optional: Complete other handwritten tasks that require the MMv1 configuration file.

0 commit comments

Comments
 (0)