func (t *ContainersTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
	pods, err := t.client.CoreV1().Pods("").List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not get pods from k8s api")
		return nil, err
	}

	// TODO: think of an efficient way to create the slice without reallocating
	rows := make([]map[string]string, 0, len(pods.Items))

	for _, pod := range pods.Items {
		for _, container := range pod.Spec.Containers {
			currRow := map[string]string{
				"name":       container.Name,
				"pod_uid":    string(pod.UID),
				"image":      container.Image,
				"privileged": "False",
			}
			if container.SecurityContext != nil {
				if container.SecurityContext.Privileged != nil {
					currRow["privileged"] = utils.Bool2str(*container.SecurityContext.Privileged)
				}
			}
			rows = append(rows, currRow)
		}
	}
	return rows, nil
}
// Generate uses the api to retrieve information on all pods
Generate uses the api to retrieve information on all pods
// Generate uses the api to retrieve information on all pods
func (t *ContainersTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
	pods, err := t.client.CoreV1().Pods("").List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not get pods from k8s api")
		return nil, err
	}
	rows := make([]map[string]string, 0, len(pods.Items))
	for _, pod := range pods.Items {
		for _, container := range pod.Spec.Containers {
			currRow := map[string]string{
				"name":       container.Name,
				"pod_uid":    string(pod.UID),
				"image":      container.Image,
				"privileged": "False",
			}
			if container.SecurityContext != nil {
				if container.SecurityContext.Privileged != nil {
					currRow["privileged"] = utils.Bool2str(*container.SecurityContext.Privileged)
				}
			}
			rows = append(rows, currRow)
		}
	}
	return rows, nil
}
func ( t * ContainersTable ) Generate ( ctx context . Context , queryContext table . QueryContext ) ( [ ] map [ string ] string , error ) { pods , err := t . client . CoreV1 ( ) . Pods ( " " ) . List ( metav1 . ListOptions { } ) if err != nil { log . Println ( " " ) return nil , err } rows := make ( [ ] map [ string ] string , 0 , len ( pods . Items ) ) for _ , pod := range pods . Items { for _ , container := range pod . Spec . Containers { currRow := map [ string ] string { " " : container . Name , " " : string ( pod . UID ) , " " : container . Image , " " : " " , } if container . SecurityContext != nil { if container . SecurityContext . Privileged != nil { currRow [ " " ] = utils . Bool2str ( * container . SecurityContext . Privileged ) } } rows = append ( rows , currRow ) } } return rows , nil }
Generate uses the api to retrieve information on all pods
Generate uses the api to retrieve information on all pods
// TODO: think of an efficient way to create the slice without reallocating