Dump logs the JSON for the deployment in an operator namespace, its pods and endpoints
(ctx context.Context, crudClient client.Client, namespace, filename string)
| 70 | |
| 71 | // Dump logs the JSON for the deployment in an operator namespace, its pods and endpoints |
| 72 | func Dump(ctx context.Context, crudClient client.Client, namespace, filename string) { |
| 73 | f, err := os.Create(filepath.Clean(filename)) |
| 74 | if err != nil { |
| 75 | fmt.Println(err) |
| 76 | return |
| 77 | } |
| 78 | w := bufio.NewWriter(f) |
| 79 | |
| 80 | deployment, _ := GetDeployment(ctx, crudClient) |
| 81 | out, _ := json.MarshalIndent(deployment, "", " ") |
| 82 | _, _ = fmt.Fprintf(w, "Dumping %v/%v deployment\n", namespace, deployment.Name) |
| 83 | _, _ = fmt.Fprintln(w, string(out)) |
| 84 | |
| 85 | podList, _ := pods.List(ctx, crudClient, namespace) |
| 86 | for _, pod := range podList.Items { |
| 87 | out, _ := json.MarshalIndent(pod, "", " ") |
| 88 | _, _ = fmt.Fprintf(w, "Dumping %v/%v pod\n", namespace, pod.Name) |
| 89 | _, _ = fmt.Fprintln(w, string(out)) |
| 90 | } |
| 91 | |
| 92 | err = w.Flush() |
| 93 | if err != nil { |
| 94 | fmt.Println(err) |
| 95 | return |
| 96 | } |
| 97 | _ = f.Sync() |
| 98 | _ = f.Close() |
| 99 | } |
| 100 | |
| 101 | // GetDeployment returns the operator Deployment if there is a single one running, error otherwise |
| 102 | func GetDeployment(ctx context.Context, crudClient client.Client) (appsv1.Deployment, error) { |
no test coverage detected