(ctx context.Context, client kubectl.Client, namespace string, name string, containerName string, skipContainer FilterContainer, skipInit bool)
| 217 | } |
| 218 | |
| 219 | func byPodName(ctx context.Context, client kubectl.Client, namespace string, name string, containerName string, skipContainer FilterContainer, skipInit bool) ([]*SelectedPodContainer, error) { |
| 220 | if name == "" { |
| 221 | return nil, nil |
| 222 | } |
| 223 | |
| 224 | retPods := []*SelectedPodContainer{} |
| 225 | pod, err := client.KubeClient().CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{}) |
| 226 | if err != nil { |
| 227 | if kerrors.IsNotFound(err) { |
| 228 | return retPods, nil |
| 229 | } |
| 230 | |
| 231 | return nil, errors.Wrap(err, "get pod") |
| 232 | } |
| 233 | |
| 234 | if !skipInit { |
| 235 | for _, container := range pod.Spec.InitContainers { |
| 236 | if skipContainer != nil && skipContainer(pod, &container) { |
| 237 | continue |
| 238 | } |
| 239 | if containerName != "" && container.Name != containerName { |
| 240 | continue |
| 241 | } |
| 242 | |
| 243 | retContainer := container |
| 244 | retPods = append(retPods, &SelectedPodContainer{ |
| 245 | Pod: pod, |
| 246 | Container: &retContainer, |
| 247 | }) |
| 248 | } |
| 249 | } |
| 250 | for _, container := range pod.Spec.Containers { |
| 251 | if skipContainer != nil && skipContainer(pod, &container) { |
| 252 | continue |
| 253 | } |
| 254 | if containerName != "" && container.Name != containerName { |
| 255 | continue |
| 256 | } |
| 257 | |
| 258 | retContainer := container |
| 259 | retPods = append(retPods, &SelectedPodContainer{ |
| 260 | Pod: pod, |
| 261 | Container: &retContainer, |
| 262 | }) |
| 263 | } |
| 264 | |
| 265 | return retPods, nil |
| 266 | } |
| 267 | |
| 268 | func byLabelSelector(ctx context.Context, client kubectl.Client, namespace string, labelSelector string, containerName string, skipContainer FilterContainer, skipInit bool) ([]*SelectedPodContainer, error) { |
| 269 | retPods := []*SelectedPodContainer{} |
no test coverage detected