Skip to content

Commit

Permalink
fix: instances column of gcp_compute_instance_group errors for region…
Browse files Browse the repository at this point in the history
…al groups
  • Loading branch information
pdecat committed Oct 19, 2024
1 parent 5bbdb77 commit d05048c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions gcp/table_gcp_compute_instance_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,21 @@ func getComputeInstanceGroupInstances(ctx context.Context, d *plugin.QueryData,
return nil, err
}

resp, err := service.InstanceGroups.ListInstances(project, getLastPathElement(types.SafeString(instanceGroup.Zone)), instanceGroup.Name, &compute.InstanceGroupsListInstancesRequest{}).Do()

if err != nil {
plugin.Logger(ctx).Error("gcp_compute_instance_group.getComputeInstanceGroupInstances", "api_err", err)
return nil, err
if instanceGroup.Zone == "" {
resp, err := service.RegionInstanceGroups.ListInstances(project, getLastPathElement(types.SafeString(instanceGroup.Region)), instanceGroup.Name, &compute.RegionInstanceGroupsListInstancesRequest{}).Do()
if err != nil {
plugin.Logger(ctx).Error("gcp_compute_instance_group.getComputeInstanceGroupInstances", "api_err", err)
return nil, err
}
return &resp.Items, nil
} else {
resp, err := service.InstanceGroups.ListInstances(project, getLastPathElement(types.SafeString(instanceGroup.Zone)), instanceGroup.Name, &compute.InstanceGroupsListInstancesRequest{}).Do()
if err != nil {
plugin.Logger(ctx).Error("gcp_compute_instance_group.getComputeInstanceGroupInstances", "api_err", err)
return nil, err
}
return &resp.Items, nil
}

return &resp.Items, nil
}

//// TRANSFORM FUNCTIONS
Expand Down

0 comments on commit d05048c

Please sign in to comment.