Skip to content

Commit 785b842

Browse files
committed
use CommandContext to get around linters
1 parent 236a960 commit 785b842

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/cmd/export.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,10 @@ Collecting PGO CLI logs...
595595
}
596596

597597
func gatherPluginList(clusterName string, tw *tar.Writer, cmd *cobra.Command) error {
598-
ex := exec.Command("kubectl", "plugin", "list")
598+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
599+
defer cancel() // Ensure the context is canceled to avoid leaks
600+
601+
ex := exec.CommandContext(ctx, "kubectl", "plugin", "list")
599602
msg, err := ex.Output()
600603

601604
if err != nil {
@@ -611,7 +614,10 @@ func gatherPluginList(clusterName string, tw *tar.Writer, cmd *cobra.Command) er
611614
}
612615

613616
func gatherPGUpgradeSpec(clusterName, namespace, pgUpgrade string, tw *tar.Writer, cmd *cobra.Command) error {
614-
ex := exec.Command("kubectl", "get", "pgupgrade", pgUpgrade, "-n", namespace, "-o", "yaml")
617+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
618+
defer cancel() // Ensure the context is canceled to avoid leaks
619+
620+
ex := exec.CommandContext(ctx, "kubectl", "get", "pgupgrade", pgUpgrade, "-n", namespace, "-o", "yaml")
615621
msg, err := ex.Output()
616622

617623
if err != nil {

0 commit comments

Comments
 (0)