Skip to content

Commit 89cd3e8

Browse files
Promoting Managed Kafka Cluster and Topic resources to GA (#12264) (#20237)
[upstream:a8a545fe5d66b53f6ec872743137bfb426669232] Signed-off-by: Modular Magician <[email protected]>
1 parent 04253f5 commit 89cd3e8

21 files changed

+2191
-16
lines changed

.changelog/12264.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_managed_kafka_cluster` and `google_managed_kafka_topic` (ga)
3+
```

google/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ type ProviderModel struct {
108108
KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"`
109109
LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"`
110110
LookerCustomEndpoint types.String `tfsdk:"looker_custom_endpoint"`
111+
ManagedKafkaCustomEndpoint types.String `tfsdk:"managed_kafka_custom_endpoint"`
111112
MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"`
112113
MemorystoreCustomEndpoint types.String `tfsdk:"memorystore_custom_endpoint"`
113114
MigrationCenterCustomEndpoint types.String `tfsdk:"migration_center_custom_endpoint"`

google/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
616616
transport_tpg.CustomEndpointValidator(),
617617
},
618618
},
619+
"managed_kafka_custom_endpoint": &schema.StringAttribute{
620+
Optional: true,
621+
Validators: []validator.String{
622+
transport_tpg.CustomEndpointValidator(),
623+
},
624+
},
619625
"memcache_custom_endpoint": &schema.StringAttribute{
620626
Optional: true,
621627
Validators: []validator.String{

google/fwtransport/framework_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ type FrameworkProviderConfig struct {
142142
KMSBasePath string
143143
LoggingBasePath string
144144
LookerBasePath string
145+
ManagedKafkaBasePath string
145146
MemcacheBasePath string
146147
MemorystoreBasePath string
147148
MigrationCenterBasePath string
@@ -306,6 +307,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
306307
p.KMSBasePath = data.KMSCustomEndpoint.ValueString()
307308
p.LoggingBasePath = data.LoggingCustomEndpoint.ValueString()
308309
p.LookerBasePath = data.LookerCustomEndpoint.ValueString()
310+
p.ManagedKafkaBasePath = data.ManagedKafkaCustomEndpoint.ValueString()
309311
p.MemcacheBasePath = data.MemcacheCustomEndpoint.ValueString()
310312
p.MemorystoreBasePath = data.MemorystoreCustomEndpoint.ValueString()
311313
p.MigrationCenterBasePath = data.MigrationCenterCustomEndpoint.ValueString()
@@ -1117,6 +1119,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
11171119
data.LookerCustomEndpoint = types.StringValue(customEndpoint.(string))
11181120
}
11191121
}
1122+
if data.ManagedKafkaCustomEndpoint.IsNull() {
1123+
customEndpoint := transport_tpg.MultiEnvDefault([]string{
1124+
"GOOGLE_MANAGED_KAFKA_CUSTOM_ENDPOINT",
1125+
}, transport_tpg.DefaultBasePaths[transport_tpg.ManagedKafkaBasePathKey])
1126+
if customEndpoint != nil {
1127+
data.ManagedKafkaCustomEndpoint = types.StringValue(customEndpoint.(string))
1128+
}
1129+
}
11201130
if data.MemcacheCustomEndpoint.IsNull() {
11211131
customEndpoint := transport_tpg.MultiEnvDefault([]string{
11221132
"GOOGLE_MEMCACHE_CUSTOM_ENDPOINT",

google/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,11 @@ func Provider() *schema.Provider {
535535
Optional: true,
536536
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
537537
},
538+
"managed_kafka_custom_endpoint": {
539+
Type: schema.TypeString,
540+
Optional: true,
541+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
542+
},
538543
"memcache_custom_endpoint": {
539544
Type: schema.TypeString,
540545
Optional: true,
@@ -1039,6 +1044,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
10391044
config.KMSBasePath = d.Get("kms_custom_endpoint").(string)
10401045
config.LoggingBasePath = d.Get("logging_custom_endpoint").(string)
10411046
config.LookerBasePath = d.Get("looker_custom_endpoint").(string)
1047+
config.ManagedKafkaBasePath = d.Get("managed_kafka_custom_endpoint").(string)
10421048
config.MemcacheBasePath = d.Get("memcache_custom_endpoint").(string)
10431049
config.MemorystoreBasePath = d.Get("memorystore_custom_endpoint").(string)
10441050
config.MigrationCenterBasePath = d.Get("migration_center_custom_endpoint").(string)

google/provider/provider_mmv1_resources.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import (
8181
"github.com/hashicorp/terraform-provider-google/google/services/kms"
8282
"github.com/hashicorp/terraform-provider-google/google/services/logging"
8383
"github.com/hashicorp/terraform-provider-google/google/services/looker"
84+
"github.com/hashicorp/terraform-provider-google/google/services/managedkafka"
8485
"github.com/hashicorp/terraform-provider-google/google/services/memcache"
8586
"github.com/hashicorp/terraform-provider-google/google/services/memorystore"
8687
"github.com/hashicorp/terraform-provider-google/google/services/migrationcenter"
@@ -452,9 +453,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
452453
}
453454

454455
// Resources
455-
// Generated resources: 485
456+
// Generated resources: 487
456457
// Generated IAM resources: 261
457-
// Total generated resources: 746
458+
// Total generated resources: 748
458459
var generatedResources = map[string]*schema.Resource{
459460
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
460461
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -967,6 +968,8 @@ var generatedResources = map[string]*schema.Resource{
967968
"google_logging_metric": logging.ResourceLoggingMetric(),
968969
"google_logging_organization_settings": logging.ResourceLoggingOrganizationSettings(),
969970
"google_looker_instance": looker.ResourceLookerInstance(),
971+
"google_managed_kafka_cluster": managedkafka.ResourceManagedKafkaCluster(),
972+
"google_managed_kafka_topic": managedkafka.ResourceManagedKafkaTopic(),
970973
"google_memcache_instance": memcache.ResourceMemcacheInstance(),
971974
"google_memorystore_instance": memorystore.ResourceMemorystoreInstance(),
972975
"google_migration_center_group": migrationcenter.ResourceMigrationCenterGroup(),
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package managedkafka
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
28+
)
29+
30+
type ManagedKafkaOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *ManagedKafkaOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.ManagedKafkaBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createManagedKafkaWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ManagedKafkaOperationWaiter, error) {
54+
w := &ManagedKafkaOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func ManagedKafkaOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createManagedKafkaWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func ManagedKafkaOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createManagedKafkaWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)