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

Function Dump

tests/utils/operator/operator.go:72–99  ·  view source on GitHub ↗

Dump logs the JSON for the deployment in an operator namespace, its pods and endpoints

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

Source from the content-addressed store, hash-verified

70
71// Dump logs the JSON for the deployment in an operator namespace, its pods and endpoints
72func 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
102func GetDeployment(ctx context.Context, crudClient client.Client) (appsv1.Deployment, error) {

Callers 1

upgrade_test.goFile · 0.92

Calls 4

ListFunction · 0.92
GetDeploymentFunction · 0.85
CreateMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected