Skip to content

Commit

Permalink
feat: add the new resource: google_dataform_repository_release_config (
Browse files Browse the repository at this point in the history
…#8511) (#6009)

* feat: add the new resource: google_dataform_repository_release_config

* Fix `recentScheduledReleaseRecords` name

* Fix linting

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 3, 2023
1 parent 5e49ac4 commit 817d19f
Show file tree
Hide file tree
Showing 6 changed files with 1,288 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/8511.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
google_dataform_repository_release_config (beta)
```
5 changes: 3 additions & 2 deletions google-beta/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,9 @@ func DatasourceMapWithErrors() (map[string]*schema.Resource, error) {
})
}

// Generated resources: 361
// Generated resources: 362
// Generated IAM resources: 234
// Total generated resources: 595
// Total generated resources: 596
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -1361,6 +1361,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_data_catalog_taxonomy_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc),
"google_data_catalog_taxonomy_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc),
"google_dataform_repository": dataform.ResourceDataformRepository(),
"google_dataform_repository_release_config": dataform.ResourceDataformRepositoryReleaseConfig(),
"google_data_fusion_instance": datafusion.ResourceDataFusionInstance(),
"google_data_fusion_instance_iam_binding": tpgiamresource.ResourceIamBinding(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc),
"google_data_fusion_instance_iam_member": tpgiamresource.ResourceIamMember(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** 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.
//
// ----------------------------------------------------------------------------

package google

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

func TestAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
CheckDestroy: testAccCheckDataformRepositoryReleaseConfigDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(context),
},
{
ResourceName: "google_dataform_repository_release_config.release",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region", "repository"},
},
},
})
}

func testAccDataformRepositoryReleaseConfig_dataformRepositoryReleaseConfigExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_sourcerepo_repository" "git_repository" {
provider = google-beta
name = "my/repository%{random_suffix}"
}
resource "google_secret_manager_secret" "secret" {
provider = google-beta
secret_id = "secret"
replication {
automatic = true
}
}
resource "google_secret_manager_secret_version" "secret_version" {
provider = google-beta
secret = google_secret_manager_secret.secret.id
secret_data = "tf-test-secret-data%{random_suffix}"
}
resource "google_dataform_repository" "repository" {
provider = google-beta
name = "tf_test_dataform_repository%{random_suffix}"
region = "us-central1"
git_remote_settings {
url = google_sourcerepo_repository.git_repository.url
default_branch = "main"
authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id
}
workspace_compilation_overrides {
default_database = "database"
schema_suffix = "_suffix"
table_prefix = "prefix_"
}
}
resource "google_dataform_repository_release_config" "release" {
provider = google-beta
project = google_dataform_repository.repository.project
region = google_dataform_repository.repository.region
repository = google_dataform_repository.repository.name
name = "tf_test_my_release%{random_suffix}"
git_commitish = "main"
cron_schedule = "0 7 * * *"
time_zone = "America/New_York"
code_compilation_config {
default_database = "gcp-example-project"
default_schema = "example-dataset"
default_location = "us-central1"
assertion_schema = "example-assertion-dataset"
database_suffix = ""
schema_suffix = ""
table_prefix = ""
vars = {
var1 = "value"
}
}
}
`, context)
}

func testAccCheckDataformRepositoryReleaseConfigDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_dataform_repository_release_config" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}

config := acctest.GoogleProviderConfig(t)

url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{DataformBasePath}}projects/{{project}}/locations/{{region}}/repositories/{{repository}}/releaseConfigs/{{name}}")
if err != nil {
return err
}

billingProject := ""

if config.BillingProject != "" {
billingProject = config.BillingProject
}

_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: config.UserAgent,
})
if err == nil {
return fmt.Errorf("DataformRepositoryReleaseConfig still exists at %s", url)
}
}

return nil
}
}
Loading

0 comments on commit 817d19f

Please sign in to comment.