code: func addKvToConfigMap(configMap *v1.ConfigMap, keyName, data string) error {
  	// Note, the rules for ConfigMap keys are the exact same as the ones for SecretKeys.
  	if errs := validation.IsConfigMapKey(keyName); len(errs) != 0 {
  		return fmt.Errorf("%q is not a valid key name for a ConfigMap: %s", keyName, strings.Join(errs, ";"))
  	}
  
  	keyExistsErrorMsg := "cannot add key %s, another key by that name already exists: %v"
  
  	// If the configmap data contains byte sequences that are all in the UTF-8
  	// range, we will write it to .Data
  	if utf8.Valid([]byte(data)) {
  		if _, entryExists := configMap.Data[keyName]; entryExists {
  			return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.Data)
  		}
  		configMap.Data[keyName] = data
  		return nil
  	}
  
  	// otherwise, it's BinaryData
  	if configMap.BinaryData == nil {
  		configMap.BinaryData = map[string][]byte{}
  	}
  	if _, entryExists := configMap.BinaryData[keyName]; entryExists {
  		return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.BinaryData)
  	}
  	configMap.BinaryData[keyName] = []byte(data)
  	return nil
  }
docs: // addKvToConfigMap adds the given key and data to the given config map.
  // Error if key invalid, or already exists.