Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promoting Managed Kafka Cluster and Topic resources to GA #20237

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/12264.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_managed_kafka_cluster` and `google_managed_kafka_topic` (ga)
```
1 change: 1 addition & 0 deletions google/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type ProviderModel struct {
KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"`
LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"`
LookerCustomEndpoint types.String `tfsdk:"looker_custom_endpoint"`
ManagedKafkaCustomEndpoint types.String `tfsdk:"managed_kafka_custom_endpoint"`
MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"`
MemorystoreCustomEndpoint types.String `tfsdk:"memorystore_custom_endpoint"`
MigrationCenterCustomEndpoint types.String `tfsdk:"migration_center_custom_endpoint"`
Expand Down
6 changes: 6 additions & 0 deletions google/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"managed_kafka_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"memcache_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
10 changes: 10 additions & 0 deletions google/fwtransport/framework_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ type FrameworkProviderConfig struct {
KMSBasePath string
LoggingBasePath string
LookerBasePath string
ManagedKafkaBasePath string
MemcacheBasePath string
MemorystoreBasePath string
MigrationCenterBasePath string
Expand Down Expand Up @@ -306,6 +307,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
p.KMSBasePath = data.KMSCustomEndpoint.ValueString()
p.LoggingBasePath = data.LoggingCustomEndpoint.ValueString()
p.LookerBasePath = data.LookerCustomEndpoint.ValueString()
p.ManagedKafkaBasePath = data.ManagedKafkaCustomEndpoint.ValueString()
p.MemcacheBasePath = data.MemcacheCustomEndpoint.ValueString()
p.MemorystoreBasePath = data.MemorystoreCustomEndpoint.ValueString()
p.MigrationCenterBasePath = data.MigrationCenterCustomEndpoint.ValueString()
Expand Down Expand Up @@ -1117,6 +1119,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
data.LookerCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.ManagedKafkaCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_MANAGED_KAFKA_CUSTOM_ENDPOINT",
}, transport_tpg.DefaultBasePaths[transport_tpg.ManagedKafkaBasePathKey])
if customEndpoint != nil {
data.ManagedKafkaCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.MemcacheCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_MEMCACHE_CUSTOM_ENDPOINT",
Expand Down
6 changes: 6 additions & 0 deletions google/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"managed_kafka_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"memcache_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1039,6 +1044,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.KMSBasePath = d.Get("kms_custom_endpoint").(string)
config.LoggingBasePath = d.Get("logging_custom_endpoint").(string)
config.LookerBasePath = d.Get("looker_custom_endpoint").(string)
config.ManagedKafkaBasePath = d.Get("managed_kafka_custom_endpoint").(string)
config.MemcacheBasePath = d.Get("memcache_custom_endpoint").(string)
config.MemorystoreBasePath = d.Get("memorystore_custom_endpoint").(string)
config.MigrationCenterBasePath = d.Get("migration_center_custom_endpoint").(string)
Expand Down
7 changes: 5 additions & 2 deletions google/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import (
"github.com/hashicorp/terraform-provider-google/google/services/kms"
"github.com/hashicorp/terraform-provider-google/google/services/logging"
"github.com/hashicorp/terraform-provider-google/google/services/looker"
"github.com/hashicorp/terraform-provider-google/google/services/managedkafka"
"github.com/hashicorp/terraform-provider-google/google/services/memcache"
"github.com/hashicorp/terraform-provider-google/google/services/memorystore"
"github.com/hashicorp/terraform-provider-google/google/services/migrationcenter"
Expand Down Expand Up @@ -452,9 +453,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 485
// Generated resources: 487
// Generated IAM resources: 261
// Total generated resources: 746
// Total generated resources: 748
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -967,6 +968,8 @@ var generatedResources = map[string]*schema.Resource{
"google_logging_metric": logging.ResourceLoggingMetric(),
"google_logging_organization_settings": logging.ResourceLoggingOrganizationSettings(),
"google_looker_instance": looker.ResourceLookerInstance(),
"google_managed_kafka_cluster": managedkafka.ResourceManagedKafkaCluster(),
"google_managed_kafka_topic": managedkafka.ResourceManagedKafkaTopic(),
"google_memcache_instance": memcache.ResourceMemcacheInstance(),
"google_memorystore_instance": memorystore.ResourceMemorystoreInstance(),
"google_migration_center_group": migrationcenter.ResourceMigrationCenterGroup(),
Expand Down
92 changes: 92 additions & 0 deletions google/services/managedkafka/managed_kafka_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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 managedkafka

import (
"encoding/json"
"errors"
"fmt"
"time"

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

type ManagedKafkaOperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *ManagedKafkaOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ManagedKafkaBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createManagedKafkaWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ManagedKafkaOperationWaiter, error) {
w := &ManagedKafkaOperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func ManagedKafkaOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createManagedKafkaWaiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
if len(rawResponse) == 0 {
return errors.New("`resource` not set in operation response")
}
return json.Unmarshal(rawResponse, response)
}

func ManagedKafkaOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createManagedKafkaWaiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
}
Loading