func ChecksumForConfigMap(cm *v1.ConfigMap) string {
	hash := sha256.New()

	// Since maps are not ordered we need to make sure we order them somehow so we'll always get the same checksums
	// for the same config maps. The solution here is to extract the keys into a slice and sort them.
	// Then iterate over that slice to fetch the values to be hashed.
	keys := []string{}
	for key := range cm.Data {
		keys = append(keys, key)
	}
	sort.Strings(keys)

	for _, key := range keys {
		hash.Write([]byte(cm.Data[key]))
	}

	// Do the same as above, but for binaryData this time.
	keys = []string{}
	for key := range cm.BinaryData {
		keys = append(keys, key)
	}
	sort.Strings(keys)

	for _, key := range keys {
		hash.Write(cm.BinaryData[key])
	}

	return fmt.Sprintf("sha256:%x", hash.Sum(nil))
}
// ChecksumForConfigMap calculates a checksum for the supplied config map. The exact algorithm depends on hash and prefix parameters
ChecksumForConfigMap calculates a checksum for the supplied config map. The exact algorithm depends on hash and prefix parameters
// ChecksumForConfigMap calculates a checksum for the supplied config map . The exact algorithm depends on hash and prefix parameters
func ChecksumForConfigMap(cm *v1.ConfigMap) string {
	hash := sha256.New()
	keys := []string{}
	for key := range cm.Data {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	for _, key := range keys {
		hash.Write([]byte(cm.Data[key]))
	}
	keys = []string{}
	for key := range cm.BinaryData {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	for _, key := range keys {
		hash.Write(cm.BinaryData[key])
	}
	return fmt.Sprintf("sha256:%x", hash.Sum(nil))
}
func ChecksumForConfigMap ( cm * v1 . ConfigMap ) string { hash := sha256 . New ( ) keys := [ ] string { } for key := range cm . Data { keys = append ( keys , key ) } sort . Strings ( keys ) for _ , key := range keys { hash . Write ( [ ] byte ( cm . Data [ key ] ) ) } keys = [ ] string { } for key := range cm . BinaryData { keys = append ( keys , key ) } sort . Strings ( keys ) for _ , key := range keys { hash . Write ( cm . BinaryData [ key ] ) } return fmt . Sprintf ( " " , hash . Sum ( nil ) ) }
ChecksumForConfigMap calculates a checksum for the supplied config map.
ChecksumForConfigMap calculates a checksum for the supplied config map .
// Since maps are not ordered we need to make sure we order them somehow so we'll always get the same checksums // for the same config maps. The solution here is to extract the keys into a slice and sort them. // Then iterate over that slice to fetch the values to be hashed. // Do the same as above, but for binaryData this time.