Skip to content

Commit d0851e8

Browse files
Arta AsadiArta Asadi
authored andcommitted
fix: add data to k8_secret and k8_configmap
1 parent a2b2fc8 commit d0851e8

File tree

7 files changed

+51
-27
lines changed

7 files changed

+51
-27
lines changed

cloudql/kubernetes/table_kubernetes_config_map.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func tableKubernetesConfigMap(ctx context.Context) *plugin.Table {
2323
Description: "If set to true, ensures that data stored in the ConfigMap cannot be updated (only object metadata can be modified). If not set to true, the field can be modified at any time. Defaulted to nil.",
2424
Transform: transform.FromField("Description.ConfigMap.Immutable"),
2525
},
26+
{
27+
Name: "data",
28+
Type: proto.ColumnType_JSON,
29+
Description: "configmap data",
30+
Transform: transform.FromField("Description.ConfigMap.Data"),
31+
},
2632
//// Steampipe Standard Columns
2733
{
2834
Name: "title",

cloudql/kubernetes/table_kubernetes_job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func tableKubernetesJob(ctx context.Context) *plugin.Table {
1313
Name: "k8_job",
1414
Description: "A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate.",
1515
List: &plugin.ListConfig{
16-
Hydrate: opengovernance.ListKubernetesIngress,
16+
Hydrate: opengovernance.ListKubernetesJob,
1717
},
1818
Columns: commonColumns([]*plugin.Column{
1919
{

cloudql/kubernetes/table_kubernetes_node.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,31 @@ func transformNodeCpuAndMemoryUnit(_ context.Context, d *transform.TransformData
198198
switch param {
199199
case "Capacity.CPU":
200200
if v, ok := node.Status.Capacity["cpu"]; ok {
201-
return v, nil
201+
if vv, k := v.AsInt64(); k {
202+
return vv, nil
203+
}
204+
return nil, nil
202205
}
203206
case "Capacity.Memory":
204207
if v, ok := node.Status.Capacity["memory"]; ok {
205-
return v, nil
208+
if vv, k := v.AsInt64(); k {
209+
return vv, nil
210+
}
211+
return nil, nil
206212
}
207213
case "Allocatable.CPU":
208214
if v, ok := node.Status.Allocatable["cpu"]; ok {
209-
return v, nil
215+
if vv, k := v.AsInt64(); k {
216+
return vv, nil
217+
}
218+
return nil, nil
210219
}
211220
case "Allocatable.Memory":
212221
if v, ok := node.Status.Allocatable["memory"]; ok {
213-
return v, nil
222+
if vv, k := v.AsInt64(); k {
223+
return vv, nil
224+
}
225+
return nil, nil
214226
}
215227
}
216228

@@ -224,19 +236,19 @@ func transformNodeCpuAndMemory(_ context.Context, d *transform.TransformData) (a
224236
switch param {
225237
case "Capacity.CPU":
226238
if v, ok := node.Status.Capacity["cpu"]; ok {
227-
return v, nil
239+
return v.String(), nil
228240
}
229241
case "Capacity.Memory":
230242
if v, ok := node.Status.Capacity["memory"]; ok {
231-
return v, nil
243+
return v.String(), nil
232244
}
233245
case "Allocatable.CPU":
234246
if v, ok := node.Status.Allocatable["cpu"]; ok {
235-
return v, nil
247+
return v.String(), nil
236248
}
237249
case "Allocatable.Memory":
238250
if v, ok := node.Status.Allocatable["memory"]; ok {
239-
return v, nil
251+
return v.String(), nil
240252
}
241253
}
242254

cloudql/kubernetes/table_kubernetes_secret.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ func tableKubernetesSecret(ctx context.Context) *plugin.Table {
2828
Description: "Type of the secret data.",
2929
Transform: transform.FromField("Description.Secret.Type"),
3030
},
31+
{
32+
Name: "data",
33+
Type: proto.ColumnType_JSON,
34+
Description: "Type of the secret data.",
35+
Transform: transform.FromField("Description.Secret.Data"),
36+
},
37+
{
38+
Name: "string_data",
39+
Type: proto.ColumnType_JSON,
40+
Description: "Type of the secret data.",
41+
Transform: transform.FromField("Description.Secret.StringData"),
42+
},
3143

3244
//// Steampipe Standard Columns
3345
{

discovery/describers/kubernetes.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ func KubernetesConfigMap(ctx context.Context, client model.Client, extra string,
121121
for _, configMap := range configMaps.Items {
122122
var resource models.Resource
123123

124-
// Do not include the data in the configmap
125-
configMap.Data = nil
126124
configMap.BinaryData = nil
127-
// We don't need to include the managed fields in the description, also it causes issues in elastic search mapping generation
128-
configMap.ManagedFields = nil
129125
resource = models.Resource{
130126
ID: fmt.Sprintf("configmap/%s/%s", configMap.Namespace, configMap.Name),
131127
Name: fmt.Sprintf("%s/%s", configMap.Namespace, configMap.Name),
@@ -136,7 +132,6 @@ func KubernetesConfigMap(ctx context.Context, client model.Client, extra string,
136132
ObjectMeta: helpers.ConvertObjectMeta(&configMap.ObjectMeta),
137133
Immutable: configMap.Immutable,
138134
Data: configMap.Data,
139-
BinaryData: configMap.BinaryData,
140135
},
141136
},
142137
}
@@ -1038,11 +1033,6 @@ func KubernetesSecret(ctx context.Context, client model.Client, extra string, st
10381033

10391034
for _, secret := range secrets.Items {
10401035
var resource models.Resource
1041-
// Do not include the data in the secret
1042-
secret.Data = nil
1043-
secret.StringData = nil
1044-
// We don't need to include the managed fields in the description, also it causes issues in elastic search mapping generation
1045-
secret.ManagedFields = nil
10461036
resource = models.Resource{
10471037
ID: fmt.Sprintf("secret/%s/%s", secret.Namespace, secret.Name),
10481038
Name: fmt.Sprintf("%s/%s", secret.Namespace, secret.Name),

discovery/pkg/es/resources_clients.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ func (p KubernetesConfigMapPaginator) NextPage(ctx context.Context) ([]Kubernete
724724
}
725725

726726
var listKubernetesConfigMapFilters = map[string]string{
727+
"data": "Description.ConfigMap.Data",
727728
"immutable": "Description.ConfigMap.Immutable",
728729
"title": "Description.ConfigMap.Name",
729730
}
@@ -789,6 +790,7 @@ func ListKubernetesConfigMap(ctx context.Context, d *plugin.QueryData, _ *plugin
789790
}
790791

791792
var getKubernetesConfigMapFilters = map[string]string{
793+
"data": "Description.ConfigMap.Data",
792794
"immutable": "Description.ConfigMap.Immutable",
793795
"title": "Description.ConfigMap.Name",
794796
}
@@ -6434,9 +6436,11 @@ func (p KubernetesSecretPaginator) NextPage(ctx context.Context) ([]KubernetesSe
64346436
}
64356437

64366438
var listKubernetesSecretFilters = map[string]string{
6437-
"immutable": "Description.Secret.Immutable",
6438-
"title": "Description.Secret.Name",
6439-
"type": "Description.Secret.Type",
6439+
"data": "Description.Secret.Data",
6440+
"immutable": "Description.Secret.Immutable",
6441+
"string_data": "Description.Secret.StringData",
6442+
"title": "Description.Secret.Name",
6443+
"type": "Description.Secret.Type",
64406444
}
64416445

64426446
func ListKubernetesSecret(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
@@ -6500,9 +6504,11 @@ func ListKubernetesSecret(ctx context.Context, d *plugin.QueryData, _ *plugin.Hy
65006504
}
65016505

65026506
var getKubernetesSecretFilters = map[string]string{
6503-
"immutable": "Description.Secret.Immutable",
6504-
"title": "Description.Secret.Name",
6505-
"type": "Description.Secret.Type",
6507+
"data": "Description.Secret.Data",
6508+
"immutable": "Description.Secret.Immutable",
6509+
"string_data": "Description.Secret.StringData",
6510+
"title": "Description.Secret.Name",
6511+
"type": "Description.Secret.Type",
65066512
}
65076513

65086514
func GetKubernetesSecret(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {

discovery/provider/helpers/config_map.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type ConfigMap struct {
1010
ObjectMeta // Assumes ObjectMeta in model_helpers.go
1111
Immutable *bool
1212
Data map[string]string
13-
BinaryData map[string][]byte
1413
}
1514

1615
// ConvertConfigMap creates a helper ConfigMap from a corev1 ConfigMap
@@ -20,6 +19,5 @@ func ConvertConfigMap(cm *corev1.ConfigMap) ConfigMap {
2019
ObjectMeta: ConvertObjectMeta(&cm.ObjectMeta), // Assumes ConvertObjectMeta in model_helpers.go
2120
Immutable: cm.Immutable,
2221
Data: cm.Data,
23-
BinaryData: cm.BinaryData,
2422
}
2523
}

0 commit comments

Comments
 (0)