This document is a GitHub repository template for writing custom Integration Plugins for Opencomply
- OpenGovernance Describer Template
- Instructions
- 1. Create a new repository using this template
- 2. Fill the Provider information
- 3. Fill the describer wrapper
- 4. Create the describer file and implement the describer
- 5. Run the auto generators
- 6. Test the describer
- 7. Connect the describer to steampipe
- 8. Connect the describer to opencomply ui
- 9 Test Plugins
First, you need to fork this repository to your account. Then, you can create a new repository using this template.
Fill the information of the Provider you want to describe in the global folder.
Fill the Credential information of the Provider in the configs.go file.
package global
type IntegrationCredentials struct {
// TODO
}
Fill the Integration information of the Provider in the configs.go file.
const (
IntegrationTypeLower = "template" // example: aws, azure
IntegrationName = integration.Type("template,github") // example: aws_account, github_account
OGPluginRepoURL = "github.com/opengovern/og-describer-template" // example: github.com/opengovern/og-describer-aws
)
Fill the describer wrapper in the describer_wrapper.go file.
You should implement two functions:
DescribeListByProvider: This function should return a list of resources of the Provider.
DescribeSingleByProvider: This function should return a single resource of the Provider.
Theses functions are wrapper for the describer any resource of the Provider.
Create a new file in the describers folder with the name of the resource you want to describe.
Implement the describer in the file you created in the previous step. Implement two List and Get functions:
List: This function should return a list of resources of the Provider.
Get: This function should return a single resource of the Provider.
Note: You can use the example describer as a reference. Example is for describing CohereAI datasets resource.
You should fill the model of the resource in the models.go.
You can define models for the resource you want to describe. The main model of the resource should have Description
suffix.
type ArtifactDockerFileDescription struct {
Sha *string
Name *string
LastUpdatedAt *string
HTMLURL *string
DockerfileContent string
DockerfileContentBase64 *string
Repository map[string]interface{}
Images []string
}
You should fill the resource-types.json file in the resource-types.json folder.
[
{
"ResourceName": "Github/Artifact/DockerFile",
"Tags": {
"category": ["artifact_dockerfile"]
},
"ListDescriber": "DescribeByIntegration(describers.ListType)",
"GetDescriber": "",
"SteampipeTable": "template_artifact_dockerfile",
"Model": "ArtifactDockerFile",
"Params": [
{
"Name": "repository",
"Description": "Please provide the repo name (i.e. internal-tools)",
"Required": false
},
{
"Name": "organization",
"Description": "Please provide the organization name",
"Required": false
}
]
}
]
All models without Description
suffix should be used for the response of the Provider API and they will be ignored in the main files.
Note: Please Do not add json:"-"
tag to the models which has Description suffix. Also any model refrenced in these models.
For genertaing the all neccessary files, you should run this three commands:
go run discovery/pkg/runable/resource_type/main.go
go run discovery/pkg/runable/steampipe_es_client_generator/main.go
go run discovery/pkg/runable/steampipe_index_map/main.go
First you nedd to add credentials to the describer.go. Then you can run the describer with the following command:
go run command/main.go
result will be saved in the output.json file.
Note: Next steps are optional.
You can connect the describer to steampipe. For this, you should implement the steampipe plugin.
You can use the example plugin as a reference. Example is for describing CohereAI datasets resource.
Add a file with this format: table_template_resource.go
in the plugin folder.
You Should implement the table definition for the resource. Example file is for describing CohereAI datasets resource.
Note: Transform Field should have Description.
prefix.
Add your function to [plugin.go] file in the plugin.go.
You can connect the describer to opencomply ui. For this, you should follow next steps.
write discovery function to find all integrations with the given credentials in the discovery.go file.
write health check function to check the health of the integration in the healthcheck.go file.
Complete discovery and healthCheck functions in the integration.go file.
for rendering the integration in the UI, you should write the UI spec in the ui_spec.json file.
You can follow guides on the helper file for writing the UI spec. Also there is an example for write a UI spec for digitalocean in the example file.
Change the build.yaml.txt to build.yaml
and change the names of the plugins in the file.
Then you can test the plugins with runing action on the github.