Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hashutil to hold hash tools #19331

Merged
merged 1 commit into from
Jan 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/api/endpoints/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:])
}

Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/container/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/dockertools/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/hash.go → pkg/util/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package hash

import (
"hash"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/hash_test.go → pkg/util/hash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package hash

import (
"fmt"
Expand Down