Files
odo/pkg/kclient/configmap.go
Philippe Martin 7a721348b3 Automount volumes (#6698)
* Simplify AddOdoProjectVolume and AddOdoMandatoryVolume

* Rename / Clarify HandleEphemeralStorage function

* Regroup volume-specific code

* Move volume specific code to a separated function

* Add a new module configAutomount

* Automount PVC (without options)

* Add unit tests

* Separate functions

* Mount secrets

* Mount configmaps

* Specific mount path

* MountAs annotation

* Mounting cm/secret as env

* Refacto: use inAllContainers + replace result with volume

* Mounting cm/secret as subpath

* Read-only

* Integration tests

* Rename label

* Automount during odo deploy Exec command

* Add documentation

* Fix TODO

* Review

* Fix indentation

* Rename labels/annotations
2023-04-18 07:58:45 -04:00

27 lines
639 B
Go

package kclient
import (
"context"
"fmt"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ListConfigMaps lists all the configmaps based on the given label selector
func (c *Client) ListConfigMaps(labelSelector string) ([]corev1.ConfigMap, error) {
listOptions := metav1.ListOptions{}
if len(labelSelector) > 0 {
listOptions = metav1.ListOptions{
LabelSelector: labelSelector,
}
}
cmList, err := c.KubeClient.CoreV1().ConfigMaps(c.Namespace).List(context.TODO(), listOptions)
if err != nil {
return nil, fmt.Errorf("unable to get configmap list: %w", err)
}
return cmList.Items, nil
}