Skip to content

Commit

Permalink
Fixed to use constant value for ClusterType
Browse files Browse the repository at this point in the history
  • Loading branch information
moremagic committed Jul 12, 2022
1 parent 6f86efb commit df05a43
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions internal/service/kafka/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,11 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
}

clusterType := d.Get("cluster_type").(string)
if clusterType == "serverless" {
if clusterType == kafka.ClusterTypeServerless {
if v, ok := d.GetOk("serverless"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
inputV2.Serverless = expandServerlessRequest(v.([]interface{})[0].(map[string]interface{}))
}
} else if clusterType == "provisioned" {
} else if clusterType == kafka.ClusterTypeProvisioned {
if v, ok := d.GetOk("provisioned"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
inputV2.Provisioned = expandProvisionedRequest(v.([]interface{})[0].(map[string]interface{}))
}
Expand Down Expand Up @@ -624,13 +624,13 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter
d.Set("current_version", cluster.CurrentVersion)

if cluster.Provisioned != nil {
d.Set("cluster_type", aws.String("provisioned"))
d.Set("cluster_type", aws.String(kafka.ClusterTypeProvisioned))
if err := d.Set("provisioned", []interface{}{flattenProvisioned(cluster.Provisioned)}); err != nil {
return diag.Errorf("setting provisioned: %s", err)
}
}
if cluster.Serverless != nil {
d.Set("cluster_type", aws.String("serverless"))
d.Set("cluster_type", aws.String(kafka.ClusterTypeServerless))
if err := d.Set("serverless", []interface{}{flattenServerless(cluster.Serverless)}); err != nil {
return diag.Errorf("setting serverless: %s", err)
}
Expand Down
56 changes: 28 additions & 28 deletions internal/service/kafka/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAccKafkaCluster_Basic_Provisioned(t *testing.T) {
resource.TestMatchResourceAttr(resourceName, "bootstrap_brokers_tls", clusterBoostrapBrokersTLSRegexp),
testAccCheckResourceAttrIsSortedCSV(resourceName, "bootstrap_brokers_tls"),
resource.TestCheckResourceAttr(resourceName, "cluster_name", rName),
resource.TestCheckResourceAttr(resourceName, "cluster_type", "provisioned"),
resource.TestCheckResourceAttr(resourceName, "cluster_type", kafka.ClusterTypeProvisioned),
resource.TestCheckResourceAttr(resourceName, "provisioned.0.broker_node_group_info.#", "1"),
resource.TestCheckResourceAttr(resourceName, "provisioned.0.broker_node_group_info.0.az_distribution", kafka.BrokerAZDistributionDefault),
resource.TestCheckResourceAttr(resourceName, "provisioned.0.broker_node_group_info.0.ebs_volume_size", "10"),
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestAccKafkaCluster_Basic_Serverless(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "bootstrap_brokers_public_tls", ""),
resource.TestCheckResourceAttr(resourceName, "bootstrap_brokers_sasl_scram", ""),
resource.TestCheckResourceAttr(resourceName, "cluster_name", rName),
resource.TestCheckResourceAttr(resourceName, "cluster_type", "serverless"),
resource.TestCheckResourceAttr(resourceName, "cluster_type", kafka.ClusterTypeServerless),
resource.TestCheckResourceAttr(resourceName, "serverless.0.client_authentication.0.sasl.0.iam", "true"),
resource.TestCheckResourceAttr(resourceName, "serverless.0.vpc_configs.0.security_group_ids.#", "1"),
resource.TestCheckTypeSetElemAttrPair(resourceName, "serverless.0.vpc_configs.0.security_group_ids.*", "aws_security_group.example_sg", "id"),
Expand Down Expand Up @@ -1473,7 +1473,7 @@ func testAccClusterConfig_basicProvisioned(rName string) string {
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1493,7 +1493,7 @@ func testAccClusterConfig_basicServerless(rName string) string {
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "serverless"
cluster_type = "SERVERLESS"
serverless {
client_authentication {
Expand All @@ -1515,7 +1515,7 @@ func testAccClusterConfig_deprecatedBrokerNodeGroupInfoEBSVolumeSize(rName strin
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1535,7 +1535,7 @@ func testAccClusterConfig_brokerNodeGroupInfoStorageInfoVolumeSizeOnly(rName str
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1559,7 +1559,7 @@ func testAccClusterConfig_brokerNodeGroupInfoStorageInfoVolumeSizeSetAndProvThro
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1586,7 +1586,7 @@ func testAccClusterConfig_brokerNodeGroupInfoStorageInfoVolumeSizeSetAndProvThro
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1614,7 +1614,7 @@ func testAccClusterConfig_brokerNodeGroupInfoInstanceType(rName string, t string
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1649,7 +1649,7 @@ func testAccClusterConfig_brokerNodeGroupInfoNoPublicAccessSASLIAM(rName string)
fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1683,7 +1683,7 @@ func testAccClusterConfig_brokerNodeGroupInfoPublicAccessSASLIAM(rName string, p
fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1742,7 +1742,7 @@ func testAccClusterConfig_clientAuthenticationTLSCertificateAuthorityARNs(rName,
fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1782,7 +1782,7 @@ func testAccClusterConfig_rootCANoClientAuthentication(rName, commonName string)
fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1809,7 +1809,7 @@ func testAccClusterConfig_clientAuthenticationSASLScram(rName string, scramEnabl
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1837,7 +1837,7 @@ func testAccClusterConfig_clientAuthenticationSASLIAM(rName string, saslEnabled
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1872,7 +1872,7 @@ PROPERTIES
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1915,7 +1915,7 @@ PROPERTIES
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -1948,7 +1948,7 @@ resource "aws_kms_key" "example_key" {
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1973,7 +1973,7 @@ func testAccClusterConfig_encryptionInfoEncryptionInTransitClientBroker(rName, c
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -1999,7 +1999,7 @@ func testAccClusterConfig_encryptionInfoEncryptionInTransitIn(rName string, inCl
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -2025,7 +2025,7 @@ func testAccClusterConfig_enhancedMonitoring(rName, enhancedMonitoring string) s
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -2047,7 +2047,7 @@ func testAccClusterConfig_numberOfBrokerNodes(rName string, brokerCount int) str
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -2068,7 +2068,7 @@ func testAccClusterConfig_openMonitoring(rName string, jmxExporterEnabled bool,
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -2169,7 +2169,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down Expand Up @@ -2207,7 +2207,7 @@ func testAccClusterConfig_version(rName string, kafkaVersion string) string {
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = %[2]q
Expand Down Expand Up @@ -2256,7 +2256,7 @@ PROPERTIES
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = %[2]q
Expand Down Expand Up @@ -2287,7 +2287,7 @@ func testAccClusterConfig_tags1(rName, tagKey1, tagValue1 string) string {
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand All @@ -2312,7 +2312,7 @@ func testAccClusterConfig_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 st
return acctest.ConfigCompose(testAccClusterBaseConfig(rName), fmt.Sprintf(`
resource "aws_msk_cluster" "test" {
cluster_name = %[1]q
cluster_type = "provisioned"
cluster_type = "PROVISIONED"
provisioned {
kafka_version = "2.7.1"
Expand Down

0 comments on commit df05a43

Please sign in to comment.