// ConfigMapHash returns a hash of the ConfigMap. // The Data, Kind, and Name are taken into account. func ConfigMapHash(cm *v1.ConfigMap) (string, error) { … } // SecretHash returns a hash of the Secret. // The Data, Kind, Name, and Type are taken into account. func SecretHash(sec *v1.Secret) (string, error) { … } // encodeConfigMap encodes a ConfigMap. // Data, Kind, and Name are taken into account. func encodeConfigMap(cm *v1.ConfigMap) (string, error) { … } // encodeSecret encodes a Secret. // Data, Kind, Name, and Type are taken into account. func encodeSecret(sec *v1.Secret) (string, error) { … } // encodeHash extracts the first 40 bits of the hash from the hex string // (1 hex char represents 4 bits), and then maps vowels and vowel-like hex // characters to consonants to prevent bad words from being formed (the theory // is that no vowels makes it really hard to make bad words). Since the string // is hex, the only vowels it can contain are 'a' and 'e'. // We picked some arbitrary consonants to map to from the same character set as GenerateName. // See: https://github.com/kubernetes/apimachinery/blob/dc1f89aff9a7509782bde3b68824c8043a3e58cc/pkg/util/rand/rand.go#L75 // If the hex string contains fewer than ten characters, returns an error. func encodeHash(hex string) (string, error) { … } // hash hashes `data` with sha256 and returns the hex string func hash(data string) string { … }