forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite iam data source template with Go (GoogleCloudPlatform#10782)
- Loading branch information
Showing
3 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
mmv1/templates/terraform/datasource_iam.html.markdown.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{{/* The license inside this block applies to this file | ||
Copyright 2024 Google LLC. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ -}} | ||
{{- /* NOTE NOTE NOTE | ||
The newlines in this file are *load bearing*. This file outputs | ||
Markdown, which is extremely sensitive to newlines. You have got | ||
to have a newline after every attribute and property, because | ||
otherwise MD will think the next element is part of the previous | ||
property's bullet point. You cannot have any double newlines in the | ||
middle of a property or attribute, because MD will think that the | ||
empty line ends the bullet point and the indentation will be off. | ||
You must have a newline before and after all --- document indicators, | ||
and you must have a newline before and after all - - - hlines. | ||
You cannot have more than one blank line between properties. | ||
The --- document indicator must be the first line of the file. | ||
As long as you only use `build_property_documentation`, it all works | ||
fine - but when you need to add custom docs (notes, etc), you need | ||
to remember these things. | ||
|
||
Know also that the `lines` function in heavy use in MagicModules will | ||
strip exactly one trailing newline - unless that's what you've designed | ||
your docstring for, it's easier to insert newlines where you need them | ||
manually. That's why, in this file, we use `lines` on anything which | ||
is generated from a ruby function, but skip it on anything that is | ||
directly inserted from YAML. */ -}} | ||
--- | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
# | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# This file is automatically generated by Magic Modules and manual | ||
# changes will be clobbered when the file is regenerated. | ||
# | ||
# Please read more about how to change this file in | ||
# .github/CONTRIBUTING.md. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
subcategory: "{{$.ProductMetadata.DisplayName}}" | ||
description: |- | ||
A datasource to retrieve the IAM policy state for {{$.ProductMetadata.DisplayName}} {{$.Name}} | ||
--- | ||
|
||
|
||
# `{{ $.IamTerraformName }}_policy` | ||
Retrieves the current IAM policy data for {{ lower $.Name }} | ||
|
||
{{ if or (eq $.MinVersionObj.Name "beta") (eq $.IamPolicy.MinVersion "beta") }} | ||
~> **Warning:** This datasource is in beta, and should be used with the terraform-provider-google-beta provider. | ||
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. | ||
{{- end }} | ||
|
||
## example | ||
|
||
```hcl | ||
data "{{ $.IamTerraformName }}_policy" "policy" { | ||
{{ if eq $.MinVersionObj.Name "beta" }} | ||
provider = google-beta | ||
{{- end }} | ||
{{- $.CustomTemplate $.IamPolicy.ExampleConfigBody}} | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
{{ range $param := $.IamSelfLinkProperties }} | ||
{{- if eq $param.Name "name" -}} | ||
* `{{if $.IamPolicy.ParentResourceAttribute}}{{$.IamPolicy.ParentResourceAttribute}}{{else}}{{underscore $.Name}}{{end}}` - (Required) Used to find the parent resource to bind the IAM policy to | ||
{{- else if or (eq (underscore $param.Name) "region") (eq (underscore $param.Name) "zone") }} | ||
* `{{ underscore $param.Name }}` - (Optional) {{ $param.Description }} Used to find the parent resource to bind the IAM policy to. If not specified, | ||
the value will be parsed from the identifier of the parent resource. If no {{ underscore $param.Name }} is provided in the parent identifier and no | ||
{{ underscore $param.Name }} is specified, it is taken from the provider configuration. | ||
{{- else }} | ||
* `{{ underscore $param.Name }}` - (Required) {{ $param.Description }} Used to find the parent resource to bind the IAM policy to | ||
{{- end }} | ||
{{- end }} | ||
{{- if $.IamPolicy.BaseUrl }} | ||
{{- if contains $.IamPolicy.BaseUrl "{{project}}" }} | ||
{{- /* The following new line allow for project to be bullet-formatted properly. */}} | ||
|
||
* `project` - (Optional) The ID of the project in which the resource belongs. | ||
If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. | ||
{{- end }} | ||
{{- else if contains $.BaseUrl "{{project}}" }} | ||
{{- /* The following new line allow for project to be bullet-formatted properly. */}} | ||
|
||
* `project` - (Optional) The ID of the project in which the resource belongs. | ||
If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. | ||
{{- end }} | ||
|
||
## Attributes Reference | ||
|
||
The attributes are exported: | ||
|
||
* `etag` - (Computed) The etag of the IAM policy. | ||
|
||
* `policy_data` - (Required only by `{{ $.IamTerraformName }}_policy`) The policy data generated by | ||
a `google_iam_policy` data source. |