Skip to content

Commit

Permalink
Update resource-metadata deps
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha committed Sep 6, 2024
1 parent d850fbf commit 8e112fe
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 31 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
kmodules.xyz/custom-resources v0.30.0
kmodules.xyz/go-containerregistry v0.0.12
kmodules.xyz/monitoring-agent-api v0.29.0
kmodules.xyz/resource-metadata v0.18.13-0.20240904102543-ace8c94cfd3d
kmodules.xyz/resource-metadata v0.18.13-0.20240906124638-46438a4d2a94
kmodules.xyz/resource-metrics v0.30.4
kmodules.xyz/resource-metrics/utils v0.30.4
kmodules.xyz/sets v0.29.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,8 @@ kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9
kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI=
kmodules.xyz/offshoot-api v0.30.0 h1:dq9F93pu4Q8rL9oTcCk+vGGy8vpS7RNt0GSwx7Bvhec=
kmodules.xyz/offshoot-api v0.30.0/go.mod h1:o9VoA3ImZMDBp3lpLb8+kc2d/KBxioRwCpaKDfLIyDw=
kmodules.xyz/resource-metadata v0.18.13-0.20240904102543-ace8c94cfd3d h1:2TzGz3I9AZ+Eb/0XY5hXsHcMCHkczlrkSE/lBEp002s=
kmodules.xyz/resource-metadata v0.18.13-0.20240904102543-ace8c94cfd3d/go.mod h1:KC8yk1AaAMRht7mLVPA6iP2U6n9qIAzR89I8IMejLgs=
kmodules.xyz/resource-metadata v0.18.13-0.20240906124638-46438a4d2a94 h1:bmvgJv6ZPyzy1+fqI7+6H3ACvEDuG+RKCdj4ryYJDlI=
kmodules.xyz/resource-metadata v0.18.13-0.20240906124638-46438a4d2a94/go.mod h1:KC8yk1AaAMRht7mLVPA6iP2U6n9qIAzR89I8IMejLgs=
kmodules.xyz/resource-metrics v0.30.4 h1:8HBPtYmo9ETY91gsc55JE8Z986+3ZuRq57M0wZ9npqI=
kmodules.xyz/resource-metrics v0.30.4/go.mod h1:w9+rz7/s/kGP1GWzYSuRdCn+l7EwpesmESSEHkLBnIQ=
kmodules.xyz/resource-metrics/utils v0.30.4 h1:bJS/x0Qr7N1FFdxugFbzZ/Es6HVs4ptsFlhkmgj3jac=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ spec:
items:
- name: User Permissions
path: /access
required: true
name: Access
- icons:
- src: https://cdn.appscode.com/k8s/icons/menu/helm.svg
Expand All @@ -93,4 +94,5 @@ spec:
items:
- name: Issue License
path: /license
required: true
name: License
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Service Name
pathTemplate: '{{ .spec.serviceName }}'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Service Name
pathTemplate: '{{ .spec.serviceName }}'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.jobTemplate.spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.jobTemplate.spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.jobTemplate.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Restart Policy
pathTemplate: '{{ .spec.restartPolicy }}'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
- name: Images
pathTemplate: '{{ .spec.template.spec.containers | k8s_container_images }}'
priority: 2
type: string
type: object
- name: Security Context
pathTemplate: '{ "runAsUser": "{{ jp "{.spec.template.spec.securityContext.runAsUser}" . }}", "runAsGroup": "{{ jp "{.spec.template.spec.securityContext.runAsGroup}" . }}","fsGroup": "{{ jp "{.spec.template.spec.securityContext.fsGroup}" . }}" }'
priority: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ spec:
priority: 2
type: string
- name: Selector
pathTemplate: '{{ .spec.selector | toRawJson }}'
priority: 3
type: string
type: object
- name: Age
pathTemplate: '{{ .metadata.creationTimestamp | k8s_age }}'
priority: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package tableconvertor

import (
"bytes"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -328,27 +327,56 @@ func promNamespaceSelectorFn(data interface{}) (string, error) {
}

func containerImagesFn(data interface{}) (string, error) {
var containers []core.Container
var images []map[string]string
appendImage := func(name, image string) {
images = append(images, map[string]string{
"container": name,
"image": image,
})
}

if s, ok := data.(string); ok && s != "" {
err := json.Unmarshal([]byte(s), &containers)
if err != nil {
return "", err
var containers []map[string]interface{}
if err := json.Unmarshal([]byte(s), &containers); err != nil {
return "", fmt.Errorf("failed to unmarshal containers JSON: %w", err)
}
for _, container := range containers {
if name, ok := container["name"].(string); ok {
if image, ok := container["image"].(string); ok {
appendImage(name, image)
}
}
}
} else if _, ok := data.(map[string]interface{}); ok {
err := meta_util.DecodeObject(data, &containers)
if err != nil {
return "", err
} else if m, ok := data.(map[string]interface{}); ok {
if containerList, ok := m["containers"].([]interface{}); ok {
for _, c := range containerList {
if container, ok := c.(map[string]interface{}); ok {
if name, ok := container["name"].(string); ok {
if image, ok := container["image"].(string); ok {
appendImage(name, image)
}
}
}
}
}
} else if slice, ok := data.([]interface{}); ok {
for _, item := range slice {
if container, ok := item.(map[string]interface{}); ok {
if name, ok := container["name"].(string); ok {
if image, ok := container["image"].(string); ok {
appendImage(name, image)
}
}
}
}
}

var imagesBuffer bytes.Buffer
for i, container := range containers {
imagesBuffer.WriteString(container.Image)
if i != len(containers)-1 {
imagesBuffer.WriteString(",")
}
imagesJSON, err := json.Marshal(images)
if err != nil {
return "", err
}
return imagesBuffer.String(), nil

return string(imagesJSON), nil
}

func durationFn(start interface{}, end ...interface{}) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@ kmodules.xyz/monitoring-agent-api/client
## explicit; go 1.22.0
kmodules.xyz/offshoot-api/api/v1
kmodules.xyz/offshoot-api/api/v2
# kmodules.xyz/resource-metadata v0.18.13-0.20240904102543-ace8c94cfd3d
# kmodules.xyz/resource-metadata v0.18.13-0.20240906124638-46438a4d2a94
## explicit; go 1.22.1
kmodules.xyz/resource-metadata/apis/core/install
kmodules.xyz/resource-metadata/apis/core/v1alpha1
Expand Down

0 comments on commit 8e112fe

Please sign in to comment.