Skip to content

Commit 59f1302

Browse files
committed
Add the client-go debug round tripper to the venafi client
Signed-off-by: Richard Wall <[email protected]>
1 parent 2e85bbf commit 59f1302

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

hack/e2e/values.venafi-kubernetes-agent.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ authentication:
99
enabled: true
1010

1111
extraArgs:
12-
- --logging-format=text
13-
# Show trace logs for the venafi-connection-lib client
14-
# See https://github.com/jetstack/venafi-connection-lib/blob/13c2342fe0140ff084d2aabfd29ae3d10721691b/internal/http_client/metrics_transport.go#L93-L115
15-
- --vmodule=metrics_transport=6
12+
- --logging-format=json

pkg/client/client_api_token.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/jetstack/preflight/api"
14+
"k8s.io/client-go/transport"
1415
)
1516

1617
type (
@@ -30,12 +31,15 @@ func NewAPITokenClient(agentMetadata *api.AgentMetadata, apiToken, baseURL strin
3031
if baseURL == "" {
3132
return nil, fmt.Errorf("cannot create APITokenClient: baseURL cannot be empty")
3233
}
33-
34+
httpClient := &http.Client{
35+
Timeout: time.Minute,
36+
Transport: transport.DebugWrappers(http.DefaultTransport),
37+
}
3438
return &APITokenClient{
3539
apiToken: apiToken,
3640
agentMetadata: agentMetadata,
3741
baseURL: baseURL,
38-
client: &http.Client{Timeout: time.Minute},
42+
client: httpClient,
3943
}, nil
4044
}
4145

pkg/client/client_oauth.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/hashicorp/go-multierror"
1616
"github.com/pkg/errors"
17+
"k8s.io/client-go/transport"
1718

1819
"github.com/jetstack/preflight/api"
1920
)
@@ -94,7 +95,10 @@ func NewOAuthClient(agentMetadata *api.AgentMetadata, credentials *OAuthCredenti
9495
credentials: credentials,
9596
baseURL: baseURL,
9697
accessToken: &accessToken{},
97-
client: &http.Client{Timeout: time.Minute},
98+
client: &http.Client{
99+
Timeout: time.Minute,
100+
Transport: transport.DebugWrappers(http.DefaultTransport),
101+
},
98102
}, nil
99103
}
100104

pkg/client/client_venafi_cloud.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/google/uuid"
2828
"github.com/hashicorp/go-multierror"
2929
"github.com/microcosm-cc/bluemonday"
30+
"k8s.io/client-go/transport"
3031

3132
"github.com/jetstack/preflight/api"
3233
)
@@ -112,7 +113,10 @@ func NewVenafiCloudClient(agentMetadata *api.AgentMetadata, credentials *VenafiS
112113
credentials: credentials,
113114
baseURL: baseURL,
114115
accessToken: &venafiCloudAccessToken{},
115-
Client: &http.Client{Timeout: time.Minute},
116+
Client: &http.Client{
117+
Timeout: time.Minute,
118+
Transport: transport.DebugWrappers(http.DefaultTransport),
119+
},
116120
uploaderID: uploaderID,
117121
uploadPath: uploadPath,
118122
privateKey: privateKey,

pkg/client/client_venconn.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"k8s.io/apimachinery/pkg/runtime"
2020
"k8s.io/apimachinery/pkg/types"
2121
"k8s.io/client-go/rest"
22+
"k8s.io/client-go/transport"
2223
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
2324

2425
"github.com/jetstack/preflight/api"
@@ -99,11 +100,11 @@ func NewVenConnClient(restcfg *rest.Config, agentMetadata *api.AgentMetadata, in
99100
}
100101

101102
vcpClient := &http.Client{}
103+
tr := http.DefaultTransport.(*http.Transport).Clone()
102104
if trustedCAs != nil {
103-
tr := http.DefaultTransport.(*http.Transport).Clone()
104105
tr.TLSClientConfig.RootCAs = trustedCAs
105-
vcpClient.Transport = tr
106106
}
107+
vcpClient.Transport = transport.DebugWrappers(tr)
107108

108109
return &VenConnClient{
109110
agentMetadata: agentMetadata,

0 commit comments

Comments
 (0)