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

Fix nutanix_project and nutanix_projects datasource to not use "kind" a… #335

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: 20 additions & 0 deletions nutanix/data_source_nutanix_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,26 @@ func flattenReferenceList(references []*v3.ReferenceValues) []map[string]interfa
return res
}

func flattenExternalNetworkListReference(reference *v3.ReferenceValues) map[string]interface{} {
if reference != nil {
return map[string]interface{}{
"uuid": reference.UUID,
"name": reference.Name,
}
}
return map[string]interface{}{}
}

func flattenExternalNetworkListReferenceList(references []*v3.ReferenceValues) []map[string]interface{} {
res := make([]map[string]interface{}, len(references))
if len(references) > 0 {
for i, r := range references {
res[i] = flattenExternalNetworkListReference(r)
}
}
return res
}

func flattenHypervisor(hypervisor *v3.Hypervisor) map[string]interface{} {
if hypervisor != nil {
return map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion nutanix/data_source_nutanix_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func dataSourceNutanixProjectRead(d *schema.ResourceData, meta interface{}) erro
if err := d.Set("subnet_reference_list", flattenReferenceList(project.Spec.Resources.SubnetReferenceList)); err != nil {
return fmt.Errorf("error setting `subnet_reference_list` for Project(%s): %s", d.Id(), err)
}
if err := d.Set("external_network_list", flattenReferenceList(project.Spec.Resources.ExternalNetworkList)); err != nil {
if err := d.Set("external_network_list", flattenExternalNetworkListReferenceList(project.Spec.Resources.ExternalNetworkList)); err != nil {
return fmt.Errorf("error setting `external_network_list` for Project(%s): %s", d.Id(), err)
}
if err := d.Set("metadata", m); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nutanix/data_source_nutanix_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func flattenProjectEntities(projects []*v3.Project) []map[string]interface{} {
"user_reference_list": flattenReferenceList(project.Spec.Resources.UserReferenceList),
"external_user_group_reference_list": flattenReferenceList(project.Spec.Resources.ExternalUserGroupReferenceList),
"subnet_reference_list": flattenReferenceList(project.Spec.Resources.SubnetReferenceList),
"external_network_list": flattenReferenceList(project.Spec.Resources.ExternalNetworkList),
"external_network_list": flattenExternalNetworkListReferenceList(project.Spec.Resources.ExternalNetworkList),
"metadata": metadata,
"categories": categories,
"project_reference": flattenReferenceValues(project.Metadata.ProjectReference),
Expand Down