k8s.io/client-go

Go client for Kubernetes.

Add tracer middleware to Config literals

Join Point
Struct literal rest.Config
  • Pointer or Value
Advice
Replace the expression using the template:
// Using the following synthetic imports:
import (
	kubernetestrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/k8s.io/client-go/kubernetes"
	kubernetestransport "k8s.io/client-go/transport"
)
{{- .AST.Type -}}{
	{{- $hasField := false -}}
	{{ range .AST.Elts }}
	{{- if eq .Key.Name "WrapTransport" }}
	{{- $hasField = true -}}
	WrapTransport: kubernetestransport.Wrappers({{ .Value }}, kubernetestrace.WrapRoundTripper),
	{{- else -}}
	{{ . }},
	{{ end -}}
	{{ end }}
	{{- if not $hasField -}}
	WrapTransport: kubernetestransport.Wrappers(nil, kubernetestrace.WrapRoundTripper),
	{{- end }}
}