Skip to content

Commit 426293d

Browse files
committed
feat: add nodes
1 parent 055539d commit 426293d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+840
-2486
lines changed
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ jobs:
4343
${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}-
4444
${{ runner.os }}-go-
4545
46-
- name: Build Template Plugin App
46+
- name: Build Kubernetes Plugin App
4747
working-directory: ./cloudql
4848
run: make build
49-
- name: Pack Template Plugin Build
49+
- name: Pack Kubernetes Plugin Build
5050
working-directory: ./cloudql
5151
run: |
5252
tar -cvf build.tar build
53-
- name: Upload Template Plugin Artifact
53+
- name: Upload Kubernetes Plugin Artifact
5454
uses: actions/[email protected]
5555
with:
56-
name: steampipe-plugin-template
56+
name: steampipe-plugin-kubernetes
5757
path: ./cloudql/build.tar
5858
retention-days: 1
5959
- name: Build Local Describer App
@@ -66,7 +66,7 @@ jobs:
6666
- name: Upload Local Artifact
6767
uses: actions/[email protected]
6868
with:
69-
name: local-og-describer-template
69+
name: local-og-describer-kubernetes
7070
path: ./discovery/local.tar
7171
retention-days: 1
7272
- name: Add Tag to Release
@@ -82,25 +82,25 @@ jobs:
8282
run: make build
8383
- name: Create output directory
8484
working-directory: .
85-
run: mkdir -p template-plugin
85+
run: mkdir -p kubernetes-plugin
8686
- name: Copy steampipe plugin to output directory
8787
working-directory: .
88-
run: cp ./cloudql/build/steampipe-plugin-template.plugin ./template-plugin/cloudql-plugin
88+
run: cp ./cloudql/build/steampipe-plugin-kubernetes.plugin ./kubernetes-plugin/cloudql-plugin
8989
- name: Copy integration plugin to output directory
9090
working-directory: .
91-
run: cp ./platform/build/integration-plugin ./template-plugin/
91+
run: cp ./platform/build/integration-plugin ./kubernetes-plugin/
9292
- name: Copy manifest to output directory
9393
working-directory: .
94-
run: cp ./platform/constants/manifest.yaml ./template-plugin/
94+
run: cp ./platform/constants/manifest.yaml ./kubernetes-plugin/
9595
- name: Pack output
9696
working-directory: .
9797
run: |
98-
tar -czf template-plugin.tar template-plugin
99-
- name: Upload template outputs artifact
98+
tar -czf kubernetes-plugin.tar kubernetes-plugin
99+
- name: Upload kubernetes outputs artifact
100100
uses: actions/[email protected]
101101
with:
102-
name: template-plugins
103-
path: ./template-plugin.tar
102+
name: kubernetes-plugins
103+
path: ./kubernetes-plugin.tar
104104
retention-days: 1
105105

106106
- name: Set Latest Tag Output
@@ -111,7 +111,7 @@ jobs:
111111
else
112112
echo "latest_tag=${{ steps.tag_version.outputs.new_tag }}" >> "$GITHUB_OUTPUT"
113113
fi
114-
deploy-template-plugin:
114+
deploy-kubernetes-plugin:
115115
needs: build
116116
runs-on: ubuntu-latest
117117
permissions:
@@ -121,12 +121,12 @@ jobs:
121121
steps:
122122
- name: Checkout Code
123123
uses: actions/checkout@v4
124-
- name: Download Template Plugin Artifact
124+
- name: Download Kubernetes Plugin Artifact
125125
uses: actions/download-artifact@v4
126126
with:
127-
name: steampipe-plugin-template
127+
name: steampipe-plugin-kubernetes
128128
path: .
129-
- name: Unpack Template Plugin Artifact
129+
- name: Unpack Kubernetes Plugin Artifact
130130
run: |
131131
tar -xvf build.tar
132132
- name: Log in to Container Registry
@@ -135,13 +135,13 @@ jobs:
135135
registry: ghcr.io
136136
username: ${{ github.actor }}
137137
password: ${{ secrets.GHCR_PAT }}
138-
- name: Build and Push Docker Image for Template Plugin
138+
- name: Build and Push Docker Image for Kubernetes Plugin
139139
uses: docker/build-push-action@v4
140140
with:
141141
push: true
142142
tags: |
143-
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-template:0.0.1
144-
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-template:${{ needs.build.outputs.latest_tag }}
143+
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-kubernetes:0.0.1
144+
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-kubernetes:${{ needs.build.outputs.latest_tag }}
145145
file: cloudql/docker/Dockerfile
146146
context: .
147147
deploy-local-describer:
@@ -158,7 +158,7 @@ jobs:
158158
- name: Download Local Describer Artifact
159159
uses: actions/download-artifact@v4
160160
with:
161-
name: local-og-describer-template
161+
name: local-og-describer-kubernetes
162162
path: .
163163
- name: Unpack Local Describer Artifact
164164
run: |
@@ -174,8 +174,8 @@ jobs:
174174
with:
175175
push: true
176176
tags: |
177-
ghcr.io/${{ github.repository_owner }}/og-describer-template:local-latest
178-
ghcr.io/${{ github.repository_owner }}/og-describer-template:local-${{ needs.build.outputs.latest_tag }}
177+
ghcr.io/${{ github.repository_owner }}/og-describer-kubernetes:local-latest
178+
ghcr.io/${{ github.repository_owner }}/og-describer-kubernetes:local-${{ needs.build.outputs.latest_tag }}
179179
file: discovery/DockerFile
180180
context: .
181181
release-integration-plugin:
@@ -192,16 +192,16 @@ jobs:
192192
- name: Download Integration Plugin Artifact
193193
uses: actions/download-artifact@v4
194194
with:
195-
name: template-plugins
195+
name: kubernetes-plugins
196196
- name: Unpack Integration Plugin Artifact
197197
run: |
198-
tar -xvf template-plugin.tar
198+
tar -xvf kubernetes-plugin.tar
199199
- name: Pack folder content into a zip file for release
200200
run: |
201-
cd template-plugin
202-
zip -r template-plugin.zip .
201+
cd kubernetes-plugin
202+
zip -r kubernetes-plugin.zip .
203203
- name: Release Integration Plugin
204204
uses: softprops/action-gh-release@v2
205205
with:
206-
files: ./template-plugin/template-plugin.zip
206+
files: ./kubernetes-plugin/kubernetes-plugin.zip
207207
tag_name: ${{ needs.build.outputs.latest_tag }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Fill the Integration information of the Provider in the [configs.go](./global/co
5757
const (
5858
IntegrationTypeLower = "template" // example: aws, azure
5959
IntegrationName = integration.Type("template,github") // example: aws_account, github_account
60-
OGPluginRepoURL = "github.com/opengovern/og-describer-template" // example: github.com/opengovern/og-describer-aws
60+
OGPluginRepoURL = "github.com/opengovern/og-describer-kubernetes" // example: github.com/opengovern/og-describer-aws
6161
)
6262
```
6363

@@ -173,11 +173,11 @@ result will be saved in the output.json file.
173173

174174
You can connect the describer to steampipe. For this, you should implement the steampipe plugin.
175175

176-
You can use the [example plugin](./cloudql/template) as a reference. Example is for describing CohereAI datasets resource.
176+
You can use the [example plugin](./cloudql/kubernetes) as a reference. Example is for describing CohereAI datasets resource.
177177

178178
### 7.1 Add Table for the resource
179179

180-
Add a file with this format: `table_template_resource.go` in the [plugin folder](./cloudql/template).
180+
Add a file with this format: `table_template_resource.go` in the [plugin folder](./cloudql/kubernetes).
181181
You Should implement the table definition for the resource. [Example file](./cloudql/template/table_template_artifact_dockerfile.go) is for describing CohereAI datasets resource.
182182

183183
**Note:** Transform Field should have `Description.` prefix.
@@ -210,6 +210,6 @@ Also there is an example for write a UI spec for digitalocean in the [example](h
210210

211211
## 9 Test Plugins
212212

213-
Change the [build.yaml.txt](.github/workflows/build.yaml.txt) to `build.yaml` and change the names of the plugins in the file.
213+
Change the [build.yaml.txt](.github/workflows/build.yaml) to `build.yaml` and change the names of the plugins in the file.
214214

215215
Then you can test the plugins with runing action on the github.

cloudql/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ STEAMPIPE_INSTALL_DIR ?= ~/.steampipe
22
BUILD_TAGS = netgo
33

44
build:
5-
GOPRIVATE="github.com/opengovern" CC=/usr/bin/musl-gcc GOOS=linux GOARCH=amd64 go build -v -mod=mod -ldflags "-linkmode external -extldflags '-static' -s -w" -o ./build/steampipe-plugin-template.plugin *.go
5+
GOPRIVATE="github.com/opengovern" CC=/usr/bin/musl-gcc GOOS=linux GOARCH=amd64 go build -v -mod=mod -ldflags "-linkmode external -extldflags '-static' -s -w" -o ./build/steampipe-plugin-kubernetes.plugin *.go
66

77
install:
8-
go build -o $(STEAMPIPE_INSTALL_DIR)/plugins/hub.steampipe.io/plugins/turbot/template@latest/steampipe-plugin-template.plugin -tags "${BUILD_TAGS}" *.go
8+
go build -o $(STEAMPIPE_INSTALL_DIR)/plugins/hub.steampipe.io/plugins/turbot/kubernetes@latest/steampipe-plugin-kubernetes.plugin -tags "${BUILD_TAGS}" *.go

cloudql/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
FROM alpine:latest
22

3-
COPY ../build/steampipe-plugin-template.plugin /steampipe-plugin-template.plugin
3+
COPY ../build/steampipe-plugin-kubernetes.plugin /steampipe-plugin-kubernetes.plugin
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package kubernetes
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
7+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
8+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
9+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
10+
)
11+
12+
const (
13+
ColumnDescriptionTitle = "Title of the resource."
14+
ColumnDescriptionAkas = "Array of globally unique identifier strings (also known as) for the resource."
15+
ColumnDescriptionTags = "A map of tags for the resource. This includes both labels and annotations."
16+
)
17+
18+
func objectMetadataColumns() []*plugin.Column {
19+
return []*plugin.Column{
20+
{Name: "name", Type: proto.ColumnType_STRING, Transform: transform.FromField("Description.MetaObject.Name"), Description: "Name of the object. Name must be unique within a namespace."},
21+
{Name: "namespace", Type: proto.ColumnType_STRING, Transform: transform.FromField("Description.MetaObject.Namespace"), Description: "Namespace defines the space within which each name must be unique."},
22+
{Name: "uid", Type: proto.ColumnType_STRING, Description: "UID is the unique in time and space value for this object.", Transform: transform.FromField("Description.MetaObject.UID").Transform(transform.NullIfZeroValue)},
23+
{Name: "generate_name", Type: proto.ColumnType_STRING, Transform: transform.FromField("Description.MetaObject.GenerateName"), Description: "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided."},
24+
{Name: "resource_version", Type: proto.ColumnType_STRING, Transform: transform.FromField("Description.MetaObject.ResourceVersion"), Description: "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed."},
25+
{Name: "generation", Type: proto.ColumnType_INT, Transform: transform.FromField("Description.MetaObject.Generation"), Description: "A sequence number representing a specific generation of the desired state."},
26+
{Name: "creation_timestamp", Type: proto.ColumnType_TIMESTAMP, Transform: transform.FromField("Description.MetaObject.CreationTimestamp").Transform(v1TimeToRFC3339), Description: "CreationTimestamp is a timestamp representing the server time when this object was created."},
27+
{Name: "deletion_timestamp", Type: proto.ColumnType_TIMESTAMP, Transform: transform.FromField("Description.MetaObject.DeletionTimestamp").Transform(v1TimeToRFC3339), Description: "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted."},
28+
{Name: "deletion_grace_period_seconds", Type: proto.ColumnType_INT, Transform: transform.FromField("Description.MetaObject.DeletionGracePeriodSeconds"), Description: "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set."},
29+
{Name: "labels", Type: proto.ColumnType_JSON, Transform: transform.FromField("Description.MetaObject.Labels"), Description: "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services."},
30+
{Name: "annotations", Type: proto.ColumnType_JSON, Transform: transform.FromField("Description.MetaObject.Annotations"), Description: "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata."},
31+
{Name: "owner_references", Type: proto.ColumnType_JSON, Transform: transform.FromField("Description.MetaObject.OwnerReferences"), Description: "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller."},
32+
{Name: "finalizers", Type: proto.ColumnType_JSON, Transform: transform.FromField("Description.MetaObject.Finalizers"), Description: "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed."},
33+
}
34+
}
35+
36+
func commonColumns(c []*plugin.Column) []*plugin.Column {
37+
res := objectMetadataColumns()
38+
res = append(res, c...)
39+
res = append(res, []*plugin.Column{
40+
{
41+
Name: "platform_integration_id",
42+
Type: proto.ColumnType_STRING,
43+
Description: "The Platform Integration ID in which the resource is located.",
44+
Transform: transform.FromField("IntegrationID"),
45+
},
46+
{
47+
Name: "platform_resource_id",
48+
Type: proto.ColumnType_STRING,
49+
Description: "The unique ID of the resource in opengovernance.",
50+
Transform: transform.FromField("PlatformID"),
51+
},
52+
{
53+
Name: "platform_metadata",
54+
Type: proto.ColumnType_JSON,
55+
Description: "The metadata of the resource",
56+
Transform: transform.FromField("Metadata").Transform(marshalJSON),
57+
},
58+
{
59+
Name: "platform_resource_description",
60+
Type: proto.ColumnType_JSON,
61+
Description: "The full model description of the resource",
62+
Transform: transform.FromField("Description").Transform(marshalJSON),
63+
},
64+
}...)
65+
return res
66+
}
67+
68+
func marshalJSON(_ context.Context, d *transform.TransformData) (interface{}, error) {
69+
b, err := json.Marshal(d.Value)
70+
if err != nil {
71+
return nil, err
72+
}
73+
return string(b), nil
74+
}
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package template
1+
package kubernetes
22

33
import (
44
"context"
@@ -60,17 +60,3 @@ func retryConfig() *plugin.RetryConfig {
6060
CappedDuration: 30000,
6161
}
6262
}
63-
64-
// function which returns an ErrorPredicate for GitHub API calls
65-
func isNotFoundError(notFoundErrors []string) plugin.ErrorPredicate {
66-
return func(err error) bool {
67-
if err != nil {
68-
for _, item := range notFoundErrors {
69-
if strings.Contains(err.Error(), item) {
70-
return true
71-
}
72-
}
73-
}
74-
return false
75-
}
76-
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package template
1+
package kubernetes
22

33
import (
44
"context"
@@ -19,8 +19,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
1919
},
2020
DefaultTransform: transform.FromCamel(),
2121
TableMap: map[string]*plugin.Table{
22-
23-
"github_artifact_dockerfile": tableGitHubArtifactDockerFile(),
22+
"kubernetes_node": tableKubernetesNode(),
2423
},
2524
}
2625
for key, table := range p.TableMap {

0 commit comments

Comments
 (0)