add hostip protocol to the hostport predicates and make unit test adapt to the code change

This commit is contained in:
chenxingyu
2017-09-07 17:12:22 +08:00
parent 687c8d3297
commit 2d44ef9dfa
9 changed files with 267 additions and 74 deletions

View File

@@ -17,6 +17,8 @@ limitations under the License.
package predicates
import (
"strings"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
@@ -89,3 +91,24 @@ func GetEquivalencePod(pod *v1.Pod) interface{} {
type EquivalencePod struct {
ControllerRef metav1.OwnerReference
}
type hostPortInfo struct {
protocol string
hostIP string
hostPort string
}
// decode a string ("protocol/hostIP/hostPort") to *hostPortInfo object
func decode(info string) *hostPortInfo {
hostPortInfoSlice := strings.Split(info, "/")
protocol := hostPortInfoSlice[0]
hostIP := hostPortInfoSlice[1]
hostPort := hostPortInfoSlice[2]
return &hostPortInfo{
protocol: protocol,
hostIP: hostIP,
hostPort: hostPort,
}
}