From 43e20081070a440c603661155b143ef2bef4962f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=88=9A=20=20=28=E6=88=90=E9=83=BD=29?= Date: Tue, 14 Feb 2023 00:41:51 +0800 Subject: [PATCH] code clean for if condtion (#1037) Signed-off-by: yanggang --- cmd/multus-shim/main.go | 2 +- cmd/multus/main.go | 2 +- pkg/k8sclient/k8sclient.go | 4 ++-- pkg/multus/multus.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/multus-shim/main.go b/cmd/multus-shim/main.go index 606622d95..c3c34dc0c 100644 --- a/cmd/multus-shim/main.go +++ b/cmd/multus-shim/main.go @@ -39,7 +39,7 @@ func main() { flag.BoolVar(&versionOpt, "v", false, "Show application version") flag.Parse() - if versionOpt == true { + if versionOpt { fmt.Printf("multus-shim: %s\n", multus.PrintVersionString()) return } diff --git a/cmd/multus/main.go b/cmd/multus/main.go index ce8cbdfa3..34ce4b3fa 100644 --- a/cmd/multus/main.go +++ b/cmd/multus/main.go @@ -38,7 +38,7 @@ func main() { flag.BoolVar(&versionOpt, "version", false, "Show application version") flag.BoolVar(&versionOpt, "v", false, "Show application version") flag.Parse() - if versionOpt == true { + if versionOpt { fmt.Printf("multus: %s\n", multus.PrintVersionString()) return } diff --git a/pkg/k8sclient/k8sclient.go b/pkg/k8sclient/k8sclient.go index 776f801d2..7e797a25e 100644 --- a/pkg/k8sclient/k8sclient.go +++ b/pkg/k8sclient/k8sclient.go @@ -372,7 +372,7 @@ func TryLoadPodDelegates(pod *v1.Pod, conf *types.NetConf, clientInfo *ClientInf } } - if isGatewayConfigured == true { + if isGatewayConfigured { err = types.CheckGatewayConfig(conf.Delegates) if err != nil { return 0, nil, err @@ -680,7 +680,7 @@ const ConfigSourceAnnotationKey = "kubernetes.io/config.source" // IsStaticPod returns true if the pod is static pod. func IsStaticPod(pod *v1.Pod) bool { if pod.Annotations != nil { - if source, ok := pod.Annotations[ConfigSourceAnnotationKey]; ok == true { + if source, ok := pod.Annotations[ConfigSourceAnnotationKey]; ok { return source != "api" } } diff --git a/pkg/multus/multus.go b/pkg/multus/multus.go index 4389049ed..584144d51 100644 --- a/pkg/multus/multus.go +++ b/pkg/multus/multus.go @@ -875,7 +875,7 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er // set CNIVersion in delegate CNI config if there is no CNIVersion and multus conf have CNIVersion. for _, v := range in.Delegates { - if v.ConfListPlugin == true && v.ConfList.CNIVersion == "" && in.CNIVersion != "" { + if v.ConfListPlugin && v.ConfList.CNIVersion == "" && in.CNIVersion != "" { v.ConfList.CNIVersion = in.CNIVersion v.Bytes, err = json.Marshal(v.ConfList) if err != nil {