@@ -22,6 +22,7 @@ import (
2222 "fmt"
2323 "io"
2424 "os"
25+ "os/exec"
2526 "strings"
2627 "text/tabwriter"
2728 "time"
@@ -232,6 +233,7 @@ kubectl pgo support export daisy --monitoring-namespace another-namespace --outp
232233| The support export tool will collect information that is
233234| commonly necessary for troubleshooting a PostgresCluster.
234235| Note: No data or k8s secrets are collected.
236+ | However, kubectl is used to list plugins on the user's machine.
235237└────────────────────────────────────────────────────────────────
236238Collecting PGO CLI version...
237239Collecting names and namespaces for PostgresClusters...
@@ -262,6 +264,7 @@ Collecting Patroni info...
262264Collecting pgBackRest info...
263265Collecting processes...
264266Collecting system times from containers...
267+ Collecting list of kubectl plugins...
265268Collecting PGO CLI logs...
266269┌────────────────────────────────────────────────────────────────
267270| Archive file size: 0.02 MiB
@@ -449,6 +452,11 @@ Collecting PGO CLI logs...
449452 err = gatherSystemTime (ctx , clientset , restConfig , namespace , clusterName , tw , cmd )
450453 }
451454
455+ if err == nil {
456+ writeInfo (cmd , "Collecting list of kubectl plugins..." )
457+ err = gatherPluginList (clusterName , tw , cmd )
458+ }
459+
452460 // Print cli output
453461 writeInfo (cmd , "Collecting PGO CLI logs..." )
454462 path := clusterName + "/logs/cli"
@@ -471,6 +479,22 @@ Collecting PGO CLI logs...
471479 return cmd
472480}
473481
482+ func gatherPluginList (clusterName string , tw * tar.Writer , cmd * cobra.Command ) error {
483+ ex := exec .Command ("kubectl" , "plugin" , "list" )
484+ msg , err := ex .Output ()
485+
486+ if err != nil {
487+ // Capture error message when kubectl is not found in $PATH.
488+ msg = append (msg , err .Error ()... )
489+ }
490+ path := clusterName + "/plugin-list"
491+ if err := writeTar (tw , msg , path , cmd ); err != nil {
492+ return err
493+ }
494+
495+ return nil
496+ }
497+
474498// exportSizeReport defines the message displayed when a support export archive
475499// is created. If the size of the archive file is greater than 25MiB, an alternate
476500// message is displayed.
0 commit comments