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