Skip to content

Commit 8331edd

Browse files
committed
style: extract cert variable and break long panic line
1 parent 925713a commit 8331edd

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

internal/pod/container_kubelet_sync.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ func ManagerInit(ctx *ManagerInitCtx) error {
166166
}
167167

168168
s := strings.Split(ctx.PodClientCertPath, ",")
169+
cert := strings.TrimSpace(s[0])
169170
if len(s) == 1 {
170-
ctx.podClientCertPath, ctx.podClientCertKey = strings.TrimSpace(s[0]), strings.TrimSpace(s[0])
171+
ctx.podClientCertPath, ctx.podClientCertKey = cert, cert
171172
} else if len(s) >= 2 {
172-
ctx.podClientCertPath, ctx.podClientCertKey = strings.TrimSpace(s[0]), strings.TrimSpace(s[1])
173+
ctx.podClientCertPath, ctx.podClientCertKey = cert, strings.TrimSpace(s[1])
173174
}
174175

175176
err := kubeletPodListPortCacheUpdate(ctx)
@@ -524,7 +525,10 @@ func kubeletConfigCacheUpdate(ctx *ManagerInitCtx) error {
524525

525526
config, err = kubeletConfigFileDefault()
526527
if err != nil {
527-
panic(fmt.Sprintf("we cannot find any cgroup driver of kubelet after requesting configz and default files: %v", err))
528+
panic(fmt.Sprintf(
529+
"we cannot find any cgroup driver of kubelet after requesting configz and default files: %v",
530+
err,
531+
))
528532
}
529533

530534
return nil

0 commit comments

Comments
 (0)