Move name constants to separate 'chains' package, to reduce dependencies

We don't want everyone that uses the `net` package to get a transitive
dependency on the Kubernetes APIs required by `npc`.
This commit is contained in:
Bryan Boreham committed 2020-07-29 12:55:46 +00:00
1 parent 9928ddb401
commit a3c76e141b
8 files changed
+51 -43

No files matched your search

+2 -1
View File
@@ -12,6 +12,7 @@ import (
"k8s.io/client-go/kubernetes"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/common/chains"
"github.com/weaveworks/weave/net/ipset"
"github.com/weaveworks/weave/npc/iptables"
)
@@ -157,7 +158,7 @@ func (npc *controller) AddNetworkPolicy(obj interface{}) error {
}
if egressNetworkPolicy {
npc.defaultEgressDrop = true
if err := npc.ipt.Append(TableFilter, EgressChain,
if err := npc.ipt.Append(TableFilter, chains.EgressChain,
"-m", "mark", "!", "--mark", EgressMark, "-j", "DROP"); err != nil {
npc.defaultEgressDrop = false
return fmt.Errorf("Failed to add iptable rule to drop egress traffic from the pods by default due to %s", err.Error())