Skip to content

Commit b2d1f1a

Browse files
authored
Merge pull request #32 from opengovern/fix-folder-reorganization
fix: builds
2 parents 9333638 + c61959f commit b2d1f1a

File tree

4 files changed

+126
-18
lines changed

4 files changed

+126
-18
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
tags: |
137137
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-github:0.0.1
138138
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-github:${{ needs.build.outputs.latest_tag }}
139-
file: plugin/cloudql/docker/Dockerfile
139+
file: cloudql/docker/Dockerfile
140140
context: .
141141
deploy-local-describer:
142142
needs:
@@ -170,7 +170,7 @@ jobs:
170170
tags: |
171171
ghcr.io/${{ github.repository_owner }}/og-describer-github:local-latest
172172
ghcr.io/${{ github.repository_owner }}/og-describer-github:local-${{ needs.build.outputs.latest_tag }}
173-
file: describer/DockerFile
173+
file: discovery/DockerFile
174174
context: .
175175
release-integration-plugin:
176176
needs:

global/maps/resource_types.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,32 @@ package maps
22

33
import (
44
"github.com/opengovern/og-util/pkg/integration"
5-
"github.com/opengovern/opencomply/services/integration/integration-type/interfaces"
65
)
76

87
const (
98
IntegrationTypeGithubAccount = integration.Type("github_account") // example: aws_cloud, azure_subscription
109
)
1110

12-
var ResourceTypeConfigs = map[string]*interfaces.ResourceTypeConfiguration{
11+
type ResourceTypeConfiguration struct {
12+
Name string `json:"name"`
13+
IntegrationType integration.Type `json:"integration_type"`
14+
Description string `json:"description"`
15+
Params []Param `json:"params"`
16+
}
17+
18+
type Param struct {
19+
Name string `json:"name"`
20+
Description string `json:"description"`
21+
Required bool `json:"required"`
22+
Default *string `json:"default"`
23+
}
24+
25+
var ResourceTypeConfigs = map[string]*ResourceTypeConfiguration{
1326
"Github/Container/Package": {
1427
Name: "Github/Container/Package",
1528
IntegrationType: IntegrationTypeGithubAccount,
1629
Description: "",
17-
Params: []interfaces.Param{
30+
Params: []Param{
1831
{
1932
Name: "organization",
2033
Description: `Please provide the organization name`,
@@ -26,7 +39,7 @@ var ResourceTypeConfigs = map[string]*interfaces.ResourceTypeConfiguration{
2639
Name: "Github/Repository",
2740
IntegrationType: IntegrationTypeGithubAccount,
2841
Description: "",
29-
Params: []interfaces.Param{
42+
Params: []Param{
3043
{
3144
Name: "repository",
3245
Description: `Please provide the repo name (i.e. "internal-tools")`,
@@ -43,7 +56,7 @@ var ResourceTypeConfigs = map[string]*interfaces.ResourceTypeConfiguration{
4356
Name: "Github/Artifact/DockerFile",
4457
IntegrationType: IntegrationTypeGithubAccount,
4558
Description: "",
46-
Params: []interfaces.Param{
59+
Params: []Param{
4760
{
4861
Name: "repository",
4962
Description: `Please provide the repo name (i.e. "internal-tools")`,
@@ -60,7 +73,7 @@ var ResourceTypeConfigs = map[string]*interfaces.ResourceTypeConfiguration{
6073
Name: "Github/Actions/WorkflowRun",
6174
IntegrationType: IntegrationTypeGithubAccount,
6275
Description: "",
63-
Params: []interfaces.Param{
76+
Params: []Param{
6477
{
6578
Name: "repository",
6679
Description: `Please provide the repo name (i.e. "internal-tools")`,

platform/integration.go

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,39 @@ package main
22

33
import (
44
"encoding/json"
5+
"strconv"
6+
7+
"github.com/hashicorp/go-plugin"
58
"github.com/jackc/pgtype"
69
"github.com/opengovern/og-describer-github/global"
710
"github.com/opengovern/og-describer-github/global/maps"
811
"github.com/opengovern/og-util/pkg/integration"
9-
"github.com/opengovern/opencomply/services/integration/integration-type/interfaces"
1012
"github.com/opengovern/opencomply/services/integration/models"
11-
"strconv"
13+
"net/rpc"
14+
1215
)
1316

1417
type Integration struct{}
1518

16-
func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration {
17-
return interfaces.IntegrationConfiguration{
19+
20+
21+
22+
type IntegrationConfiguration struct {
23+
NatsScheduledJobsTopic string
24+
NatsManualJobsTopic string
25+
NatsStreamName string
26+
NatsConsumerGroup string
27+
NatsConsumerGroupManuals string
28+
29+
SteampipePluginName string
30+
31+
UISpec []byte
32+
33+
DescriberDeploymentName string
34+
DescriberRunCommand string
35+
}
36+
func (i *Integration) GetConfiguration() IntegrationConfiguration {
37+
return IntegrationConfiguration{
1838
NatsScheduledJobsTopic: global.JobQueueTopic,
1939
NatsManualJobsTopic: global.JobQueueTopicManuals,
2040
NatsStreamName: global.StreamName,
@@ -83,13 +103,13 @@ func (i *Integration) DiscoverIntegrations(jsonData []byte) ([]models.Integratio
83103
return integrations, nil
84104
}
85105

86-
func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[string]interfaces.ResourceTypeConfiguration, error) {
87-
resourceTypesMap := make(map[string]interfaces.ResourceTypeConfiguration)
106+
func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[string]maps.ResourceTypeConfiguration, error) {
107+
resourceTypesMap := make(map[string]maps.ResourceTypeConfiguration)
88108
for _, resourceType := range maps.ResourceTypesList {
89109
if v, ok := maps.ResourceTypeConfigs[resourceType]; ok {
90110
resourceTypesMap[resourceType] = *v
91111
} else {
92-
resourceTypesMap[resourceType] = interfaces.ResourceTypeConfiguration{}
112+
resourceTypesMap[resourceType] = maps.ResourceTypeConfiguration{}
93113
}
94114
}
95115
return resourceTypesMap, nil
@@ -120,3 +140,78 @@ func (i *Integration) ListAllTables() map[string][]string {
120140

121141
return tables
122142
}
143+
var HandshakeConfig = plugin.HandshakeConfig{
144+
ProtocolVersion: 1,
145+
MagicCookieKey: "platform-integration-plugin",
146+
MagicCookieValue: "integration",
147+
}
148+
149+
type IntegrationTypePlugin struct {
150+
Impl IntegrationType
151+
}
152+
type IntegrationType interface {
153+
GetIntegrationType() integration.Type
154+
GetConfiguration() IntegrationConfiguration
155+
GetResourceTypesByLabels(map[string]string) (map[string]maps.ResourceTypeConfiguration, error)
156+
HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error)
157+
DiscoverIntegrations(jsonData []byte) ([]models.Integration, error)
158+
GetResourceTypeFromTableName(tableName string) string
159+
ListAllTables() map[string][]string
160+
}
161+
type IntegrationTypeRPCServer struct {
162+
Impl IntegrationType
163+
}
164+
type IntegrationTypeRPC struct {
165+
client *rpc.Client
166+
}
167+
func (p *IntegrationTypePlugin) Server(*plugin.MuxBroker) (any, error) {
168+
return &IntegrationTypeRPCServer{Impl: p.Impl}, nil
169+
}
170+
171+
func (IntegrationTypePlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (any, error) {
172+
return &IntegrationTypeRPC{client: c}, nil
173+
}
174+
175+
176+
func (i *IntegrationTypeRPCServer) GetIntegrationType(_ struct{}, integrationType *integration.Type) error {
177+
*integrationType = i.Impl.GetIntegrationType()
178+
return nil
179+
}
180+
181+
func (i *IntegrationTypeRPCServer) GetConfiguration(_ struct{}, configuration *IntegrationConfiguration) error {
182+
*configuration = i.Impl.GetConfiguration()
183+
return nil
184+
}
185+
186+
func (i *IntegrationTypeRPCServer) GetResourceTypesByLabels(labels map[string]string, resourceTypes *map[string]maps.ResourceTypeConfiguration) error {
187+
var err error
188+
*resourceTypes, err = i.Impl.GetResourceTypesByLabels(labels)
189+
return err
190+
}
191+
type HealthCheckRequest struct {
192+
JsonData []byte
193+
ProviderId string
194+
Labels map[string]string
195+
Annotations map[string]string
196+
}
197+
func (i *IntegrationTypeRPCServer) HealthCheck(request HealthCheckRequest, result *bool) error {
198+
var err error
199+
*result, err = i.Impl.HealthCheck(request.JsonData, request.ProviderId, request.Labels, request.Annotations)
200+
return err
201+
}
202+
203+
func (i *IntegrationTypeRPCServer) DiscoverIntegrations(jsonData []byte, integrations *[]models.Integration) error {
204+
var err error
205+
*integrations, err = i.Impl.DiscoverIntegrations(jsonData)
206+
return err
207+
}
208+
209+
func (i *IntegrationTypeRPCServer) GetResourceTypeFromTableName(tableName string, resourceType *string) error {
210+
*resourceType = i.Impl.GetResourceTypeFromTableName(tableName)
211+
return nil
212+
}
213+
214+
func (i *IntegrationTypeRPCServer) ListAllTables(_ struct{}, tables *map[string][]string) error {
215+
*tables = i.Impl.ListAllTables()
216+
return nil
217+
}

platform/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"github.com/hashicorp/go-hclog"
55
"github.com/hashicorp/go-plugin"
6-
"github.com/opengovern/opencomply/services/integration/integration-type/interfaces"
76
"os"
87
)
98

9+
1010
func main() {
1111
i := Integration{}
1212
logger := hclog.New(&hclog.LoggerOptions{
@@ -16,11 +16,11 @@ func main() {
1616
})
1717

1818
var pluginMap = map[string]plugin.Plugin{
19-
IntegrationTypeGithubAccount.String(): &interfaces.IntegrationTypePlugin{Impl: &i},
19+
IntegrationTypeGithubAccount.String(): &IntegrationTypePlugin{Impl: &i},
2020
}
2121

2222
plugin.Serve(&plugin.ServeConfig{
23-
HandshakeConfig: interfaces.HandshakeConfig,
23+
HandshakeConfig: HandshakeConfig,
2424
Plugins: pluginMap,
2525
Logger: logger,
2626
})

0 commit comments

Comments
 (0)