From cf3a3be8f25c136e59748837766f1a5a0f5f531e Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Thu, 7 Jun 2018 14:20:49 +0200 Subject: [PATCH] npc: Replace isNil by reflect.IsNil --- npc/ipblock.go | 4 ---- npc/rule.go | 7 +++---- npc/selector.go | 4 ---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/npc/ipblock.go b/npc/ipblock.go index 0c5284ae..c40e46e2 100644 --- a/npc/ipblock.go +++ b/npc/ipblock.go @@ -48,10 +48,6 @@ 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{} diff --git a/npc/rule.go b/npc/rule.go index b90fd157..1edee770 100644 --- a/npc/rule.go +++ b/npc/rule.go @@ -2,6 +2,7 @@ package npc import ( "fmt" + "reflect" "strings" "k8s.io/apimachinery/pkg/types" @@ -16,8 +17,6 @@ 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 { @@ -32,13 +31,13 @@ func newRuleSpec(policyType policyType, proto *string, srcHost, dstHost ruleHost args = append(args, "-p", *proto) } srcComment := "anywhere" - if srcHost != nil && !srcHost.isNil() { + if srcHost != nil && !reflect.ValueOf(srcHost).IsNil() { rule, comment := srcHost.getRuleSpec(true) args = append(args, rule...) srcComment = comment } dstComment := "anywhere" - if dstHost != nil && !dstHost.isNil() { + if dstHost != nil && !reflect.ValueOf(dstHost).IsNil() { rule, comment := dstHost.getRuleSpec(false) args = append(args, rule...) dstComment = comment diff --git a/npc/selector.go b/npc/selector.go index 54848512..6280f26a 100644 --- a/npc/selector.go +++ b/npc/selector.go @@ -56,10 +56,6 @@ 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