Skip to content

Commit fdb9a0b

Browse files
committed
feat: add some tables
1 parent 5c981dd commit fdb9a0b

23 files changed

+2535
-62
lines changed

cloudql/kubernetes/plugin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ import (
1212
// Plugin returns this plugin
1313
func Plugin(ctx context.Context) *plugin.Plugin {
1414
p := &plugin.Plugin{
15-
Name: "steampipe-plugin-github",
15+
Name: "steampipe-plugin-kubernetes",
1616
ConnectionConfigSchema: &plugin.ConnectionConfigSchema{
1717
NewInstance: essdk.ConfigInstance,
1818
Schema: essdk.ConfigSchema(),
1919
},
2020
DefaultTransform: transform.FromCamel(),
2121
TableMap: map[string]*plugin.Table{
22-
"kubernetes_node": tableKubernetesNode(),
22+
"kubernetes_node": tableKubernetesNode(ctx),
23+
"kubernetes_persistent_volume_claim": tableKubernetesPersistentVolumeClaim(ctx),
24+
"kubernetes_persistent_volume": tableKubernetesPersistentVolume(ctx),
2325
},
2426
}
2527
for key, table := range p.TableMap {

cloudql/kubernetes/table_kubernetes_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
1010
)
1111

12-
func tableKubernetesNode() *plugin.Table {
12+
func tableKubernetesNode(ctx context.Context) *plugin.Table {
1313
return &plugin.Table{
1414
Name: "kubernetes_node",
1515
Description: "Kubernetes Node is a worker node in Kubernetes.",
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package kubernetes
2+
3+
import (
4+
"context"
5+
opengovernance "github.com/opengovern/og-describer-kubernetes/discovery/pkg/es"
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+
func tableKubernetesPersistentVolume(ctx context.Context) *plugin.Table {
13+
return &plugin.Table{
14+
Name: "kubernetes_persistent_volume",
15+
Description: "A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV.",
16+
Get: &plugin.GetConfig{
17+
Hydrate: opengovernance.GetKubernetesPersistentVolume,
18+
},
19+
List: &plugin.ListConfig{
20+
Hydrate: opengovernance.ListKubernetesPersistentVolume,
21+
},
22+
Columns: commonColumns([]*plugin.Column{
23+
//// PersistentVolumeSpec columns
24+
{
25+
Name: "storage_class",
26+
Type: proto.ColumnType_STRING,
27+
Description: "Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.",
28+
Transform: transform.FromField("Description.PV.Spec.StorageClassName"),
29+
},
30+
{
31+
Name: "volume_mode",
32+
Type: proto.ColumnType_STRING,
33+
Description: "Defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state.",
34+
Transform: transform.FromField("Description.PV.Spec.VolumeMode"),
35+
},
36+
{
37+
Name: "persistent_volume_reclaim_policy",
38+
Type: proto.ColumnType_STRING,
39+
Description: "What happens to a persistent volume when released from its claim. Valid options are Retain (default for manually created PersistentVolumes), Delete (default for dynamically provisioned PersistentVolumes), and Recycle (deprecated). Recycle must be supported by the volume plugin underlying this PersistentVolume.",
40+
Transform: transform.FromField("Description.PV.Spec.PersistentVolumeReclaimPolicy"),
41+
},
42+
{
43+
Name: "access_modes",
44+
Type: proto.ColumnType_JSON,
45+
Description: "List of ways the volume can be mounted.",
46+
Transform: transform.FromField("Description.PV.Spec.AccessModes"),
47+
},
48+
{
49+
Name: "capacity",
50+
Type: proto.ColumnType_JSON,
51+
Description: "A description of the persistent volume's resources and capacity.",
52+
Transform: transform.FromField("Description.PV.Spec.Capacity"),
53+
},
54+
{
55+
Name: "claim_ref",
56+
Type: proto.ColumnType_JSON,
57+
Description: "ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound.",
58+
Transform: transform.FromField("Description.PV.Spec.ClaimRef"),
59+
},
60+
{
61+
Name: "mount_options",
62+
Type: proto.ColumnType_JSON,
63+
Description: "A list of mount options, e.g. [\"ro\", \"soft\"].",
64+
Transform: transform.FromField("Description.PV.Spec.MountOptions"),
65+
},
66+
{
67+
Name: "node_affinity",
68+
Type: proto.ColumnType_JSON,
69+
Description: "Defines constraints that limit what nodes this volume can be accessed from.",
70+
Transform: transform.FromField("Description.PV.Spec.NodeAffinity"),
71+
},
72+
{
73+
Name: "persistent_volume_source",
74+
Type: proto.ColumnType_JSON,
75+
Description: "The actual volume backing the persistent volume.",
76+
Transform: transform.FromField("Description.PV.Spec.PersistentVolumeSource"),
77+
},
78+
79+
//// PersistentVolumeStatus columns
80+
{
81+
Name: "phase",
82+
Type: proto.ColumnType_STRING,
83+
Description: "Phase indicates if a volume is available, bound to a claim, or released by a claim.",
84+
Transform: transform.FromField("Description.PV.Status.Phase"),
85+
},
86+
{
87+
Name: "message",
88+
Type: proto.ColumnType_STRING,
89+
Description: "A human-readable message indicating details about why the volume is in this state.",
90+
Transform: transform.FromField("Description.PV.Status.Message"),
91+
},
92+
{
93+
Name: "reason",
94+
Type: proto.ColumnType_STRING,
95+
Description: "Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.",
96+
Transform: transform.FromField("Description.PV.Status.Reason"),
97+
},
98+
{
99+
Name: "title",
100+
Type: proto.ColumnType_STRING,
101+
Description: ColumnDescriptionTitle,
102+
Transform: transform.FromField("Description.PV.Name"),
103+
},
104+
{
105+
Name: "tags",
106+
Type: proto.ColumnType_JSON,
107+
Description: ColumnDescriptionTags,
108+
Transform: transform.From(transformPVTags),
109+
},
110+
}),
111+
}
112+
}
113+
114+
//// TRANSFORM FUNCTIONS
115+
116+
func transformPVTags(_ context.Context, d *transform.TransformData) (interface{}, error) {
117+
obj := d.HydrateItem.(opengovernance.KubernetesPersistentVolume).Description.PV
118+
return mergeTags(obj.Labels, obj.Annotations), nil
119+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package kubernetes
2+
3+
import (
4+
"context"
5+
opengovernance "github.com/opengovern/og-describer-kubernetes/discovery/pkg/es"
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+
func tableKubernetesPersistentVolumeClaim(ctx context.Context) *plugin.Table {
13+
return &plugin.Table{
14+
Name: "kubernetes_persistent_volume_claim",
15+
Description: "A PersistentVolumeClaim (PVC) is a request for storage by a user.",
16+
Get: &plugin.GetConfig{
17+
Hydrate: opengovernance.GetKubernetesPersistentVolumeClaim,
18+
},
19+
List: &plugin.ListConfig{
20+
Hydrate: opengovernance.ListKubernetesPersistentVolumeClaim,
21+
},
22+
Columns: commonColumns([]*plugin.Column{
23+
{
24+
Name: "volume_name",
25+
Type: proto.ColumnType_STRING,
26+
Description: "The binding reference to the PersistentVolume backing this claim.",
27+
Transform: transform.FromField("Description.PVC.Spec.VolumeName"),
28+
},
29+
{
30+
Name: "volume_mode",
31+
Type: proto.ColumnType_STRING,
32+
Description: "Defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state.",
33+
Transform: transform.FromField("Description.PVC.Spec.VolumeMode"),
34+
},
35+
{
36+
Name: "storage_class",
37+
Type: proto.ColumnType_STRING,
38+
Description: "Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.",
39+
Transform: transform.FromField("Description.PVC.Spec.StorageClassName"),
40+
},
41+
{
42+
Name: "access_modes",
43+
Type: proto.ColumnType_JSON,
44+
Description: "List of ways the volume can be mounted.",
45+
Transform: transform.FromField("Description.PVC.Spec.AccessModes"),
46+
},
47+
{
48+
Name: "data_source",
49+
Type: proto.ColumnType_JSON,
50+
Description: "The source of the volume. This can be used to specify either: an existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot), an existing PVC (PersistentVolumeClaim) or an existing custom resource that implements data population (Alpha).",
51+
Transform: transform.FromField("Description.PVC.Spec.DataSource"),
52+
},
53+
{
54+
Name: "resources",
55+
Type: proto.ColumnType_JSON,
56+
Description: "Represents the minimum resources the volume should have.",
57+
Transform: transform.FromField("Description.PVC.Spec.Resources"),
58+
},
59+
{
60+
Name: "selector",
61+
Type: proto.ColumnType_JSON,
62+
Description: "The actual volume backing the persistent volume.",
63+
Transform: transform.FromField("Description.PVC.Spec.Selector"),
64+
},
65+
66+
//// PersistentVolumeClaimStatus columns
67+
{
68+
Name: "phase",
69+
Type: proto.ColumnType_STRING,
70+
Description: "Phase indicates the current phase of PersistentVolumeClaim.",
71+
Transform: transform.FromField("Description.PVC.Status.Phase"),
72+
},
73+
{
74+
Name: "status_access_modes",
75+
Type: proto.ColumnType_JSON,
76+
Description: "The actual access modes the volume backing the PVC has.",
77+
Transform: transform.FromField("Description.PVC.Status.AccessModes"),
78+
},
79+
{
80+
Name: "capacity",
81+
Type: proto.ColumnType_JSON,
82+
Description: "The actual resources of the underlying volume.",
83+
Transform: transform.FromField("Description.PVC.Status.Capacity"),
84+
},
85+
{
86+
Name: "conditions",
87+
Type: proto.ColumnType_JSON,
88+
Description: "The Condition of persistent volume claim.",
89+
Transform: transform.FromField("Description.PVC.Status.Conditions"),
90+
},
91+
//// Steampipe Standard Columns
92+
{
93+
Name: "title",
94+
Type: proto.ColumnType_STRING,
95+
Description: ColumnDescriptionTitle,
96+
Transform: transform.FromField("Description.PVC.Name"),
97+
},
98+
{
99+
Name: "tags",
100+
Type: proto.ColumnType_JSON,
101+
Description: ColumnDescriptionTags,
102+
Transform: transform.From(transformPVCTags),
103+
},
104+
}),
105+
}
106+
}
107+
108+
func transformPVCTags(_ context.Context, d *transform.TransformData) (interface{}, error) {
109+
obj := d.HydrateItem.(opengovernance.KubernetesPersistentVolumeClaim).Description.PVC
110+
return mergeTags(obj.Labels, obj.Annotations), nil
111+
}

0 commit comments

Comments
 (0)