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

Function clusterCmd

internal/cmd/plugin/logs/cluster.go:28–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26)
27
28func clusterCmd() *cobra.Command {
29 cl := clusterLogs{}
30
31 cmd := &cobra.Command{
32 Use: "cluster CLUSTER",
33 Short: "Logs for cluster's pods",
34 Long: "Collects the logs for all pods in a cluster into a single stream or outputFile",
35 Args: plugin.RequiresArguments(1),
36 ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
37 return plugin.CompleteClusters(cmd.Context(), args, toComplete), cobra.ShellCompDirectiveNoFileComp
38 },
39 RunE: func(cmd *cobra.Command, args []string) error {
40 cl.clusterName = args[0]
41 cl.namespace = plugin.Namespace
42 cl.ctx = cmd.Context()
43 cl.client = plugin.ClientInterface
44 if cl.follow {
45 return followCluster(cl)
46 }
47 return saveClusterLogs(cl)
48 },
49 }
50
51 cmd.Flags().StringVarP(&cl.outputFile, "output", "o", "",
52 "Output outputFile")
53 cmd.Flags().BoolVarP(&cl.timestamp, "timestamps", "t", false,
54 "Prepend human-readable timestamp to each log line. If set, logs start from current time")
55 cmd.Flags().Int64Var(&cl.tailLines, "tail", -1,
56 "Number of lines from the end of the logs to show for each pod. By default there is no limit")
57 cmd.Flags().BoolVarP(&cl.follow, "follow", "f", false,
58 "Follow cluster logs (watches for new and re-created pods)")
59
60 return cmd
61}

Callers 2

NewCmdFunction · 0.70
cluster_test.goFile · 0.70

Calls 4

RequiresArgumentsFunction · 0.92
CompleteClustersFunction · 0.92
followClusterFunction · 0.85
saveClusterLogsFunction · 0.85

Tested by

no test coverage detected