From c5baf1f284da1e5fa00ab9ca618e11ea7f829bbb Mon Sep 17 00:00:00 2001 From: BenTheElder Date: Thu, 11 Jun 2015 15:10:59 -0400 Subject: [PATCH] Export GetIptablesVersion utility in util/iptables For kube-proxy to determine whether to use pure iptables as in https://github.com/GoogleCloudPlatform/kubernetes/issues/3760 Related WIP PR: https://github.com/GoogleCloudPlatform/kubernetes/pull/9210 --- pkg/util/iptables/iptables.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/util/iptables/iptables.go b/pkg/util/iptables/iptables.go index b3da523c0f5..abf3fbb4750 100644 --- a/pkg/util/iptables/iptables.go +++ b/pkg/util/iptables/iptables.go @@ -343,6 +343,16 @@ func getIptablesVersionString(exec utilexec.Interface) (string, error) { return string(bytes), nil } +// GetIptablesVersion returns the major minor and patch version of iptables +// which will all be zero in case of error, and any error encountered. +func GetIptablesVersion(exec utilexec.Interface) (int, int, int, error) { + s, err := getIptablesVersionString(exec) + if err != nil { + return 0, 0, 0, err + } + return extractIptablesVersion(s) +} + // Checks if an iptables version is after 1.4.11, when --check was added func iptablesHasCheckCommand(v1 int, v2 int, v3 int) bool { if v1 > 1 {