CommandInContainer executes commands in a given instance pod, in the postgres container
( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, container ContainerLocator, timeout *time.Duration, command ...string, )
| 47 | // CommandInContainer executes commands in a given instance pod, in the |
| 48 | // postgres container |
| 49 | func CommandInContainer( |
| 50 | ctx context.Context, |
| 51 | crudClient client.Client, |
| 52 | kubeInterface kubernetes.Interface, |
| 53 | restConfig *rest.Config, |
| 54 | container ContainerLocator, |
| 55 | timeout *time.Duration, |
| 56 | command ...string, |
| 57 | ) (string, string, error) { |
| 58 | wrapErr := func(err error) error { |
| 59 | return fmt.Errorf("while executing command in pod '%s/%s': %w", |
| 60 | container.Namespace, container.PodName, err) |
| 61 | } |
| 62 | pod, err := pods.Get(ctx, crudClient, container.Namespace, container.PodName) |
| 63 | if err != nil { |
| 64 | return "", "", wrapErr(err) |
| 65 | } |
| 66 | if !pkgutils.IsPodReady(*pod) { |
| 67 | return "", "", fmt.Errorf("pod not ready. Namespace: %v, Name: %v", pod.Namespace, pod.Name) |
| 68 | } |
| 69 | return Command(ctx, kubeInterface, restConfig, *pod, container.ContainerName, timeout, command...) |
| 70 | } |
| 71 | |
| 72 | // PodLocator contains the necessary data to find a pod |
| 73 | type PodLocator struct { |
no test coverage detected