Skip to content

Commit f287221

Browse files
committed
🌱 Allows to redefine ETCD client logger
1 parent a8e4187 commit f287221

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

controlplane/kubeadm/etcd/alias.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package etcd
18+
19+
import (
20+
"go.uber.org/zap"
21+
22+
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/etcd"
23+
)
24+
25+
// SetLogger allows to redefine ETCD client logger.
26+
func SetLogger(logger *zap.Logger) {
27+
etcd.SetLogger(logger)
28+
}

controlplane/kubeadm/etcd/doc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package etcd implements the Kubeadm ETCD client functions.
18+
package etcd

controlplane/kubeadm/internal/etcd/etcd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"go.etcd.io/etcd/api/v3/etcdserverpb"
2727
"go.etcd.io/etcd/client/pkg/v3/logutil"
2828
clientv3 "go.etcd.io/etcd/client/v3"
29+
"go.uber.org/zap"
2930
"go.uber.org/zap/zapcore"
3031
"google.golang.org/grpc"
3132
kerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -174,6 +175,11 @@ func NewClient(ctx context.Context, config ClientConfiguration) (*Client, error)
174175
return client, nil
175176
}
176177

178+
// SetLogger allows to redefine ETCD client logger.
179+
func SetLogger(logger *zap.Logger) {
180+
etcdClientLogger = logger
181+
}
182+
177183
func newEtcdClient(ctx context.Context, etcdClient etcd, callTimeout time.Duration) (*Client, error) {
178184
endpoints := etcdClient.Endpoints()
179185
if len(endpoints) == 0 {

0 commit comments

Comments
 (0)