Skip to content

Commit

Permalink
kubelet_profile added
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Apr 7, 2020
1 parent 3e88527 commit 130beb8
Showing 1 changed file with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,42 @@ func resourceArmKubernetesCluster() *schema.Resource {
},
},

"identity_profile": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"kubelet_identity": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"client_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"object_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"resource_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
},
},
},

"linux_profile": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -909,6 +945,11 @@ 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)
}

linuxProfile := flattenKubernetesClusterLinuxProfile(props.LinuxProfile)
if err := d.Set("linux_profile", linuxProfile); err != nil {
return fmt.Errorf("setting `linux_profile`: %+v", err)
Expand Down Expand Up @@ -1042,6 +1083,42 @@ func expandKubernetesClusterLinuxProfile(input []interface{}) *containerservice.
}
}

func flattenKubernetesClusterIdentityProfile(profile map[string]*containerservice.ManagedClusterPropertiesIdentityProfileValue) []interface{} {
if profile == nil {
return []interface{}{}
}

kubeletIdentity := make([]interface{}, 0)
if kubeletidentity := profile["kubeletIdentity"]; kubeletidentity != nil {
clientId := ""
if clientid := kubeletidentity.ClientID; clientid != nil {
clientId = *clientid
}

objectId := ""
if objectid := kubeletidentity.ObjectID; objectid != nil {
objectId = *objectid
}

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

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

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

func flattenKubernetesClusterLinuxProfile(profile *containerservice.LinuxProfile) []interface{} {
if profile == nil {
return []interface{}{}
Expand Down

0 comments on commit 130beb8

Please sign in to comment.