Merge pull request #19331 from resouer/hash-util
Auto commit by PR queue bot
This commit is contained in:
		@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
package hash
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"hash"
 | 
			
		||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
package hash
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
		Reference in New Issue
	
	Block a user