Skip to content

Commit 8065121

Browse files
Add google_dataproc_metastore_service (#4486) (#2977)
Signed-off-by: Modular Magician <[email protected]>
1 parent f6ee5c8 commit 8065121

13 files changed

+1475
-6
lines changed

.changelog/4486.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_dataproc_metastore_service`
3+
```

google-beta/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ type Config struct {
113113
DataFusionBasePath string
114114
DataLossPreventionBasePath string
115115
DataprocBasePath string
116+
DataprocMetastoreBasePath string
116117
DatastoreBasePath string
117118
DeploymentManagerBasePath string
118119
DialogflowBasePath string
@@ -208,6 +209,7 @@ var DataCatalogDefaultBasePath = "https://datacatalog.googleapis.com/v1beta1/"
208209
var DataFusionDefaultBasePath = "https://datafusion.googleapis.com/v1beta1/"
209210
var DataLossPreventionDefaultBasePath = "https://dlp.googleapis.com/v2/"
210211
var DataprocDefaultBasePath = "https://dataproc.googleapis.com/v1beta2/"
212+
var DataprocMetastoreDefaultBasePath = "https://metastore.googleapis.com/v1beta/"
211213
var DatastoreDefaultBasePath = "https://datastore.googleapis.com/v1/"
212214
var DeploymentManagerDefaultBasePath = "https://www.googleapis.com/deploymentmanager/v2/"
213215
var DialogflowDefaultBasePath = "https://dialogflow.googleapis.com/v2/"
@@ -1015,6 +1017,7 @@ func ConfigureBasePaths(c *Config) {
10151017
c.DataFusionBasePath = DataFusionDefaultBasePath
10161018
c.DataLossPreventionBasePath = DataLossPreventionDefaultBasePath
10171019
c.DataprocBasePath = DataprocDefaultBasePath
1020+
c.DataprocMetastoreBasePath = DataprocMetastoreDefaultBasePath
10181021
c.DatastoreBasePath = DatastoreDefaultBasePath
10191022
c.DeploymentManagerBasePath = DeploymentManagerDefaultBasePath
10201023
c.DialogflowBasePath = DialogflowDefaultBasePath
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
package google
15+
16+
import (
17+
"fmt"
18+
"time"
19+
)
20+
21+
type DataprocMetastoreOperationWaiter struct {
22+
Config *Config
23+
UserAgent string
24+
Project string
25+
CommonOperationWaiter
26+
}
27+
28+
func (w *DataprocMetastoreOperationWaiter) QueryOp() (interface{}, error) {
29+
if w == nil {
30+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
31+
}
32+
// Returns the proper get.
33+
url := fmt.Sprintf("https://metastore.googleapis.com/v1beta/%s", w.CommonOperationWaiter.Op.Name)
34+
35+
return sendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
36+
}
37+
38+
func createDataprocMetastoreWaiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*DataprocMetastoreOperationWaiter, error) {
39+
if val, ok := op["name"]; !ok || val == "" {
40+
// An operation could also be indicated with a "metadata" field.
41+
if _, ok := op["metadata"]; !ok {
42+
// This was a synchronous call - there is no operation to wait for.
43+
return nil, nil
44+
}
45+
}
46+
w := &DataprocMetastoreOperationWaiter{
47+
Config: config,
48+
UserAgent: userAgent,
49+
Project: project,
50+
}
51+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
52+
return nil, err
53+
}
54+
return w, nil
55+
}
56+
57+
func dataprocMetastoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
58+
w, err := createDataprocMetastoreWaiter(config, op, project, activity, userAgent)
59+
if err != nil || w == nil {
60+
// If w is nil, the op was synchronous.
61+
return err
62+
}
63+
return OperationWait(w, activity, timeout, config.PollInterval)
64+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package google
2+
3+
import (
4+
"strings"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
)
8+
9+
const dataprocMetastoreProvidedOverride = "hive.metastore.warehouse.dir"
10+
11+
func dataprocMetastoreServiceOverrideSuppress(k, old, new string, d *schema.ResourceData) bool {
12+
// Suppress diffs for the label provided by Google
13+
if strings.Contains(k, dataprocMetastoreProvidedOverride) && new == "" {
14+
return true
15+
}
16+
17+
// Let diff be determined by labels (above)
18+
if strings.Contains(k, "hive_metastore_config.0.config_overrides.%") {
19+
return true
20+
}
21+
22+
// For other keys, don't suppress diff.
23+
return false
24+
}

google-beta/provider.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ func Provider() *schema.Provider {
359359
"GOOGLE_DATAPROC_CUSTOM_ENDPOINT",
360360
}, DataprocDefaultBasePath),
361361
},
362+
"dataproc_metastore_custom_endpoint": {
363+
Type: schema.TypeString,
364+
Optional: true,
365+
ValidateFunc: validateCustomEndpoint,
366+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
367+
"GOOGLE_DATAPROC_METASTORE_CUSTOM_ENDPOINT",
368+
}, DataprocMetastoreDefaultBasePath),
369+
},
362370
"datastore_custom_endpoint": {
363371
Type: schema.TypeString,
364372
Optional: true,
@@ -810,9 +818,9 @@ func Provider() *schema.Provider {
810818
return provider
811819
}
812820

813-
// Generated resources: 209
821+
// Generated resources: 210
814822
// Generated IAM resources: 108
815-
// Total generated resources: 317
823+
// Total generated resources: 318
816824
func ResourceMap() map[string]*schema.Resource {
817825
resourceMap, _ := ResourceMapWithErrors()
818826
return resourceMap
@@ -998,6 +1006,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
9981006
"google_data_loss_prevention_stored_info_type": resourceDataLossPreventionStoredInfoType(),
9991007
"google_data_loss_prevention_deidentify_template": resourceDataLossPreventionDeidentifyTemplate(),
10001008
"google_dataproc_autoscaling_policy": resourceDataprocAutoscalingPolicy(),
1009+
"google_dataproc_metastore_service": resourceDataprocMetastoreService(),
10011010
"google_datastore_index": resourceDatastoreIndex(),
10021011
"google_deployment_manager_deployment": resourceDeploymentManagerDeployment(),
10031012
"google_dialogflow_agent": resourceDialogflowAgent(),
@@ -1356,6 +1365,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
13561365
config.DataFusionBasePath = d.Get("data_fusion_custom_endpoint").(string)
13571366
config.DataLossPreventionBasePath = d.Get("data_loss_prevention_custom_endpoint").(string)
13581367
config.DataprocBasePath = d.Get("dataproc_custom_endpoint").(string)
1368+
config.DataprocMetastoreBasePath = d.Get("dataproc_metastore_custom_endpoint").(string)
13591369
config.DatastoreBasePath = d.Get("datastore_custom_endpoint").(string)
13601370
config.DeploymentManagerBasePath = d.Get("deployment_manager_custom_endpoint").(string)
13611371
config.DialogflowBasePath = d.Get("dialogflow_custom_endpoint").(string)

google-beta/resource_dataflow_flex_template_job_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
11-
"google.golang.org/api/compute/v1"
11+
compute "google.golang.org/api/compute/v1"
1212
)
1313

1414
func TestAccDataflowFlexTemplateJob_basic(t *testing.T) {

0 commit comments

Comments
 (0)