From a1c4554c2d7632bdad3f3525aff25c799073c780 Mon Sep 17 00:00:00 2001 From: stephybun Date: Wed, 16 Aug 2023 17:51:39 +0200 Subject: [PATCH] add current_kubernetes_version to data source (#22986) --- .../kubernetes_cluster_data_source.go | 17 ++++++++++++----- website/docs/d/kubernetes_cluster.html.markdown | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_data_source.go b/internal/services/containers/kubernetes_cluster_data_source.go index 10577db2a209..9e7006bb941c 100644 --- a/internal/services/containers/kubernetes_cluster_data_source.go +++ b/internal/services/containers/kubernetes_cluster_data_source.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" @@ -202,6 +203,11 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource { Computed: true, }, + "current_kubernetes_version": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "dns_prefix": { Type: pluginsdk.TypeString, Computed: true, @@ -738,11 +744,12 @@ func dataSourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{} d.Set("location", location.Normalize(model.Location)) if props := model.Properties; props != nil { - d.Set("dns_prefix", props.DnsPrefix) - d.Set("fqdn", props.Fqdn) - d.Set("disk_encryption_set_id", props.DiskEncryptionSetID) - d.Set("private_fqdn", props.PrivateFQDN) - d.Set("kubernetes_version", props.KubernetesVersion) + d.Set("dns_prefix", pointer.From(props.DnsPrefix)) + d.Set("fqdn", pointer.From(props.Fqdn)) + d.Set("disk_encryption_set_id", pointer.From(props.DiskEncryptionSetID)) + d.Set("private_fqdn", pointer.From(props.PrivateFQDN)) + d.Set("kubernetes_version", pointer.From(props.KubernetesVersion)) + d.Set("current_kubernetes_version", pointer.From(props.CurrentKubernetesVersion)) nodeResourceGroup := "" if v := props.NodeResourceGroup; v != nil { diff --git a/website/docs/d/kubernetes_cluster.html.markdown b/website/docs/d/kubernetes_cluster.html.markdown index 52194d26d15f..0f3f465ce69c 100644 --- a/website/docs/d/kubernetes_cluster.html.markdown +++ b/website/docs/d/kubernetes_cluster.html.markdown @@ -46,6 +46,8 @@ The following attributes are exported: * `agent_pool_profile` - An `agent_pool_profile` block as documented below. +* `current_kubernetes_version` - Contains the current version of Kubernetes running on the Cluster. + * `dns_prefix` - The DNS Prefix of the managed Kubernetes cluster. * `fqdn` - The FQDN of the Azure Kubernetes Managed Cluster.