Skip to content

Commit

Permalink
Add column connection_info in the table gcp_alloydb_instance Closes #632
Browse files Browse the repository at this point in the history
 (#651)
  • Loading branch information
ParthaI authored Sep 6, 2024
1 parent 4e8d77a commit 40560f5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gcp/table_gcp_alloydb_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ func tableGcpAlloyDBInstance(ctx context.Context) *plugin.Table {
Type: proto.ColumnType_JSON,
Description: "This is set for the read-write VM of the PRIMARY instance only.",
},
{
Name: "connection_info",
Type: proto.ColumnType_JSON,
Description: "ConnectionInfo singleton resource.",
Hydrate: getAlloydbInstanceConnectionInfo,
Transform: transform.FromValue(),
},

// Steampipe standard columns
{
Expand Down Expand Up @@ -309,6 +316,24 @@ func getAlloydbInstance(ctx context.Context, d *plugin.QueryData, h *plugin.Hydr
return resp, nil
}

func getAlloydbInstanceConnectionInfo(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
alloyDBInstance := h.Item.(*alloydb.Instance)

service, err := AlloyDBService(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("gcp_alloydb_instance.getAlloydbInstanceConnectionInfo", "connection_error", err)
return nil, err
}

resp, err := service.Projects.Locations.Clusters.Instances.GetConnectionInfo(alloyDBInstance.Name).Do()
if err != nil {
plugin.Logger(ctx).Error("gcp_alloydb_instance.getAlloydbInstanceConnectionInfo", "api_error", err)
return nil, err
}

return resp, nil
}

func alloyDBInstanceSelfLink(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
instance := h.Item.(*alloydb.Instance)

Expand Down

0 comments on commit 40560f5

Please sign in to comment.