MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / Get

Function Get

tests/utils/pods/pod.go:144–162  ·  view source on GitHub ↗

Get gets a pod by namespace and name

(
	ctx context.Context,
	crudClient client.Client,
	namespace, podName string,
)

Source from the content-addressed store, hash-verified

142
143// Get gets a pod by namespace and name
144func Get(
145 ctx context.Context,
146 crudClient client.Client,
147 namespace, podName string,
148) (*corev1.Pod, error) {
149 wrapErr := func(err error) error {
150 return fmt.Errorf("while getting pod '%s/%s': %w", namespace, podName, err)
151 }
152 podList, err := List(ctx, crudClient, namespace)
153 if err != nil {
154 return nil, wrapErr(err)
155 }
156 for _, pod := range podList.Items {
157 if podName == pod.Name {
158 return &pod, nil
159 }
160 }
161 return nil, wrapErr(errors.New("pod not found"))
162}
163
164// HasLabels verifies that the labels of a pod contain a specified
165// labels map

Callers 3

CommandInContainerFunction · 0.92
drain_node_test.goFile · 0.92
disk_space_test.goFile · 0.92

Calls 1

ListFunction · 0.70

Tested by

no test coverage detected