@@ -29,18 +29,18 @@ func tableKubernetesPod(ctx context.Context) *plugin.Table {
2929 Description : "List of containers belonging to the pod." ,
3030 Transform : transform .FromField ("Description.Pod.Spec.Containers" ),
3131 },
32- {
33- Name : "containers_resources_limits_std" ,
34- Type : proto .ColumnType_JSON ,
35- Description : "Standardized CPU and memory resource limits in millicores for each container in the pod." ,
36- Transform : transform .FromP (transformPodCpuAndMemoryUnit , "limit" ),
37- },
38- {
39- Name : "containers_resources_requests_std" ,
40- Type : proto .ColumnType_JSON ,
41- Description : "Standardized CPU and memory resource requests in millicores for each container in the pod." ,
42- Transform : transform .FromP (transformPodCpuAndMemoryUnit , "request" ),
43- },
32+ // {
33+ // Name: "containers_resources_limits_std",
34+ // Type: proto.ColumnType_JSON,
35+ // Description: "Standardized CPU and memory resource limits in millicores for each container in the pod.",
36+ // Transform: transform.FromP(transformPodCpuAndMemoryUnit, "limit"),
37+ // },
38+ // {
39+ // Name: "containers_resources_requests_std",
40+ // Type: proto.ColumnType_JSON,
41+ // Description: "Standardized CPU and memory resource requests in millicores for each container in the pod.",
42+ // Transform: transform.FromP(transformPodCpuAndMemoryUnit, "request"),
43+ // },
4444 {
4545 Name : "ephemeral_containers" ,
4646 Type : proto .ColumnType_JSON ,
@@ -403,76 +403,77 @@ func transformPodTags(_ context.Context, d *transform.TransformData) (interface{
403403 return mergeTags (obj .Labels , obj .Annotations ), nil
404404}
405405
406- func transformPodCpuAndMemoryUnit (ctx context.Context , d * transform.TransformData ) (interface {}, error ) {
407- param := d .Param .(string )
408-
409- pod := d .HydrateItem .(opengovernance.KubernetesPod ).Description .Pod
410-
411- containers := pod .Spec .DeepCopy ().Containers
412-
413- if param == "limit" {
414- limitCPUMemoryMaps := make ([]map [string ]interface {}, 0 )
415-
416- limitCPUMemoryMap := make (map [string ]interface {})
417-
418- for _ , container := range containers {
419- limit := container .Resources .Limits
420- limitCPUMemoryMap ["containerName" ] = container .Name
421- limitCPUMemoryMap ["containerImage" ] = container .Image
422- if limit .Cpu ().String () != "" && ! limit .Cpu ().IsZero () {
423- cpu , err := normalizeCPUToMilliCores (limit .Cpu ().String ())
424- if err != nil {
425- plugin .Logger (ctx ).Error ("k8_pod.transformPodCpuAndMemoryUnit" , "error in parsing the CPU value" , err )
426- return nil , err
427- }
428- limitCPUMemoryMap ["cpu" ] = cpu
429- }
430-
431- if limit .Memory ().String () != "" && ! limit .Memory ().IsZero () {
432- memory , err := normalizeMemoryToBytes (limit .Memory ().String ())
433- if err != nil {
434- plugin .Logger (ctx ).Error ("k8_pod.transformPodCpuAndMemoryUnit" , "error in parsing the memory value" , err )
435- return nil , err
436- }
437- limitCPUMemoryMap ["memory" ] = memory
438- }
439- limitCPUMemoryMaps = append (limitCPUMemoryMaps , limitCPUMemoryMap )
440-
441- }
442-
443- return limitCPUMemoryMaps , nil
444- } else if param == "request" {
445- requestCPUMemoryMaps := make ([]map [string ]interface {}, 0 )
446-
447- requestCPUMemoryMap := make (map [string ]interface {})
448-
449- for _ , container := range containers {
450- request := container .Resources .Requests
451- requestCPUMemoryMap ["containerName" ] = container .Name
452- requestCPUMemoryMap ["containerImage" ] = container .Image
453- if request .Cpu ().String () != "" && ! request .Cpu ().IsZero () {
454- cpu , err := normalizeCPUToMilliCores (request .Cpu ().String ())
455- if err != nil {
456- plugin .Logger (ctx ).Error ("k8_pod.transformPodCpuAndMemoryUnit" , "error in parsing the CPU value" , err )
457- return nil , err
458- }
459- requestCPUMemoryMap ["cpu" ] = cpu
460- }
461-
462- if request .Memory ().String () != "" && ! request .Memory ().IsZero () {
463- memory , err := normalizeMemoryToBytes (request .Memory ().String ())
464- if err != nil {
465- plugin .Logger (ctx ).Error ("k8_pod.transformPodCpuAndMemoryUnit" , "error in parsing the memory value" , err )
466- return nil , err
467- }
468- requestCPUMemoryMap ["memory" ] = memory
469- }
470- requestCPUMemoryMaps = append (requestCPUMemoryMaps , requestCPUMemoryMap )
471-
472- }
473-
474- return requestCPUMemoryMaps , nil
475- }
476-
477- return nil , nil
478- }
406+ //
407+ //func transformPodCpuAndMemoryUnit(ctx context.Context, d *transform.TransformData) (interface{}, error) {
408+ // param := d.Param.(string)
409+ //
410+ // pod := d.HydrateItem.(opengovernance.KubernetesPod).Description.Pod
411+ //
412+ // containers := pod.Spec.Containers
413+ //
414+ // if param == "limit" {
415+ // limitCPUMemoryMaps := make([]map[string]interface{}, 0)
416+ //
417+ // limitCPUMemoryMap := make(map[string]interface{})
418+ //
419+ // for _, container := range containers {
420+ // limit := container.Resources.Limits
421+ // limitCPUMemoryMap["containerName"] = container.Name
422+ // limitCPUMemoryMap["containerImage"] = container.Image
423+ // if limit.Cpu().String() != "" && !limit.Cpu().IsZero() {
424+ // cpu, err := normalizeCPUToMilliCores(limit.Cpu().String())
425+ // if err != nil {
426+ // plugin.Logger(ctx).Error("k8_pod.transformPodCpuAndMemoryUnit", "error in parsing the CPU value", err)
427+ // return nil, err
428+ // }
429+ // limitCPUMemoryMap["cpu"] = cpu
430+ // }
431+ //
432+ // if limit.Memory().String() != "" && !limit.Memory().IsZero() {
433+ // memory, err := normalizeMemoryToBytes(limit.Memory().String())
434+ // if err != nil {
435+ // plugin.Logger(ctx).Error("k8_pod.transformPodCpuAndMemoryUnit", "error in parsing the memory value", err)
436+ // return nil, err
437+ // }
438+ // limitCPUMemoryMap["memory"] = memory
439+ // }
440+ // limitCPUMemoryMaps = append(limitCPUMemoryMaps, limitCPUMemoryMap)
441+ //
442+ // }
443+ //
444+ // return limitCPUMemoryMaps, nil
445+ // } else if param == "request" {
446+ // requestCPUMemoryMaps := make([]map[string]interface{}, 0)
447+ //
448+ // requestCPUMemoryMap := make(map[string]interface{})
449+ //
450+ // for _, container := range containers {
451+ // request := container.Resources.Requests
452+ // requestCPUMemoryMap["containerName"] = container.Name
453+ // requestCPUMemoryMap["containerImage"] = container.Image
454+ // if request.Cpu().String() != "" && !request.Cpu().IsZero() {
455+ // cpu, err := normalizeCPUToMilliCores(request.Cpu().String())
456+ // if err != nil {
457+ // plugin.Logger(ctx).Error("k8_pod.transformPodCpuAndMemoryUnit", "error in parsing the CPU value", err)
458+ // return nil, err
459+ // }
460+ // requestCPUMemoryMap["cpu"] = cpu
461+ // }
462+ //
463+ // if request.Memory().String() != "" && !request.Memory().IsZero() {
464+ // memory, err := normalizeMemoryToBytes(request.Memory().String())
465+ // if err != nil {
466+ // plugin.Logger(ctx).Error("k8_pod.transformPodCpuAndMemoryUnit", "error in parsing the memory value", err)
467+ // return nil, err
468+ // }
469+ // requestCPUMemoryMap["memory"] = memory
470+ // }
471+ // requestCPUMemoryMaps = append(requestCPUMemoryMaps, requestCPUMemoryMap)
472+ //
473+ // }
474+ //
475+ // return requestCPUMemoryMaps, nil
476+ // }
477+ //
478+ // return nil, nil
479+ //}
0 commit comments