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

Add self_link for gcp_dns_managed_zone table. Closes #194 #195

Merged
merged 3 commits into from
May 12, 2021
Merged
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
26 changes: 24 additions & 2 deletions gcp/table_gcp_dns_managed_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ func tableGcpDnsManagedZone(ctx context.Context) *plugin.Table {
Type: proto.ColumnType_TIMESTAMP,
Transform: transform.FromField("ServiceDirectoryConfig.Namespace.DeletionTime"),
},
{
Name: "self_link",
Description: "Server-defined URL for the managed zone.",
Type: proto.ColumnType_STRING,
Hydrate: getDnsZoneSelfLink,
Transform: transform.FromValue(),
},
{
Name: "dnssec_config_default_key_specs",
Description: "Specifies parameters for generating initial DnsKeys for this ManagedZone.",
Expand Down Expand Up @@ -117,7 +124,7 @@ func tableGcpDnsManagedZone(ctx context.Context) *plugin.Table {
Type: proto.ColumnType_JSON,
},

// standard steampipe columns
// Steampipe standard columns
{
Name: "title",
Description: ColumnDescriptionTitle,
Expand All @@ -138,7 +145,7 @@ func tableGcpDnsManagedZone(ctx context.Context) *plugin.Table {
Transform: transform.FromValue(),
},

// standard gcp columns
// Standard gcp columns
{
Name: "location",
Description: ColumnDescriptionLocation,
Expand Down Expand Up @@ -233,3 +240,18 @@ func getDnsManagedZoneAka(ctx context.Context, d *plugin.QueryData, h *plugin.Hy

return akas, nil
}

func getDnsZoneSelfLink(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
zone := h.Item.(*dns.ManagedZone)

// Get project details
projectData, err := activeProject(ctx, d)
if err != nil {
return nil, err
}
project := projectData.Project

selfLink := "https://www.googleapis.com/dns/v1/projects/" + project + "/managedZones/" + zone.Name

return selfLink, nil
}