-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recompile plugin with steampipe-plugin-sdk v5.10.1 and add support fo…
…r connection key columns (#38) Co-authored-by: ParthaI <partha@turbot.com>
- Loading branch information
Showing
10 changed files
with
225 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package buildkite | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" | ||
"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" | ||
) | ||
|
||
func commonColumns(c []*plugin.Column) []*plugin.Column { | ||
return append([]*plugin.Column{ | ||
{ | ||
Name: "member_id", | ||
Description: "Unique identifier for the organization.", | ||
Type: proto.ColumnType_STRING, | ||
Hydrate: getMemberId, | ||
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 getMemberIdMemoized = plugin.HydrateFunc(getMemberIdUncached).Memoize(memoize.WithCacheKeyFunction(getMemberIdCacheKey)) | ||
|
||
// declare a wrapper hydrate function to call the memoized function | ||
// - this is required when a memoized function is used for a column definition | ||
func getMemberId(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { | ||
return getMemberIdMemoized(ctx, d, h) | ||
} | ||
|
||
// Build a cache key for the call to getMemberIdCacheKey. | ||
func getMemberIdCacheKey(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { | ||
key := "getMemberId" | ||
return key, nil | ||
} | ||
|
||
func getMemberIdUncached(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { | ||
|
||
conn, err := connect(ctx, d) | ||
if err != nil { | ||
plugin.Logger(ctx).Error("getMemberIdUncached", "connection_error", err) | ||
return nil, err | ||
} | ||
|
||
user, resp, err := conn.User.Get() | ||
if err != nil { | ||
plugin.Logger(ctx).Error("getMemberIdUncached", "query_error", err, "resp", resp) | ||
return nil, err | ||
} | ||
|
||
return user.ID, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.