Move util.StringSet into its own package

A lot of packages use StringSet, but they don't use anything else from
the util package. Moving StringSet into another package will shrink
their dependency trees significantly.
This commit is contained in:
tummychow
2015-09-09 10:45:01 -07:00
parent 1313e3b14e
commit 78ce5da988
98 changed files with 473 additions and 429 deletions

View File

@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
. "github.com/onsi/ginkgo"
@@ -41,8 +42,8 @@ const (
// getPodMatches returns a set of pod names on the given node that matches the
// podNamePrefix and namespace.
func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, namespace string) util.StringSet {
matches := util.NewStringSet()
func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, namespace string) sets.String {
matches := sets.NewString()
Logf("Checking pods on node %v via /runningpods endpoint", nodeName)
runningPods, err := GetKubeletPods(c, nodeName)
if err != nil {
@@ -65,9 +66,9 @@ func getPodMatches(c *client.Client, nodeName string, podNamePrefix string, name
// information; they are reconstructed by examining the container runtime. In
// the scope of this test, we do not expect pod naming conflicts so
// podNamePrefix should be sufficient to identify the pods.
func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, podNamePrefix string, namespace string, targetNumPods int, timeout time.Duration) error {
func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames sets.String, podNamePrefix string, namespace string, targetNumPods int, timeout time.Duration) error {
return wait.Poll(pollInterval, timeout, func() (bool, error) {
matchCh := make(chan util.StringSet, len(nodeNames))
matchCh := make(chan sets.String, len(nodeNames))
for _, item := range nodeNames.List() {
// Launch a goroutine per node to check the pods running on the nodes.
nodeName := item
@@ -76,7 +77,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
}()
}
seen := util.NewStringSet()
seen := sets.NewString()
for i := 0; i < len(nodeNames.List()); i++ {
seen = seen.Union(<-matchCh)
}
@@ -90,7 +91,7 @@ func waitTillNPodsRunningOnNodes(c *client.Client, nodeNames util.StringSet, pod
var _ = Describe("kubelet", func() {
var numNodes int
var nodeNames util.StringSet
var nodeNames sets.String
framework := NewFramework("kubelet")
var resourceMonitor *resourceMonitor
@@ -98,7 +99,7 @@ var _ = Describe("kubelet", func() {
nodes, err := framework.Client.Nodes().List(labels.Everything(), fields.Everything())
expectNoError(err)
numNodes = len(nodes.Items)
nodeNames = util.NewStringSet()
nodeNames = sets.NewString()
for _, node := range nodes.Items {
nodeNames.Insert(node.Name)
}