Skip to content

Recompile plugin with steampipe-plugin-sdk v5.10.1 and add support for connection key columns #104

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions digitalocean/common_columns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package digitalocean

import (
"context"

"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/memoize"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)

func commonColumns(c []*plugin.Column) []*plugin.Column {
return append([]*plugin.Column{
{
Name: "uuid",
Description: "The unique universal identifier for the current user.",
Type: proto.ColumnType_STRING,
Hydrate: getCurrentUserUuid,
Transform: transform.FromValue(),
},
}, c...)
}

// if the caching is required other than per connection, build a cache key for the call and use it in Memoize.
var getCurrentUserUuidMemoized = plugin.HydrateFunc(getCurrentUserUuidUncached).Memoize(memoize.WithCacheKeyFunction(getCurrentUserUuidCacheKey))

// declare a wrapper hydrate function to call the memoized function
// - this is required when a memoized function is used for a column definition
func getCurrentUserUuid(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
return getCurrentUserUuidMemoized(ctx, d, h)
}

// Build a cache key for the call to getCurrentUserUuidCacheKey.
func getCurrentUserUuidCacheKey(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
key := "getCurrentUserUuid"
return key, nil
}

func getCurrentUserUuidUncached(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
conn, err := connect(ctx, d)
if err != nil {
return nil, err
}
account, _, err := conn.Account.Get(ctx)
if err != nil {
return nil, err
}
return account.UUID, nil
}
6 changes: 6 additions & 0 deletions digitalocean/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ func Plugin(ctx context.Context) *plugin.Plugin {
ConnectionConfigSchema: &plugin.ConnectionConfigSchema{
NewInstance: ConfigInstance,
},
ConnectionKeyColumns: []plugin.ConnectionKeyColumn{
{
Name: "uuid",
Hydrate: getCurrentUserUuid,
},
},
DefaultTransform: transform.FromJSONTag().NullIfZero(),
TableMap: map[string]*plugin.Table{
"digitalocean_account": tableDigitalOceanAccount(ctx),
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func tableDigitalOceanAccount(ctx context.Context) *plugin.Table {
List: &plugin.ListConfig{
Hydrate: listAccount,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "email", Type: proto.ColumnType_STRING, Description: "The email address used by the current user to register for DigitalOcean."},
// Other columns
Expand All @@ -32,7 +32,7 @@ func tableDigitalOceanAccount(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(accountAkas), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromConstant(map[string]bool{}), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Email"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanAction(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getAction,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_INT, Description: "A unique numeric ID that can be used to identify and reference an action."},
{Name: "resource_id", Type: proto.ColumnType_INT, Description: "A unique identifier for the resource that the action is associated with."},
Expand All @@ -35,7 +35,7 @@ func tableDigitalOceanAction(ctx context.Context) *plugin.Table {
{Name: "region_slug", Type: proto.ColumnType_STRING, Description: "The region where the action occurred."},
{Name: "resource_type", Type: proto.ColumnType_STRING, Description: "The type of resource that the action is associated with."},
{Name: "status", Type: proto.ColumnType_STRING, Description: "The current status of the action. This can be \"in-progress\", \"completed\", or \"errored\"."},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func tableDigitalOceanAlertPolicy(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("uuid"),
Hydrate: getAlertPolicy,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "uuid",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -104,7 +104,7 @@ func tableDigitalOceanAlertPolicy(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(alertPolicyToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func tableDigitalOceanApp(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getApp,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "id",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -120,7 +120,7 @@ func tableDigitalOceanApp(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(appToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ func tableDigitalOceanBalance(ctx context.Context) *plugin.Table {
List: &plugin.ListConfig{
Hydrate: listBalance,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{Name: "account_balance", Type: proto.ColumnType_DOUBLE, Description: "Current balance of the customer's most recent billing activity. Does not reflect month_to_date_usage."},
{Name: "generated_at", Type: proto.ColumnType_TIMESTAMP, Description: "The time at which balances were most recently generated."},
{Name: "month_to_date_balance", Type: proto.ColumnType_DOUBLE, Description: "Balance as of the generated_at time. This value includes the account_balance and month_to_date_usage."},
{Name: "month_to_date_usage", Type: proto.ColumnType_DOUBLE, Description: "Amount used in the current billing period as of the generated_at time."},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_bill.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func tableDigitalOceanBill(ctx context.Context) *plugin.Table {
List: &plugin.ListConfig{
Hydrate: listBill,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "date", Type: proto.ColumnType_TIMESTAMP, Description: "Time the billing history entry occured."},
// Other columns
Expand All @@ -25,7 +25,7 @@ func tableDigitalOceanBill(ctx context.Context) *plugin.Table {
{Name: "invoice_id", Type: proto.ColumnType_STRING, Description: "ID of the invoice associated with the billing history entry, if applicable."},
{Name: "invoice_uuid", Type: proto.ColumnType_STRING, Description: "UUID of the invoice associated with the billing history entry, if applicable."},
{Name: "type", Type: proto.ColumnType_STRING, Description: "Type of billing history entry."},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_container_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableDigitalOceanContainerRegistry(ctx context.Context) *plugin.Table {
List: &plugin.ListConfig{
Hydrate: getContainerRegistry,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "name",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -62,7 +62,7 @@ func tableDigitalOceanContainerRegistry(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(registryToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanDatabase(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getDatabase,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "A unique ID that can be used to identify and reference a database cluster."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "A unique, human-readable name referring to a database cluster."},
Expand Down Expand Up @@ -62,7 +62,7 @@ func tableDigitalOceanDatabase(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(databaseToURN).Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromField("Tags").Transform(labelsToTagsMap), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func tableDigitalOceanDomain(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("name"),
Hydrate: getDomain,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "name",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -60,7 +60,7 @@ func tableDigitalOceanDomain(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(domainToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanDroplet(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getDroplet,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_INT, Description: "A unique identifier for each Droplet instance."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The human-readable name set for the Droplet instance."},
Expand Down Expand Up @@ -56,7 +56,7 @@ func tableDigitalOceanDroplet(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromMethod("URN").Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromField("Tags").Transform(labelsToTagsMap), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanFirewall(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getFirewall,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "id",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -90,7 +90,7 @@ func tableDigitalOceanFirewall(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(firewallToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_floating_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanFloatingIP(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("ip"),
Hydrate: getFloatingIP,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "ip", Type: proto.ColumnType_IPADDR, Description: "The public IP address of the floating IP. It also serves as its identifier."},
// Other columns
Expand All @@ -35,7 +35,7 @@ func tableDigitalOceanFloatingIP(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromMethod("URN").Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromConstant(map[string]bool{}), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("IP"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func tableDigitalOceanImage(ctx context.Context) *plugin.Table {
KeyColumns: plugin.AnyColumn([]string{"id", "slug"}),
Hydrate: getImage,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_INT, Description: "A unique number that can be used to identify and reference a specific image."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question."},
Expand All @@ -45,7 +45,7 @@ func tableDigitalOceanImage(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(imageToURN).Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromField("Tags").Transform(labelsToTagsMap), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func tableDigitalOceanKey(ctx context.Context) *plugin.Table {
KeyColumns: plugin.AnyColumn([]string{"id", "fingerprint"}),
Hydrate: getKey,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_INT, Description: "This is a unique identification number for the key."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The human-readable display name for the given SSH key."},
Expand All @@ -34,7 +34,7 @@ func tableDigitalOceanKey(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(keyToURN).Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromConstant(map[string]bool{}), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func tableDigitalOceanKubernetesCluster(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getKubernetesCluster,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "id",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -142,7 +142,7 @@ func tableDigitalOceanKubernetesCluster(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(clusterToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_kubernetes_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func tableDigitalOceanKubernetesNodePool(ctx context.Context) *plugin.Table {
KeyColumns: plugin.AllColumns([]string{"id", "cluster_id"}),
Hydrate: getKubernetesNodePool,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
{
Name: "id",
Type: proto.ColumnType_STRING,
Expand Down Expand Up @@ -120,7 +120,7 @@ func tableDigitalOceanKubernetesNodePool(ctx context.Context) *plugin.Table {
Description: resourceInterfaceDescription("akas"),
Transform: transform.FromValue().Transform(nodePoolToURN).Transform(ensureStringArray),
},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanLoadBalancer(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getLoadBalancer,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "A unique ID that can be used to identify and reference a load balancer."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "A human-readable name for a load balancer instance."},
Expand Down Expand Up @@ -57,7 +57,7 @@ func tableDigitalOceanLoadBalancer(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(loadBalancerToURN).Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromField("Tags").Transform(labelsToTagsMap), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
4 changes: 2 additions & 2 deletions digitalocean/table_digitalocean_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func tableDigitalOceanProject(ctx context.Context) *plugin.Table {
KeyColumns: plugin.SingleColumn("id"),
Hydrate: getProject,
},
Columns: []*plugin.Column{
Columns: commonColumns([]*plugin.Column{
// Top columns
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique universal identifier of this project."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "The globally unique human-readable name for the project."},
Expand All @@ -39,7 +39,7 @@ func tableDigitalOceanProject(ctx context.Context) *plugin.Table {
{Name: "akas", Type: proto.ColumnType_JSON, Transform: transform.FromValue().Transform(projectToURN).Transform(ensureStringArray), Description: resourceInterfaceDescription("akas")},
{Name: "tags", Type: proto.ColumnType_JSON, Transform: transform.FromConstant(map[string]bool{}), Description: resourceInterfaceDescription("tags")},
{Name: "title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Name"), Description: resourceInterfaceDescription("title")},
},
}),
}
}

Expand Down
Loading
Loading