From c7153f468e96b5d920ddf2b7af6c48e67738f692 Mon Sep 17 00:00:00 2001 From: Viktor Csomor Date: Thu, 21 Nov 2024 17:36:56 +0100 Subject: [PATCH] Fix Data Warehouse documentation (#183) Fix documentation generation of the Data Warehouse resources. The `cdp_vw_hive` resource type has been renamed to `cdp_dw_vw_hive`. --- docs/resources/dw_aws_cluster.md | 5 +--- docs/resources/dw_database_catalog.md | 5 +--- docs/resources/{vw_hive.md => dw_vw_hive.md} | 29 ++++++++++++++----- docs/resources/environments_aws_credential.md | 8 ++--- docs/resources/iam_group.md | 2 +- .../resource.tf | 2 +- .../resource.tf | 8 ++--- resources/dw/resource_dw_acc_test.go | 2 +- .../virtualwarehouse/hive/resource_hive_vw.go | 2 +- .../hive/resource_hive_vw_acc_test.go | 10 +++---- .../hive/resource_hive_vw_test.go | 5 ++-- .../virtualwarehouse/hive/schema_hive_vw.go | 1 + templates/resources/dw_aws_cluster.md.tmpl | 26 +++++++++++++++++ .../resources/dw_database_catalog.md.tmpl | 26 +++++++++++++++++ templates/resources/dw_vw_hive.md.tmpl | 26 +++++++++++++++++ templates/resources/iam_group.md.tmpl | 2 +- 16 files changed, 124 insertions(+), 35 deletions(-) rename docs/resources/{vw_hive.md => dw_vw_hive.md} (56%) rename examples/resources/{cdp_dw_hive => cdp_dw_vw_hive}/resource.tf (94%) create mode 100644 templates/resources/dw_aws_cluster.md.tmpl create mode 100644 templates/resources/dw_database_catalog.md.tmpl create mode 100644 templates/resources/dw_vw_hive.md.tmpl diff --git a/docs/resources/dw_aws_cluster.md b/docs/resources/dw_aws_cluster.md index 719740f5..a678f4fc 100644 --- a/docs/resources/dw_aws_cluster.md +++ b/docs/resources/dw_aws_cluster.md @@ -1,7 +1,6 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "cdp_dw_aws_cluster Resource - terraform-provider-cdp" -subcategory: "" +subcategory: "Data Warehouse" description: |- Creates an AWS Data Warehouse cluster. --- @@ -134,5 +133,3 @@ Optional: - `async` (Boolean) Boolean value that specifies if Terraform should wait for resource creation/deletion. - `call_failure_threshold` (Number) Threshold value that specifies how many times should a single call failure happen before giving up the polling. - `polling_timeout` (Number) Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion. - - diff --git a/docs/resources/dw_database_catalog.md b/docs/resources/dw_database_catalog.md index 3a2c8eb1..31c7c0e3 100644 --- a/docs/resources/dw_database_catalog.md +++ b/docs/resources/dw_database_catalog.md @@ -1,7 +1,6 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "cdp_dw_database_catalog Resource - terraform-provider-cdp" -subcategory: "" +subcategory: "Data Warehouse" description: |- Creates an AWS Data Warehouse database catalog. --- @@ -38,5 +37,3 @@ Optional: - `async` (Boolean) Boolean value that specifies if Terraform should wait for resource creation/deletion. - `call_failure_threshold` (Number) Threshold value that specifies how many times should a single call failure happen before giving up the polling. - `polling_timeout` (Number) Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion. - - diff --git a/docs/resources/vw_hive.md b/docs/resources/dw_vw_hive.md similarity index 56% rename from docs/resources/vw_hive.md rename to docs/resources/dw_vw_hive.md index accce7fd..deb6a33f 100644 --- a/docs/resources/vw_hive.md +++ b/docs/resources/dw_vw_hive.md @@ -1,16 +1,33 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "cdp_vw_hive Resource - terraform-provider-cdp" -subcategory: "" +page_title: "cdp_dw_vw_hive Resource - terraform-provider-cdp" +subcategory: "Data Warehouse" description: |- - + A Hive Virtual Warehouse is service which is able to run big SQL queries. --- -# cdp_vw_hive (Resource) +# cdp_dw_vw_hive (Resource) +A Hive Virtual Warehouse is service which is able to run big SQL queries. +## Example Usage +```terraform +## Copyright 2024 Cloudera. All Rights Reserved. +# +# This file is 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. +# +# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +# OF ANY KIND, either express or implied. Refer to the License for the specific +# permissions and limitations governing your use of the file. +resource "cdp_dw_vw_hive" "example" { + cluster_id = var.cluster_id + database_catalog_id = var.database_catalog_id + name = var.name +} +``` ## Schema @@ -39,5 +56,3 @@ Optional: - `async` (Boolean) Boolean value that specifies if Terraform should wait for resource creation/deletion. - `call_failure_threshold` (Number) Threshold value that specifies how many times should a single call failure happen before giving up the polling. - `polling_timeout` (Number) Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion. - - diff --git a/docs/resources/environments_aws_credential.md b/docs/resources/environments_aws_credential.md index 33bf6c4d..440be2aa 100644 --- a/docs/resources/environments_aws_credential.md +++ b/docs/resources/environments_aws_credential.md @@ -23,11 +23,11 @@ The AWS credential is used for authorization to provision resources such as comp # permissions and limitations governing your use of the file. resource "cdp_environments_aws_credential" "example" { - credential_name = "example-cdp-aws-credential" - role_arn = "arn:aws:iam::11111111111:role/example-cross-account-role" - description = "Example AWS Credentials" + credential_name = "example-cdp-aws-credential" + role_arn = "arn:aws:iam::11111111111:role/example-cross-account-role" + description = "Example AWS Credentials" skip_org_policy_decisions = false - verify_permissions = false + verify_permissions = false } output "credential_name" { diff --git a/docs/resources/iam_group.md b/docs/resources/iam_group.md index c3cc8a1a..3c72a670 100644 --- a/docs/resources/iam_group.md +++ b/docs/resources/iam_group.md @@ -46,4 +46,4 @@ output "crn" { ### Read-Only - `crn` (String) The CRN of the resource. -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. diff --git a/examples/resources/cdp_dw_hive/resource.tf b/examples/resources/cdp_dw_vw_hive/resource.tf similarity index 94% rename from examples/resources/cdp_dw_hive/resource.tf rename to examples/resources/cdp_dw_vw_hive/resource.tf index f14a1df1..c4094659 100644 --- a/examples/resources/cdp_dw_hive/resource.tf +++ b/examples/resources/cdp_dw_vw_hive/resource.tf @@ -8,7 +8,7 @@ # OF ANY KIND, either express or implied. Refer to the License for the specific # permissions and limitations governing your use of the file. -resource "cdp_vw_hive" "example" { +resource "cdp_dw_vw_hive" "example" { cluster_id = var.cluster_id database_catalog_id = var.database_catalog_id name = var.name diff --git a/examples/resources/cdp_environments_aws_credential/resource.tf b/examples/resources/cdp_environments_aws_credential/resource.tf index ab185c47..30007fb2 100644 --- a/examples/resources/cdp_environments_aws_credential/resource.tf +++ b/examples/resources/cdp_environments_aws_credential/resource.tf @@ -9,11 +9,11 @@ # permissions and limitations governing your use of the file. resource "cdp_environments_aws_credential" "example" { - credential_name = "example-cdp-aws-credential" - role_arn = "arn:aws:iam::11111111111:role/example-cross-account-role" - description = "Example AWS Credentials" + credential_name = "example-cdp-aws-credential" + role_arn = "arn:aws:iam::11111111111:role/example-cross-account-role" + description = "Example AWS Credentials" skip_org_policy_decisions = false - verify_permissions = false + verify_permissions = false } output "credential_name" { diff --git a/resources/dw/resource_dw_acc_test.go b/resources/dw/resource_dw_acc_test.go index efd5f3f5..c70e7c72 100644 --- a/resources/dw/resource_dw_acc_test.go +++ b/resources/dw/resource_dw_acc_test.go @@ -279,7 +279,7 @@ func testAccDwCatalog() string { func testAccHiveVirtualWarehouse(name string) string { return fmt.Sprintf(` - resource "cdp_vw_hive" "test_hive" { + resource "cdp_dw_vw_hive" "test_hive" { cluster_id = cdp_dw_aws_cluster.test_data_warehouse_aws.cluster_id database_catalog_id = cdp_dw_database_catalog.test_catalog.id name = %[1]q diff --git a/resources/dw/virtualwarehouse/hive/resource_hive_vw.go b/resources/dw/virtualwarehouse/hive/resource_hive_vw.go index 8f616a88..1b18bd2d 100644 --- a/resources/dw/virtualwarehouse/hive/resource_hive_vw.go +++ b/resources/dw/virtualwarehouse/hive/resource_hive_vw.go @@ -51,7 +51,7 @@ func (r *hiveResource) Configure(_ context.Context, req resource.ConfigureReques } func (r *hiveResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_vw_hive" + resp.TypeName = req.ProviderTypeName + "_dw_vw_hive" } func (r *hiveResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/resources/dw/virtualwarehouse/hive/resource_hive_vw_acc_test.go b/resources/dw/virtualwarehouse/hive/resource_hive_vw_acc_test.go index 6cd4eef4..cf9f4ced 100644 --- a/resources/dw/virtualwarehouse/hive/resource_hive_vw_acc_test.go +++ b/resources/dw/virtualwarehouse/hive/resource_hive_vw_acc_test.go @@ -64,9 +64,9 @@ func TestAccHive_basic(t *testing.T) { cdpacctest.TestAccCdpProviderConfig(), testAccHiveBasicConfig(params)), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("cdp_vw_hive.test_hive", "name", params.Name), - resource.TestCheckResourceAttr("cdp_vw_hive.test_hive", "cluster_id", params.ClusterID), - resource.TestCheckResourceAttr("cdp_vw_hive.test_hive", "database_catalog_id", params.DatabaseCatalogID), + resource.TestCheckResourceAttr("cdp_dw_vw_hive.test_hive", "name", params.Name), + resource.TestCheckResourceAttr("cdp_dw_vw_hive.test_hive", "cluster_id", params.ClusterID), + resource.TestCheckResourceAttr("cdp_dw_vw_hive.test_hive", "database_catalog_id", params.DatabaseCatalogID), ), }, // Delete testing automatically occurs in TestCase @@ -76,7 +76,7 @@ func TestAccHive_basic(t *testing.T) { func testAccHiveBasicConfig(params hiveTestParameters) string { return fmt.Sprintf(` - resource "cdp_vw_hive" "test_hive" { + resource "cdp_dw_vw_hive" "test_hive" { cluster_id = %[1]q database_catalog_id = %[2]q name = %[3]q @@ -86,7 +86,7 @@ func testAccHiveBasicConfig(params hiveTestParameters) string { func testCheckHiveDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { - if rs.Type != "cdp_vw_hive" { + if rs.Type != "cdp_dw_vw_hive" { continue } diff --git a/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go b/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go index a6f7d4fe..b107ffb0 100644 --- a/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go +++ b/resources/dw/virtualwarehouse/hive/resource_hive_vw_test.go @@ -36,6 +36,7 @@ import ( ) var testHiveSchema = schema.Schema{ + MarkdownDescription: "A Hive Virtual Warehouse is service which is able to run big SQL queries.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, @@ -174,10 +175,10 @@ func (suite *HiveTestSuite) TestHiveMetadata() { // Function under test dwApi.Metadata( context.TODO(), - resource.MetadataRequest{ProviderTypeName: "dw"}, + resource.MetadataRequest{ProviderTypeName: "cdp"}, &resp, ) - suite.Equal("dw_vw_hive", resp.TypeName) + suite.Equal("cdp_dw_vw_hive", resp.TypeName) } func (suite *HiveTestSuite) TestHiveSchema() { diff --git a/resources/dw/virtualwarehouse/hive/schema_hive_vw.go b/resources/dw/virtualwarehouse/hive/schema_hive_vw.go index db865a75..54babd09 100644 --- a/resources/dw/virtualwarehouse/hive/schema_hive_vw.go +++ b/resources/dw/virtualwarehouse/hive/schema_hive_vw.go @@ -20,6 +20,7 @@ import ( ) var hiveSchema = schema.Schema{ + MarkdownDescription: "A Hive Virtual Warehouse is service which is able to run big SQL queries.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, diff --git a/templates/resources/dw_aws_cluster.md.tmpl b/templates/resources/dw_aws_cluster.md.tmpl new file mode 100644 index 00000000..48bbee41 --- /dev/null +++ b/templates/resources/dw_aws_cluster.md.tmpl @@ -0,0 +1,26 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "Data Warehouse" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} + +{{- if .HasImport }} +## Import + +Import is supported using the following syntax: + +{{codefile "shell" .ImportFile }} +{{- end }} diff --git a/templates/resources/dw_database_catalog.md.tmpl b/templates/resources/dw_database_catalog.md.tmpl new file mode 100644 index 00000000..48bbee41 --- /dev/null +++ b/templates/resources/dw_database_catalog.md.tmpl @@ -0,0 +1,26 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "Data Warehouse" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} + +{{- if .HasImport }} +## Import + +Import is supported using the following syntax: + +{{codefile "shell" .ImportFile }} +{{- end }} diff --git a/templates/resources/dw_vw_hive.md.tmpl b/templates/resources/dw_vw_hive.md.tmpl new file mode 100644 index 00000000..48bbee41 --- /dev/null +++ b/templates/resources/dw_vw_hive.md.tmpl @@ -0,0 +1,26 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "Data Warehouse" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} + +{{- if .HasImport }} +## Import + +Import is supported using the following syntax: + +{{codefile "shell" .ImportFile }} +{{- end }} diff --git a/templates/resources/iam_group.md.tmpl b/templates/resources/iam_group.md.tmpl index c971996d..a7b36e87 100644 --- a/templates/resources/iam_group.md.tmpl +++ b/templates/resources/iam_group.md.tmpl @@ -23,4 +23,4 @@ description: |- Import is supported using the following syntax: {{codefile "shell" .ImportFile }} -{{- end }} \ No newline at end of file +{{- end }}