npc: Replace isNil by reflect.IsNil
This commit is contained in:
1 parent
49224ec9f7
commit
cf3a3be8f2
3 files changed
+3
-12
No files matched your search
@@ -48,10 +48,6 @@ func (spec *ipBlockSpec) getRuleSpec(src bool) ([]string, string) {
|
|||||||
return rule, comment
|
return rule, comment
|
||||||
}
|
}
|
||||||
|
|
||||||
func (spec *ipBlockSpec) isNil() bool {
|
|
||||||
return spec == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ipBlockSet struct {
|
type ipBlockSet struct {
|
||||||
ips ipset.Interface
|
ips ipset.Interface
|
||||||
users map[string]map[types.UID]struct{}
|
users map[string]map[types.UID]struct{}
|
||||||
|
|||||||
+3
-4
@@ -2,6 +2,7 @@ package npc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@@ -16,8 +17,6 @@ type ruleHost interface {
|
|||||||
//
|
//
|
||||||
// If src=true then the rulespec is for source, otherwise - for destination.
|
// If src=true then the rulespec is for source, otherwise - for destination.
|
||||||
getRuleSpec(src bool) ([]string, string)
|
getRuleSpec(src bool) ([]string, string)
|
||||||
// TODO(brb) Get rid
|
|
||||||
isNil() bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ruleSpec struct {
|
type ruleSpec struct {
|
||||||
@@ -32,13 +31,13 @@ func newRuleSpec(policyType policyType, proto *string, srcHost, dstHost ruleHost
|
|||||||
args = append(args, "-p", *proto)
|
args = append(args, "-p", *proto)
|
||||||
}
|
}
|
||||||
srcComment := "anywhere"
|
srcComment := "anywhere"
|
||||||
if srcHost != nil && !srcHost.isNil() {
|
if srcHost != nil && !reflect.ValueOf(srcHost).IsNil() {
|
||||||
rule, comment := srcHost.getRuleSpec(true)
|
rule, comment := srcHost.getRuleSpec(true)
|
||||||
args = append(args, rule...)
|
args = append(args, rule...)
|
||||||
srcComment = comment
|
srcComment = comment
|
||||||
}
|
}
|
||||||
dstComment := "anywhere"
|
dstComment := "anywhere"
|
||||||
if dstHost != nil && !dstHost.isNil() {
|
if dstHost != nil && !reflect.ValueOf(dstHost).IsNil() {
|
||||||
rule, comment := dstHost.getRuleSpec(false)
|
rule, comment := dstHost.getRuleSpec(false)
|
||||||
args = append(args, rule...)
|
args = append(args, rule...)
|
||||||
dstComment = comment
|
dstComment = comment
|
||||||
|
|||||||
@@ -56,10 +56,6 @@ func (spec *selectorSpec) getRuleSpec(src bool) ([]string, string) {
|
|||||||
return rule, comment
|
return rule, comment
|
||||||
}
|
}
|
||||||
|
|
||||||
func (spec *selectorSpec) isNil() bool {
|
|
||||||
return spec == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type selector struct {
|
type selector struct {
|
||||||
ips ipset.Interface
|
ips ipset.Interface
|
||||||
spec *selectorSpec
|
spec *selectorSpec
|
||||||
|
|||||||
Reference in new issue
Block a user