Skip to content

Commit

Permalink
remove identity_profile nest
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Apr 8, 2020
1 parent 2f1d5d3 commit 326e16a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,30 +120,22 @@ func resourceArmKubernetesCluster() *schema.Resource {
},
},

"identity_profile": {
"kubelet_identity": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"kubelet_identity": {
Type: schema.TypeList,
"client_id": {
Type: schema.TypeString,
Computed: true,
},
"object_id": {
Type: schema.TypeString,
Computed: true,
},
"user_assigned_identity_id": {
Type: schema.TypeString,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"client_id": {
Type: schema.TypeString,
Computed: true,
},
"object_id": {
Type: schema.TypeString,
Computed: true,
},
"user_assigned_identity_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
Expand Down Expand Up @@ -938,9 +930,9 @@ func resourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("setting `default_node_pool`: %+v", err)
}

identityProfile := flattenKubernetesClusterIdentityProfile(props.IdentityProfile)
if err := d.Set("identity_profile", identityProfile); err != nil {
return fmt.Errorf("setting `identity_profile`: %+v", err)
kubeletIdentity := flattenKubernetesClusterIdentityProfile(props.IdentityProfile)
if err := d.Set("kubelet_identity", kubeletIdentity); err != nil {
return fmt.Errorf("setting `kubelet_identity`: %+v", err)
}

linuxProfile := flattenKubernetesClusterLinuxProfile(props.LinuxProfile)
Expand Down Expand Up @@ -1093,23 +1085,19 @@ func flattenKubernetesClusterIdentityProfile(profile map[string]*containerservic
objectId = *objectid
}

resourceId := ""
userAssignedIdentityId := ""
if resourceid := kubeletidentity.ResourceID; resourceid != nil {
resourceId = *resourceid
userAssignedIdentityId = *resourceid
}

kubeletIdentity = append(kubeletIdentity, map[string]interface{}{
"client_id": clientId,
"object_id": objectId,
"resource_id": resourceId,
"client_id": clientId,
"object_id": objectId,
"user_assigned_identity_id": userAssignedIdentityId,
})
}

return []interface{}{
map[string]interface{}{
"kubelet_identity": kubeletIdentity,
},
}
return kubeletIdentity
}

func flattenKubernetesClusterLinuxProfile(profile *containerservice.LinuxProfile) []interface{} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func testAccAzureRMKubernetesCluster_managedClusterIdentity(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKubernetesClusterExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "identity.0.type", "SystemAssigned"),
resource.TestCheckResourceAttrSet(data.ResourceName, "identity_profile.0.kubelet_identity.0.client_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "identity_profile.0.kubelet_identity.0.object_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "identity_profile.0.kubelet_identity.0.resource_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.client_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.object_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "kubelet_identity.0.user_assigned_identity_id"),
resource.TestCheckResourceAttr(data.ResourceName, "service_principal.%", "0"),
),
},
Expand Down
8 changes: 1 addition & 7 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ The following attributes are exported:

* `node_resource_group` - The auto-generated Resource Group which contains the resources for this Managed Kubernetes Cluster.

* `identity_profile` - A `identity_profile` block as defined below.
* `kubelet_identity` - A `kubelet_identity` block as defined below.

---

Expand All @@ -384,12 +384,6 @@ The `identity` block exports the following:

---

The `identity_profile` block exports the following:

* `kubelet_identity` - A `kubelet_identity` block as defined below.

---

The `kubelet_identity` block exports the following:

* `client_id` - The Client ID of the user-defined Managed Identity assigned to the Kubelets.
Expand Down

0 comments on commit 326e16a

Please sign in to comment.