Remove the dependency of 'ipset' package on Kubernetes
We don't want everyone that uses the `net` package to get a transitive dependency on the Kubernetes APIs, so have it define the `UID` type. Conceptually this is a simple change because `UID` is a `string`, but unfortunately it is used in a lot of places.
This commit is contained in:
1 parent
a3c76e141b
commit
ca4f93d0d7
8 files changed
+103
-100
No files matched your search
+10
-2
@@ -63,7 +63,7 @@ func (npc *controller) onNewNsSelector(selector *selector) error {
|
||||
for _, ns := range npc.nss {
|
||||
if ns.namespace != nil {
|
||||
if selector.matchesNamespaceSelector(ns.namespace.ObjectMeta.Labels) {
|
||||
if err := selector.addEntry(ns.namespace.ObjectMeta.UID, string(ns.allPods.ipsetName), namespaceComment(ns)); err != nil {
|
||||
if err := selector.addEntry(nsuid(ns.namespace), string(ns.allPods.ipsetName), namespaceComment(ns)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (npc *controller) onNewNamespacePodsSelector(selector *selector) error {
|
||||
for _, pod := range ns.pods {
|
||||
if hasIP(pod) {
|
||||
if selector.matchesNamespacedPodSelector(pod.ObjectMeta.Labels, ns.namespace.ObjectMeta.Labels) {
|
||||
if err := selector.addEntry(pod.ObjectMeta.UID, pod.Status.PodIP, podComment(pod)); err != nil {
|
||||
if err := selector.addEntry(uid(pod), pod.Status.PodIP, podComment(pod)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -263,3 +263,11 @@ func isEgressNetworkPolicy(obj interface{}) (bool, error) {
|
||||
}
|
||||
return false, errInvalidNetworkPolicyObjType
|
||||
}
|
||||
|
||||
func uid(pod *coreapi.Pod) ipset.UID {
|
||||
return ipset.UID(pod.UID)
|
||||
}
|
||||
|
||||
func nsuid(ns *coreapi.Namespace) ipset.UID {
|
||||
return ipset.UID(ns.UID)
|
||||
}
|
||||
Reference in new issue
Block a user