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

Function clusterCmd

internal/cmd/plugin/report/cluster.go:30–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28)
29
30func clusterCmd() *cobra.Command {
31 var (
32 file, output string
33 includeLogs, logTimeStamp bool
34 )
35
36 const filePlaceholder = "report_cluster_<name>_<timestamp>.zip"
37 cmd := &cobra.Command{
38 Use: "cluster CLUSTER",
39 Short: "Report cluster resources, pods, events, logs (opt-in)",
40 Long: "Collects combined information on the cluster in a Zip file",
41 Args: plugin.RequiresArguments(1),
42 ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
43 return plugin.CompleteClusters(cmd.Context(), args, toComplete), cobra.ShellCompDirectiveNoFileComp
44 },
45 RunE: func(cmd *cobra.Command, args []string) error {
46 clusterName := args[0]
47 now := time.Now().UTC()
48 if file == filePlaceholder {
49 file = reportName("cluster", now, clusterName) + ".zip"
50 }
51 return cluster(cmd.Context(), clusterName, plugin.Namespace,
52 plugin.OutputFormat(output), file, includeLogs, logTimeStamp, now)
53 },
54 }
55
56 cmd.Flags().StringVarP(&file, "file", "f", filePlaceholder,
57 "Output file")
58 cmd.Flags().StringVarP(&output, "output", "o", "yaml",
59 "Output format for manifests (yaml or json)")
60 cmd.Flags().BoolVarP(&includeLogs, "logs", "l", false, "include logs")
61 cmd.Flags().BoolVarP(&logTimeStamp, "timestamps", "t", false,
62 "Prepend human-readable timestamp to each log line")
63
64 return cmd
65}

Callers 1

NewCmdFunction · 0.70

Calls 5

RequiresArgumentsFunction · 0.92
CompleteClustersFunction · 0.92
OutputFormatTypeAlias · 0.92
reportNameFunction · 0.85
clusterFunction · 0.85

Tested by

no test coverage detected