Skip to content

Commit

Permalink
fix: added common columns for render tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ArshiaBP committed Dec 22, 2024
1 parent 9ceed7b commit 4d6687c
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"es_id":"","es_index":"","platform_id":":::Render/EnvGroup:::evg-ctavhehopnds73ejl14g","resource_id":"evg-ctavhehopnds73ejl14g","resource_name":"harbor-prod","description":{"createdAt":"2024-12-08T19:51:22.426806Z","environmentId":"","id":"evg-ctavhehopnds73ejl14g","name":"harbor-prod","ownerId":"tea-csuhvt52ng1s739lbn5g","serviceLinks":[],"updatedAt":"2024-12-08T19:51:22.426806Z"},"integration_type":"RENDER_ACCOUNT","resource_type":"render/envgroup","integration_id":"","metadata":{},"canonical_tags":null,"described_by":"473050548","described_at":1733908008835},
{"es_id":"","es_index":"","platform_id":":::Render/Project:::prj-ctavcqqj1k6c738qbuf0","resource_id":"prj-ctavcqqj1k6c738qbuf0","resource_name":"opencomply-platform","description":{"createdAt":"2024-12-08T19:41:31.164334Z","environmentIds":["evm-ctavcqqj1k6c738qbufg"],"id":"prj-ctavcqqj1k6c738qbuf0","name":"opencomply-platform","owner":{"email":"[email protected]","id":"tea-csuhvt52ng1s739lbn5g","name":"My Workspace","twoFactorAuthEnabled":false,"type":"team"},"updatedAt":"2024-12-08T19:41:31.164334Z"},"integration_type":"RENDER_ACCOUNT","resource_type":"render/project","integration_id":"","metadata":{},"canonical_tags":null,"described_by":"3928438176","described_at":1734887045810},
46 changes: 46 additions & 0 deletions steampipe-plugin-render/render/common_column.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package render

import (
"context"
"encoding/json"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)

func commonColumns(c []*plugin.Column) []*plugin.Column {
return append(c, []*plugin.Column{
{
Name: "platform_account_id",
Type: proto.ColumnType_STRING,
Description: "The Platform Account ID in which the resource is located.",
Transform: transform.FromField("IntegrationID"),
},
{
Name: "platform_resource_id",
Type: proto.ColumnType_STRING,
Description: "The unique ID of the resource in opengovernance.",
Transform: transform.FromField("PlatformID"),
},
{
Name: "platform_metadata",
Type: proto.ColumnType_JSON,
Description: "The metadata of the resource",
Transform: transform.FromField("Metadata").Transform(marshalJSON),
},
{
Name: "platform_resource_description",
Type: proto.ColumnType_JSON,
Description: "The full model description of the resource",
Transform: transform.FromField("Description").Transform(marshalJSON),
},
}...)
}

func marshalJSON(_ context.Context, d *transform.TransformData) (interface{}, error) {
b, err := json.Marshal(d.Value)
if err != nil {
return nil, err
}
return string(b), nil
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderBlueprint(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetBlueprint,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the blueprint.", Transform: transform.FromField("Description.ID")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the blueprint.", Transform: transform.FromField("Description.Name")},
Expand All @@ -28,6 +28,6 @@ func tableRenderBlueprint(ctx context.Context) *plugin.Table {
{Name: "repo", Type: proto.ColumnType_STRING, Description: "The repository associated with the blueprint.", Transform: transform.FromField("Description.Repo")},
{Name: "branch", Type: proto.ColumnType_STRING, Description: "The branch in the repository for the blueprint.", Transform: transform.FromField("Description.Branch")},
{Name: "lastSync", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last sync for the blueprint.", Transform: transform.FromField("Description.LastSync")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderDeploy(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetDeploy,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the deployment.", Transform: transform.FromField("Description.ID")},
{Name: "commit", Type: proto.ColumnType_JSON, Description: "The commit details associated with the deployment.", Transform: transform.FromField("Description.Commit")},
Expand All @@ -29,6 +29,6 @@ func tableRenderDeploy(ctx context.Context) *plugin.Table {
{Name: "finishedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the deployment finished.", Transform: transform.FromField("Description.FinishedAt")},
{Name: "createdAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the deployment was created.", Transform: transform.FromField("Description.CreatedAt")},
{Name: "updatedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last update to the deployment.", Transform: transform.FromField("Description.UpdatedAt")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderDisk(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetDisk,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the disk.", Transform: transform.FromField("Description.ID")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the disk.", Transform: transform.FromField("Description.Name")},
Expand All @@ -28,6 +28,6 @@ func tableRenderDisk(ctx context.Context) *plugin.Table {
{Name: "serviceId", Type: proto.ColumnType_STRING, Description: "The ID of the service associated with the disk.", Transform: transform.FromField("Description.ServiceID")},
{Name: "createdAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the disk was created.", Transform: transform.FromField("Description.CreatedAt")},
{Name: "updatedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last update to the disk.", Transform: transform.FromField("Description.UpdatedAt")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_env_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderEnvGroup(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetEnvGroup,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the environment group.", Transform: transform.FromField("Description.ID")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the environment group.", Transform: transform.FromField("Description.Name")},
Expand All @@ -28,6 +28,6 @@ func tableRenderEnvGroup(ctx context.Context) *plugin.Table {
{Name: "updatedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last update to the environment group.", Transform: transform.FromField("Description.UpdatedAt")},
{Name: "serviceLinks", Type: proto.ColumnType_JSON, Description: "A list of service links associated with the environment group.", Transform: transform.FromField("Description.ServiceLinks")},
{Name: "environmentId", Type: proto.ColumnType_STRING, Description: "The ID of the associated environment.", Transform: transform.FromField("Description.EnvironmentID")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderEnvironment(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetEnvironment,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the environment.", Transform: transform.FromField("Description.ID")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the environment.", Transform: transform.FromField("Description.Name")},
Expand All @@ -29,6 +29,6 @@ func tableRenderEnvironment(ctx context.Context) *plugin.Table {
{Name: "serviceIds", Type: proto.ColumnType_JSON, Description: "A list of service IDs associated with the environment.", Transform: transform.FromField("Description.ServiceIDs")},
{Name: "envGroupIds", Type: proto.ColumnType_JSON, Description: "A list of environment group IDs associated with the environment.", Transform: transform.FromField("Description.EnvGroupIDs")},
{Name: "protectedStatus", Type: proto.ColumnType_STRING, Description: "The protected status of the environment.", Transform: transform.FromField("Description.ProtectedStatus")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func tableRenderHeader(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetHeader,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the header.", Transform: transform.FromField("Description.ID")},
{Name: "path", Type: proto.ColumnType_STRING, Description: "The path of the header.", Transform: transform.FromField("Description.Path")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the header.", Transform: transform.FromField("Description.Name")},
{Name: "value", Type: proto.ColumnType_STRING, Description: "The value of the header.", Transform: transform.FromField("Description.Value")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderJob(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetJob,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the job.", Transform: transform.FromField("Description.ID")},
{Name: "serviceId", Type: proto.ColumnType_STRING, Description: "The ID of the service associated with the job.", Transform: transform.FromField("Description.ServiceID")},
Expand All @@ -29,6 +29,6 @@ func tableRenderJob(ctx context.Context) *plugin.Table {
{Name: "createdAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the job was created.", Transform: transform.FromField("Description.CreatedAt")},
{Name: "startedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the job started.", Transform: transform.FromField("Description.StartedAt")},
{Name: "finishedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the job finished.", Transform: transform.FromField("Description.FinishedAt")},
},
}),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderPostgres(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetPostgres,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the PostgreSQL instance.", Transform: transform.FromField("Description.ID")},
{Name: "ipAllowList", Type: proto.ColumnType_JSON, Description: "A list of IP addresses allowed to access the PostgreSQL instance.", Transform: transform.FromField("Description.IPAllowList")},
Expand All @@ -43,6 +43,6 @@ func tableRenderPostgres(ctx context.Context) *plugin.Table {
{Name: "suspended", Type: proto.ColumnType_STRING, Description: "Indicates whether the PostgreSQL instance is suspended.", Transform: transform.FromField("Description.Suspended")},
{Name: "suspenders", Type: proto.ColumnType_JSON, Description: "A list of suspenders associated with the PostgreSQL instance.", Transform: transform.FromField("Description.Suspenders")},
{Name: "dashboardUrl", Type: proto.ColumnType_STRING, Description: "The URL of the PostgreSQL instance's dashboard.", Transform: transform.FromField("Description.DashboardURL")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func tableRenderProject(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetProject,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the project.", Transform: transform.FromField("Description.ID")},
{Name: "createdAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of when the project was created.", Transform: transform.FromField("Description.CreatedAt")},
{Name: "updatedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last update to the project.", Transform: transform.FromField("Description.UpdatedAt")},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The name of the project.", Transform: transform.FromField("Description.Name")},
{Name: "owner", Type: proto.ColumnType_JSON, Description: "Information about the owner of the project.", Transform: transform.FromField("Description.Owner")},
{Name: "environmentIds", Type: proto.ColumnType_JSON, Description: "A list of environment IDs associated with the project.", Transform: transform.FromField("Description.EnvironmentIDs")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func tableRenderRoute(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetRoute,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the route.", Transform: transform.FromField("Description.ID")},
{Name: "type", Type: proto.ColumnType_STRING, Description: "The type of the route.", Transform: transform.FromField("Description.Type")},
{Name: "source", Type: proto.ColumnType_STRING, Description: "The source of the route.", Transform: transform.FromField("Description.Source")},
{Name: "destination", Type: proto.ColumnType_STRING, Description: "The destination of the route.", Transform: transform.FromField("Description.Destination")},
{Name: "priority", Type: proto.ColumnType_INT, Description: "The priority of the route.", Transform: transform.FromField("Description.Priority")},
},
}),
}
}
4 changes: 2 additions & 2 deletions steampipe-plugin-render/render/table_render_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableRenderService(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: opengovernance.GetService,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique identifier for the service.", Transform: transform.FromField("Description.ID")},
{Name: "autoDeploy", Type: proto.ColumnType_STRING, Description: "Indicates whether the service deploys automatically.", Transform: transform.FromField("Description.AutoDeploy")},
Expand All @@ -41,6 +41,6 @@ func tableRenderService(ctx context.Context) *plugin.Table {
{Name: "type", Type: proto.ColumnType_STRING, Description: "The type of the service.", Transform: transform.FromField("Description.Type")},
{Name: "updatedAt", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp of the last update to the service.", Transform: transform.FromField("Description.UpdatedAt")},
{Name: "serviceDetails", Type: proto.ColumnType_JSON, Description: "The details of the service.", Transform: transform.FromField("Description.ServiceDetails")},
},
}),
}
}

0 comments on commit 4d6687c

Please sign in to comment.