func hashAddresses(addrs addressSet) string { // Flatten the list of addresses into a string so it can be used as a // map key. Unfortunately, DeepHashObject is implemented in terms of // spew, and spew does not handle non-primitive map keys well. So // first we collapse it into a slice, sort the slice, then hash that. slice := make([]addrReady, 0, len(addrs)) for k, ready := range addrs { slice = append(slice, addrReady{k, ready}) } sort.Sort(addrsReady(slice)) hasher := md5.New() hashutil.DeepHashObject(hasher, slice) return hex.EncodeToString(hasher.Sum(nil)[0:]) }
func hashObject(hasher hash.Hash, obj interface{}) []byte { hashutil.DeepHashObject(hasher, obj) return hasher.Sum(nil) }
func GetPodTemplateSpecHash(template api.PodTemplateSpec) uint32 { podTemplateSpecHasher := adler32.New() hashutil.DeepHashObject(podTemplateSpecHasher, template) return podTemplateSpecHasher.Sum32() }