Skip to content

Commit

Permalink
hdinsight_kafka_cluster_resource: deprecate kafka_management_node
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaweitao001 committed Nov 24, 2022
1 parent 4c84e28 commit 13e6714
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
46 changes: 44 additions & 2 deletions internal/services/hdinsight/hdinsight_kafka_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -52,7 +53,7 @@ var hdInsightKafkaClusterKafkaManagementNodeDefinition = HDInsightNodeDefinition
}

func resourceHDInsightKafkaCluster() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Create: resourceHDInsightKafkaClusterCreate,
Read: resourceHDInsightKafkaClusterRead,
Update: hdinsightClusterUpdate("Kafka", resourceHDInsightKafkaClusterRead),
Expand Down Expand Up @@ -158,7 +159,12 @@ func resourceHDInsightKafkaCluster() *pluginsdk.Resource {
},
},
},
RequiredWith: []string{"roles.0.kafka_management_node"},
RequiredWith: func() []string {
if !features.FourPointOh() {
return []string{"roles.0.kafka_management_node"}
}
return []string{}
}(),
},

"tags": tags.Schema(),
Expand All @@ -183,6 +189,42 @@ func resourceHDInsightKafkaCluster() *pluginsdk.Resource {
"extension": SchemaHDInsightsExtension(),
},
}

if !features.FourPointOh() {
resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightKafkaClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightKafkaClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightKafkaClusterZookeeperNodeDefinition, true),

"kafka_management_node": SchemaHDInsightNodeDefinition("roles.0.kafka_management_node", hdInsightKafkaClusterKafkaManagementNodeDefinition, false),
},
},
}

resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightKafkaClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightKafkaClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightKafkaClusterZookeeperNodeDefinition, true),
},
},
}
}

return resource
}

func resourceHDInsightKafkaClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/hdinsight_kafka_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ A `roles` block supports the following:

* `kafka_management_node` - (Optional) A `kafka_management_node` block as defined below.

~> **Note:** This property has been deprecated and will be removed in version 4.0.

---

A `network` block supports the following:
Expand Down

0 comments on commit 13e6714

Please sign in to comment.