...
1 package cmd
2
3 import (
4 "fmt"
5 "strings"
6 "time"
7
8 pkgCmd "github.com/linkerd/linkerd2/pkg/cmd"
9 "github.com/linkerd/linkerd2/pkg/flags"
10 "github.com/linkerd/linkerd2/pkg/healthcheck"
11 "github.com/linkerd/linkerd2/pkg/k8s"
12 "github.com/spf13/cobra"
13 "helm.sh/helm/v3/pkg/cli/values"
14 )
15
16 func newCmdPrune() *cobra.Command {
17 var cniEnabled bool
18 var wait time.Duration
19 var options values.Options
20
21 cmd := &cobra.Command{
22 Use: "prune [flags]",
23 Args: cobra.NoArgs,
24 Short: "Output extraneous Kubernetes resources in the linkerd-jaeger extension",
25 Long: `Output extraneous Kubernetes resources in the linkerd-jaeger extension.`,
26 Example: ` # Prune extraneous resources.
27 linkerd jaeger prune | kubectl delete -f -
28 `,
29 RunE: func(cmd *cobra.Command, _ []string) error {
30 hc := healthcheck.NewWithCoreChecks(&healthcheck.Options{
31 ControlPlaneNamespace: controlPlaneNamespace,
32 KubeConfig: kubeconfigPath,
33 KubeContext: kubeContext,
34 Impersonate: impersonate,
35 ImpersonateGroup: impersonateGroup,
36 APIAddr: apiAddr,
37 RetryDeadline: time.Now().Add(wait),
38 })
39 hc.RunWithExitOnError()
40 cniEnabled = hc.CNIEnabled
41
42 manifests := strings.Builder{}
43
44 err := install(&manifests, options, "", cniEnabled)
45 if err != nil {
46 return err
47 }
48
49 label := fmt.Sprintf("%s=%s", k8s.LinkerdExtensionLabel, JaegerExtensionName)
50 return pkgCmd.Prune(cmd.Context(), hc.KubeAPIClient(), manifests.String(), label)
51 },
52 }
53
54 cmd.Flags().DurationVar(&wait, "wait", 300*time.Second, "Wait for extension components to be available")
55
56 flags.AddValueOptionsFlags(cmd.Flags(), &options)
57
58 return cmd
59 }
60
View as plain text