-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathplugin.go
57 lines (49 loc) · 1.46 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package template
import (
"context"
essdk "github.com/opengovern/og-util/pkg/opengovernance-es-sdk"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)
// Plugin returns this plugin
func Plugin(ctx context.Context) *plugin.Plugin {
p := &plugin.Plugin{
Name: "steampipe-plugin-github",
ConnectionConfigSchema: &plugin.ConnectionConfigSchema{
NewInstance: essdk.ConfigInstance,
Schema: essdk.ConfigSchema(),
},
DefaultTransform: transform.FromCamel(),
TableMap: map[string]*plugin.Table{
"github_artifact_dockerfile": tableGitHubArtifactDockerFile(),
},
}
for key, table := range p.TableMap {
if table == nil {
continue
}
if table.Get != nil && table.Get.Hydrate == nil {
delete(p.TableMap, key)
continue
}
if table.List != nil && table.List.Hydrate == nil {
delete(p.TableMap, key)
continue
}
opengovernanceTable := false
for _, col := range table.Columns {
if col != nil && col.Name == "platform_integration_id" {
opengovernanceTable = true
}
}
if opengovernanceTable {
if table.Get != nil {
table.Get.KeyColumns = append(table.Get.KeyColumns, plugin.OptionalColumns([]string{"platform_integration_id", "platform_resource_id"})...)
}
if table.List != nil {
table.List.KeyColumns = append(table.List.KeyColumns, plugin.OptionalColumns([]string{"platform_integration_id", "platform_resource_id"})...)
}
}
}
return p
}