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

Export FQDN for managed Kubernetes cluster #907

Merged
merged 2 commits into from
Mar 2, 2018
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
20 changes: 14 additions & 6 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func resourceArmKubernetesCluster() *schema.Resource {
Computed: true,
},

"fqdn": {
Type: schema.TypeString,
Computed: true,
},

"kubernetes_version": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -99,8 +104,9 @@ func resourceArmKubernetesCluster() *schema.Resource {
},

"fqdn": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: "This field has been deprecated. Use the parent `fqdn` instead",
},

"vm_size": {
Expand Down Expand Up @@ -246,14 +252,15 @@ func resourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{})
}
d.Set("resource_group_name", resGroup)
d.Set("dns_prefix", resp.DNSPrefix)
d.Set("fqdn", resp.Fqdn)
d.Set("kubernetes_version", resp.KubernetesVersion)

linuxProfile := flattenAzureRmKubernetesClusterLinuxProfile(*resp.ManagedClusterProperties.LinuxProfile)
if err := d.Set("linux_profile", &linuxProfile); err != nil {
return fmt.Errorf("Error setting `linux_profile`: %+v", err)
}

agentPoolProfiles := flattenAzureRmKubernetesClusterAgentPoolProfiles(resp.ManagedClusterProperties.AgentPoolProfiles)
agentPoolProfiles := flattenAzureRmKubernetesClusterAgentPoolProfiles(resp.ManagedClusterProperties.AgentPoolProfiles, resp.Fqdn)
if err := d.Set("agent_pool_profile", &agentPoolProfiles); err != nil {
return fmt.Errorf("Error setting `agent_pool_profile`: %+v", err)
}
Expand Down Expand Up @@ -307,7 +314,7 @@ func flattenAzureRmKubernetesClusterLinuxProfile(profile containerservice.LinuxP
return profiles
}

func flattenAzureRmKubernetesClusterAgentPoolProfiles(profiles *[]containerservice.AgentPoolProfile) []interface{} {
func flattenAzureRmKubernetesClusterAgentPoolProfiles(profiles *[]containerservice.AgentPoolProfile, fqdn *string) []interface{} {
agentPoolProfiles := make([]interface{}, 0, len(*profiles))

for _, profile := range *profiles {
Expand All @@ -321,8 +328,9 @@ func flattenAzureRmKubernetesClusterAgentPoolProfiles(profiles *[]containerservi
agentPoolProfile["dns_prefix"] = *profile.DNSPrefix
}

if profile.Fqdn != nil {
Copy link
Collaborator

@katbyte katbyte Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just set this to profile.Fqdn for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be surprised that it would break existing code (profile.Fqdn has always been empty, so the field hasn't been useful), but I can make that change and deprecate it.

agentPoolProfile["fqdn"] = *profile.Fqdn
if fqdn != nil {
// temporarily persist the parent FQDN here until `fqdn` is removed from the `agent_pool_profile`
agentPoolProfile["fqdn"] = *fqdn
}

if profile.Name != nil {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The following attributes are exported:

* `id` - The Kubernetes Managed Cluster ID.

* `agent_pool_profile.#.fqdn` - The FQDN of the Azure Kubernetes Managed Cluster.
* `fqdn` - The FQDN of the Azure Kubernetes Managed Cluster.

## Import

Expand Down