code: func encodeManagedFields(managedFields fieldpath.ManagedFields) (encodedManagedFields []metav1.ManagedFieldsEntry, err error) {
  	// Sort the keys so a predictable order will be used.
  	managers := []string{}
  	for manager := range managedFields {
  		managers = append(managers, manager)
  	}
  	sort.Strings(managers)
  
  	encodedManagedFields = []metav1.ManagedFieldsEntry{}
  	for _, manager := range managers {
  		versionedSet := managedFields[manager]
  		v, err := encodeManagerVersionedSet(manager, versionedSet)
  		if err != nil {
  			return nil, fmt.Errorf("error encoding versioned set for %v: %v", manager, err)
  		}
  		encodedManagedFields = append(encodedManagedFields, *v)
  	}
  	return sortEncodedManagedFields(encodedManagedFields)
  }
docs: // encodeManagedFields converts ManagedFields from the the format used by
  // sigs.k8s.io/structured-merge-diff to the the wire format (api format)