Get gets a pod by namespace and name
( ctx context.Context, crudClient client.Client, namespace, podName string, )
| 142 | |
| 143 | // Get gets a pod by namespace and name |
| 144 | func 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 |
no test coverage detected