Skip to content

Commit

Permalink
Migrate client-go/rest to contextual logging
Browse files Browse the repository at this point in the history
Signed-off-by: WillardHu <wei.hu@daocloud.io>
  • Loading branch information
WillardHu committed Jan 19, 2024
1 parent 2624e93 commit 0a8481b
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 136 deletions.
6 changes: 2 additions & 4 deletions staging/src/k8s.io/client-go/rest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"k8s.io/client-go/transport"
certutil "k8s.io/client-go/util/cert"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/klog/v2"
)

const (
Expand Down Expand Up @@ -526,10 +525,9 @@ func InClusterConfig() (*Config, error) {
tlsClientConfig := TLSClientConfig{}

if _, err := certutil.NewPool(rootCAFile); err != nil {
klog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err)
} else {
tlsClientConfig.CAFile = rootCAFile
return nil, err
}
tlsClientConfig.CAFile = rootCAFile

return &Config{
// TODO: switch to using cluster DNS.
Expand Down
6 changes: 5 additions & 1 deletion staging/src/k8s.io/client-go/rest/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ var fakeWrapperFunc = func(http.RoundTripper) http.RoundTripper {

type fakeWarningHandler struct{}

func (f fakeWarningHandler) HandleWarningHeader(code int, agent string, message string) {}
func (f fakeWarningHandler) HandleWarningHeader(code int, agent string, message string) {
}

func (f fakeWarningHandler) HandleWarningHeaderWithContext(ctx context.Context, code int, agent string, message string) {
}

type fakeNegotiatedSerializer struct{}

Expand Down
6 changes: 3 additions & 3 deletions staging/src/k8s.io/client-go/rest/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"net/http"
"sync"

"k8s.io/klog/v2"

clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/klog/v2"
)

type AuthProvider interface {
Expand Down Expand Up @@ -65,7 +64,8 @@ func RegisterAuthProviderPlugin(name string, plugin Factory) error {
if _, found := plugins[name]; found {
return fmt.Errorf("auth Provider Plugin %q was registered twice", name)
}
klog.V(4).Infof("Registered Auth Provider Plugin %q", name)
//nolint:logchck // For development and debugging only
klog.Background().V(4).Info("Registered Auth Provider Plugin", "plugin-name", name)
plugins[name] = plugin
return nil
}
Expand Down

0 comments on commit 0a8481b

Please sign in to comment.