diff --git a/README.md b/README.md index 6000bdd90434..9fbd0df9d0ca 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ If you're generating the Terraform providers (`google` and `google-beta`), you'll need to check out the repo(s) you're generating in your GOPATH. For example: -``` +```bash git clone https://github.com/hashicorp/terraform-provider-google.git $GOPATH/src/github.com/hashicorp/terraform-provider-google git clone https://github.com/hashicorp/terraform-provider-google-beta.git $GOPATH/src/github.com/hashicorp/terraform-provider-google-beta ``` @@ -86,7 +86,8 @@ Terraform provider are running on up to date copies of `master`. Once you've prepared the target folders for the tools, run the following to finish getting Magic Modules set up by installing the Ruby gems it needs to run: -``` +```bash +cd mmv1 bundle install ``` @@ -102,7 +103,7 @@ Before making any changes, you can compile the "downstream" tool you're working on by running the following command. If Magic Modules has been installed correctly, you'll get no errors when you run a command: -``` +```bash bundle exec compiler -a -v "ga" -e {{tool}} -o "{{output_folder}}" ``` @@ -112,7 +113,7 @@ For Ansible and Inspec, wherever you have cloned those repositories. For example, to generate Terraform: -``` +```bash bundle exec compiler -a -v "ga" -e terraform -o "$GOPATH/src/github.com/hashicorp/terraform-provider-google" ``` @@ -126,7 +127,7 @@ Terraform is the only tool to handle Beta features right now; you can generate `google-beta` by running the following, substitution `"beta"` for the version and using the repository for the `google-beta` provider. -``` +```bash bundle exec compiler -a -v "beta" -e terraform -o "$GOPATH/src/github.com/hashicorp/terraform-provider-google-beta" ``` @@ -245,6 +246,7 @@ Once you've gotten approvals from the primary reviewer and the reviewers for any affected tools, the primary reviewer will merge your changes. ## Glossary + The maintainers of the repository will tend to use specific jargon to describe concepts related to Magic Modules; here's a quick reference of what some of those terms are. diff --git a/mmv1/third_party/terraform/data_sources/data_source_runtimeconfig_variable.go.erb b/mmv1/third_party/terraform/data_sources/data_source_runtimeconfig_variable.go.erb new file mode 100644 index 000000000000..8541d937c730 --- /dev/null +++ b/mmv1/third_party/terraform/data_sources/data_source_runtimeconfig_variable.go.erb @@ -0,0 +1,36 @@ +<% autogen_exception -%> +package google + +<% unless version == 'ga' -%> + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceGoogleRuntimeconfigVariable() *schema.Resource { + + dsSchema := datasourceSchemaFromResourceSchema(resourceRuntimeconfigVariable().Schema) + addRequiredFieldsToSchema(dsSchema, "name") + addRequiredFieldsToSchema(dsSchema, "parent") + addOptionalFieldsToSchema(dsSchema, "project") + + return &schema.Resource{ + Read: dataSourceGoogleRuntimeconfigVariableRead, + Schema: dsSchema, + } +} + +func dataSourceGoogleRuntimeconfigVariableRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + id, err := replaceVars(d, config, "projects/{{project}}/configs/{{parent}}/variables/{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + return resourceRuntimeconfigVariableRead(d, meta) +} + +<% end -%> diff --git a/mmv1/third_party/terraform/tests/data_source_runtimeconfig_variable_test.go.erb b/mmv1/third_party/terraform/tests/data_source_runtimeconfig_variable_test.go.erb new file mode 100644 index 000000000000..d6c54218d7fa --- /dev/null +++ b/mmv1/third_party/terraform/tests/data_source_runtimeconfig_variable_test.go.erb @@ -0,0 +1,58 @@ +<% autogen_exception -%> +package google + +<% unless version == 'ga' -%> + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccRuntimeconfigVariableDatasource_basic(t *testing.T) { + t.Parallel() + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccRuntimeconfigDatasourceVariable(randString(t, 10), randString(t, 10), randString(t, 10)), + Check: resource.ComposeTestCheckFunc( + checkDataSourceStateMatchesResourceState("data.google_runtimeconfig_variable.default", "google_runtimeconfig_variable.default"), + ), + }, + }, + }) +} + +func testAccRuntimeconfigDatasourceVariable(suffix string, name string, text string) string { + return fmt.Sprintf(` + resource "google_project_service" "default" { + service = "runtimeconfig.googleapis.com" + } + + resource "google_runtimeconfig_config" "default" { + project = google_project_service.default.project + name = "runtime-%s" + description = "runtime-%s" + depends_on = [ google_project_service.default ] + } + + resource "google_runtimeconfig_variable" "default" { + project = google_project_service.default.project + parent = google_runtimeconfig_config.default.name + name = "%s" + text = "%s" + } + + data "google_runtimeconfig_variable" "default" { + project = google_project_service.default.project + name = google_runtimeconfig_variable.default.name + parent = google_runtimeconfig_config.default.name + } +`, suffix, suffix, name, text) +} + +<% end -%> diff --git a/mmv1/third_party/terraform/utils/provider.go.erb b/mmv1/third_party/terraform/utils/provider.go.erb index 08884b77c964..19753a0a94ab 100644 --- a/mmv1/third_party/terraform/utils/provider.go.erb +++ b/mmv1/third_party/terraform/utils/provider.go.erb @@ -249,6 +249,9 @@ func Provider() *schema.Provider { "google_project_organization_policy": dataSourceGoogleProjectOrganizationPolicy(), "google_pubsub_topic": dataSourceGooglePubsubTopic(), "google_runtimeconfig_config": dataSourceGoogleRuntimeconfigConfig(), + <% unless version == 'ga' -%> + "google_runtimeconfig_variable": dataSourceGoogleRuntimeconfigVariable(), + <% end -%> "google_secret_manager_secret_version": dataSourceSecretManagerSecretVersion(), "google_service_account": dataSourceGoogleServiceAccount(), "google_service_account_access_token": dataSourceGoogleServiceAccountAccessToken(), diff --git a/mmv1/third_party/terraform/website/docs/d/runtimeconfig_config.html.markdown b/mmv1/third_party/terraform/website/docs/d/runtimeconfig_config.html.markdown index 6e7145ca1218..a1a5c10e4988 100644 --- a/mmv1/third_party/terraform/website/docs/d/runtimeconfig_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/d/runtimeconfig_config.html.markdown @@ -27,7 +27,7 @@ data "google_runtimeconfig_config" "run-service" { The following arguments are supported: -* `name` - (Required) The name of the Cloud Run Service. +* `name` - (Required) The name of the Runtime Configurator configuration. - - - diff --git a/mmv1/third_party/terraform/website/docs/d/runtimeconfig_variable.html.markdown b/mmv1/third_party/terraform/website/docs/d/runtimeconfig_variable.html.markdown new file mode 100644 index 000000000000..bfd04a0045cd --- /dev/null +++ b/mmv1/third_party/terraform/website/docs/d/runtimeconfig_variable.html.markdown @@ -0,0 +1,41 @@ +--- +subcategory: "Runtime Configurator" +layout: "google" +page_title: "Google: google_runtimeconfig_variable" +sidebar_current: "docs-google-datasource-runtimeconfig-variable" +description: |- + Get information about a Google Cloud RuntimeConfig varialbe. +--- + +# google\_runtimeconfig\_variable + +To get more information about RuntimeConfigs, see: + +* [API documentation](https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs) +* How-to Guides + * [Runtime Configurator Fundamentals](https://cloud.google.com/deployment-manager/runtime-configurator/) + +## Example Usage + +```hcl +data "google_runtimeconfig_variable" "run-service" { + parent = "my-service" + name = "prod-variables/hostname" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Runtime Configurator configuration. +* `parent` - (Required) The name of the RuntimeConfig resource containing this variable. + +- - - + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +## Attributes Reference + +See [google_runtimeconfig_variable](https://www.terraform.io/docs/providers/google/r/runtimeconfig_variable.html#argument-reference) resource for details of the available attributes. diff --git a/tpgtools/overrides/runtimeconfig/variable.yaml b/tpgtools/overrides/runtimeconfig/variable.yaml index 946a52793c05..3617b7eaee3b 100644 --- a/tpgtools/overrides/runtimeconfig/variable.yaml +++ b/tpgtools/overrides/runtimeconfig/variable.yaml @@ -7,4 +7,4 @@ function: runtimeconfigVariableImport - type: PRE_CREATE_FUNCTION details: - function: runtimeconfigVariableValidateTextOrValueSet + function: runtimeconfigVariableValidateTextOrValueSet