-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* metastore dataproc service data source * provider * docs * test name * location optional * revert location and make required * docs * docs * tf test Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
caccf10
commit 9703ccd
Showing
6 changed files
with
129 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-datasource | ||
dataproc_metastore_service | ||
``` |
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,29 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceDataprocMetastoreService() *schema.Resource { | ||
|
||
dsSchema := datasourceSchemaFromResourceSchema(resourceDataprocMetastoreService().Schema) | ||
addRequiredFieldsToSchema(dsSchema, "service_id") | ||
addRequiredFieldsToSchema(dsSchema, "location") | ||
addOptionalFieldsToSchema(dsSchema, "project") | ||
|
||
return &schema.Resource{ | ||
Read: dataSourceDataprocMetastoreServiceRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func dataSourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface{}) error { | ||
id, err := replaceVars(d, meta.(*Config), "projects/{{project}}/locations/{{location}}/services/{{service_id}}") | ||
if err != nil { | ||
return fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
d.SetId(id) | ||
return resourceDataprocMetastoreServiceRead(d, meta) | ||
} |
46 changes: 46 additions & 0 deletions
46
google-beta/data_source_dataproc_metastore_service_test.go
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,46 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataprocMetastoreServiceDatasource_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
name := "tf-test-" + randString(t, 10) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataprocMetastoreServiceDatasource_basic(name, "DEVELOPER"), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkDataSourceStateMatchesResourceState("data.google_dataproc_metastore_service.my_metastore", "google_dataproc_metastore_service.my_metastore"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataprocMetastoreServiceDatasource_basic(name, tier string) string { | ||
return fmt.Sprintf(` | ||
resource "google_dataproc_metastore_service" "my_metastore" { | ||
service_id = "%s" | ||
location = "us-central1" | ||
tier = "%s" | ||
hive_metastore_config { | ||
version = "2.3.6" | ||
} | ||
} | ||
data "google_dataproc_metastore_service" "my_metastore" { | ||
service_id = google_dataproc_metastore_service.my_metastore.service_id | ||
location = google_dataproc_metastore_service.my_metastore.location | ||
} | ||
`, name, tier) | ||
} |
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
40 changes: 40 additions & 0 deletions
40
website/docs/d/data_source_dataproc_metastore_service.markdown
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,40 @@ | ||
--- | ||
subcategory: "Dataproc" | ||
layout: "google" | ||
page_title: "Google: google_dataproc_metastore_service" | ||
sidebar_current: "docs-google-datasource-dataproc-metastore-service" | ||
description: |- | ||
Get a Dataproc Metastore Service from Google Cloud | ||
--- | ||
|
||
# google\_dataproc\_metastore\_service | ||
|
||
Get a Dataproc Metastore service from Google Cloud by its id and location. | ||
|
||
~> **Warning:** This resource 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. | ||
|
||
## Example Usage | ||
|
||
```tf | ||
data "google_dataproc_metastore_service" "foo" { | ||
service_id = "foo-bar" | ||
location = "global" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `service_id` - (Required) The ID of the metastore service. | ||
* `location` - (Required) The location where the metastore service resides. | ||
|
||
- - - | ||
|
||
* `project` - (Optional) The project in which the resource belongs. If it | ||
is not provided, the provider project is used. | ||
|
||
## Attributes Reference | ||
|
||
See [google_dataproc_metastore_service](https://www.terraform.io/docs/providers/google/r/dataproc_metastore_service.html) resource for details of all the available attributes. |
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