Optimize the judgment mode to remove redundant transformations (#9588)

Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
Fish-pro 2023-02-16 21:59:39 +08:00 committed by GitHub
parent 00086ab429
commit fbdbc24a42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 9 deletions

View file

@ -26,11 +26,11 @@ import (
// if an object contains invalid configurations that may represent a security risk, // if an object contains invalid configurations that may represent a security risk,
// and returning an error in this case // and returning an error in this case
func DeepInspect(obj interface{}) error { func DeepInspect(obj interface{}) error {
switch obj.(type) { switch obj := obj.(type) {
case *networking.Ingress: case *networking.Ingress:
return InspectIngress(obj.(*networking.Ingress)) return InspectIngress(obj)
case *corev1.Service: case *corev1.Service:
return InspectService(obj.(*corev1.Service)) return InspectService(obj)
default: default:
klog.Warningf("received invalid object to inspect: %T", obj) klog.Warningf("received invalid object to inspect: %T", obj)
return nil return nil

View file

@ -165,7 +165,7 @@ func downloadDatabase(dbName string) error {
mmdbFile := dbName + dbExtension mmdbFile := dbName + dbExtension
tarReader := tar.NewReader(archive) tarReader := tar.NewReader(archive)
for true { for {
header, err := tarReader.Next() header, err := tarReader.Next()
if err == io.EOF { if err == io.EOF {
break break

View file

@ -76,11 +76,7 @@ func (c1 *Configuration) Equal(c2 *Configuration) bool {
} }
} }
if c1.BackendConfigChecksum != c2.BackendConfigChecksum { return c1.BackendConfigChecksum == c2.BackendConfigChecksum
return false
}
return true
} }
// Equal tests for equality between two Backend types // Equal tests for equality between two Backend types