Skip to content

Commit

Permalink
Adding Support to update DataCatalog TagTemplate fields (#6803)
Browse files Browse the repository at this point in the history
fixes hashicorp/terraform-provider-google#6574

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Dec 12, 2022
1 parent 943d5a7 commit f31b02c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
46 changes: 46 additions & 0 deletions converters/google/resources/datacatalog_tag_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,57 @@
package google

import (
"fmt"
"log"
"reflect"

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

//Use it to delete TagTemplate Field
func deleteTagTemplateField(d *schema.ResourceData, config *Config, name, billingProject, userAgent string) error {

url_delete, err := replaceVars(d, config, "{{DataCatalogBasePath}}{{name}}/fields/"+name+"?force={{force_delete}}")
if err != nil {
return err
}
var obj map[string]interface{}
res, err := sendRequestWithTimeout(config, "DELETE", billingProject, url_delete, userAgent, obj, d.Timeout(schema.TimeoutDelete))
if err != nil {
return fmt.Errorf("Error deleting TagTemplate Field %v: %s", name, err)
}

log.Printf("[DEBUG] Finished deleting TagTemplate Field %q: %#v", name, res)
return nil
}

//Use it to create TagTemplate Field
func createTagTemplateField(d *schema.ResourceData, config *Config, body map[string]interface{}, name, billingProject, userAgent string) error {

url_create, err := replaceVars(d, config, "{{DataCatalogBasePath}}{{name}}/fields")
if err != nil {
return err
}

url_create, err = addQueryParams(url_create, map[string]string{"tagTemplateFieldId": name})
if err != nil {
return err
}

res_create, err := sendRequestWithTimeout(config, "POST", billingProject, url_create, userAgent, body, d.Timeout(schema.TimeoutCreate))
if err != nil {
return fmt.Errorf("Error creating TagTemplate Field: %s", err)
}

if err != nil {
return fmt.Errorf("Error creating TagTemplate Field %v: %s", name, err)
} else {
log.Printf("[DEBUG] Finished creating TagTemplate Field %v: %#v", name, res_create)
}

return nil
}

const DataCatalogTagTemplateAssetType string = "datacatalog.googleapis.com/TagTemplate"

func resourceConverterDataCatalogTagTemplate() ResourceConverter {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/terraform-json v0.14.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221209230321-348619fa2dd2
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221212040814-3433c55b7ef9
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R
github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 h1:FtCLTiTcykdsURXPt/ku7fYXm3y19nbzbZcUxHx9RbI=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0/go.mod h1:80wf5oad1tW+oLnbXS4UTYmDCrl7BuN1Q+IA91X1a4Y=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221209230321-348619fa2dd2 h1:RFZvI9QgBqODe5AM3zxS0i0SBc2kUFhkkrgs5/VExl4=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221209230321-348619fa2dd2/go.mod h1:noO9KRFUJgJg9g+VaIqh0oUlr3GaDCtbFB+KD+iBgeI=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221212040814-3433c55b7ef9 h1:pB3Nb1dcB40XaEqmihq5HMDHlV+ajB9nQsIO7Sbt57s=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20221212040814-3433c55b7ef9/go.mod h1:noO9KRFUJgJg9g+VaIqh0oUlr3GaDCtbFB+KD+iBgeI=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
Expand Down

0 comments on commit f31b02c

Please sign in to comment.