From 2a52976983aa9e86c22c77f2047860fa1caa5c3f Mon Sep 17 00:00:00 2001 From: harry Date: Tue, 5 Jan 2016 15:31:20 +0800 Subject: [PATCH] Use hashutil to hold hash tools --- pkg/api/endpoints/util.go | 6 +++--- pkg/kubelet/config/common.go | 4 ++-- pkg/kubelet/container/helpers.go | 4 ++-- pkg/kubelet/dockertools/docker_test.go | 4 ++-- pkg/util/deployment/deployment.go | 4 ++-- pkg/util/{ => hash}/hash.go | 2 +- pkg/util/{ => hash}/hash_test.go | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) rename pkg/util/{ => hash}/hash.go (98%) rename pkg/util/{ => hash}/hash_test.go (99%) diff --git a/pkg/api/endpoints/util.go b/pkg/api/endpoints/util.go index bf9e0b2d3e1..91bc57166de 100644 --- a/pkg/api/endpoints/util.go +++ b/pkg/api/endpoints/util.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/types" - "k8s.io/kubernetes/pkg/util" + hashutil "k8s.io/kubernetes/pkg/util/hash" ) // RepackSubsets takes a slice of EndpointSubset objects, expands it to the full @@ -138,7 +138,7 @@ func hashAddresses(addrs addressSet) string { } sort.Sort(addrsReady(slice)) hasher := md5.New() - util.DeepHashObject(hasher, slice) + hashutil.DeepHashObject(hasher, slice) return hex.EncodeToString(hasher.Sum(nil)[0:]) } @@ -191,7 +191,7 @@ func SortSubsets(subsets []api.EndpointSubset) []api.EndpointSubset { } func hashObject(hasher hash.Hash, obj interface{}) []byte { - util.DeepHashObject(hasher, obj) + hashutil.DeepHashObject(hasher, obj) return hasher.Sum(nil) } diff --git a/pkg/kubelet/config/common.go b/pkg/kubelet/config/common.go index 0033642ce80..28aad3e0ebd 100644 --- a/pkg/kubelet/config/common.go +++ b/pkg/kubelet/config/common.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/api/validation" kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/types" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/hash" utilyaml "k8s.io/kubernetes/pkg/util/yaml" "github.com/golang/glog" @@ -47,7 +47,7 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName string) er } else { fmt.Fprintf(hasher, "url:%s", source) } - util.DeepHashObject(hasher, pod) + hash.DeepHashObject(hasher, pod) pod.UID = types.UID(hex.EncodeToString(hasher.Sum(nil)[0:])) glog.V(5).Infof("Generated UID %q pod %q from %s", pod.UID, pod.Name, source) } diff --git a/pkg/kubelet/container/helpers.go b/pkg/kubelet/container/helpers.go index bd6314d47ab..3f43363d272 100644 --- a/pkg/kubelet/container/helpers.go +++ b/pkg/kubelet/container/helpers.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/kubelet/util/format" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + hashutil "k8s.io/kubernetes/pkg/util/hash" "k8s.io/kubernetes/third_party/golang/expansion" "github.com/golang/glog" @@ -127,7 +127,7 @@ func ConvertPodStatusToRunningPod(podStatus *PodStatus) Pod { // the running container with its desired spec. func HashContainer(container *api.Container) uint64 { hash := adler32.New() - util.DeepHashObject(hash, *container) + hashutil.DeepHashObject(hash, *container) return uint64(hash.Sum32()) } diff --git a/pkg/kubelet/dockertools/docker_test.go b/pkg/kubelet/dockertools/docker_test.go index cbee46899b9..afaabbc521a 100644 --- a/pkg/kubelet/dockertools/docker_test.go +++ b/pkg/kubelet/dockertools/docker_test.go @@ -36,7 +36,7 @@ import ( "k8s.io/kubernetes/pkg/kubelet/network" kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/types" - "k8s.io/kubernetes/pkg/util" + hashutil "k8s.io/kubernetes/pkg/util/hash" "k8s.io/kubernetes/pkg/util/parsers" ) @@ -116,7 +116,7 @@ func TestGetContainerID(t *testing.T) { func verifyPackUnpack(t *testing.T, podNamespace, podUID, podName, containerName string) { container := &api.Container{Name: containerName} hasher := adler32.New() - util.DeepHashObject(hasher, *container) + hashutil.DeepHashObject(hasher, *container) computedHash := uint64(hasher.Sum32()) podFullName := fmt.Sprintf("%s_%s", podName, podNamespace) _, name := BuildDockerName(KubeletContainerName{podFullName, types.UID(podUID), container.Name}, container) diff --git a/pkg/util/deployment/deployment.go b/pkg/util/deployment/deployment.go index 5885339ea51..5919d72b0b5 100644 --- a/pkg/util/deployment/deployment.go +++ b/pkg/util/deployment/deployment.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" client "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/util" + hashutil "k8s.io/kubernetes/pkg/util/hash" ) // GetOldRCs returns the old RCs targeted by the given Deployment; get PodList and RCList from client interface. @@ -141,7 +141,7 @@ func CloneAndAddLabel(labels map[string]string, labelKey string, labelValue uint func GetPodTemplateSpecHash(template api.PodTemplateSpec) uint32 { podTemplateSpecHasher := adler32.New() - util.DeepHashObject(podTemplateSpecHasher, template) + hashutil.DeepHashObject(podTemplateSpecHasher, template) return podTemplateSpecHasher.Sum32() } diff --git a/pkg/util/hash.go b/pkg/util/hash/hash.go similarity index 98% rename from pkg/util/hash.go rename to pkg/util/hash/hash.go index 53834c05ea5..95fd32abe7d 100644 --- a/pkg/util/hash.go +++ b/pkg/util/hash/hash.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package hash import ( "hash" diff --git a/pkg/util/hash_test.go b/pkg/util/hash/hash_test.go similarity index 99% rename from pkg/util/hash_test.go rename to pkg/util/hash/hash_test.go index ac6edd23bfe..3bba3b074ba 100644 --- a/pkg/util/hash_test.go +++ b/pkg/util/hash/hash_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package hash import ( "fmt"