mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Return pointer for Affinity in api helper
This commit is contained in:
		@@ -436,15 +436,16 @@ const (
 | 
			
		||||
 | 
			
		||||
// GetAffinityFromPod gets the json serialized affinity data from Pod.Annotations
 | 
			
		||||
// and converts it to the Affinity type in api.
 | 
			
		||||
func GetAffinityFromPodAnnotations(annotations map[string]string) (Affinity, error) {
 | 
			
		||||
	var affinity Affinity
 | 
			
		||||
func GetAffinityFromPodAnnotations(annotations map[string]string) (*Affinity, error) {
 | 
			
		||||
	if len(annotations) > 0 && annotations[AffinityAnnotationKey] != "" {
 | 
			
		||||
		var affinity Affinity
 | 
			
		||||
		err := json.Unmarshal([]byte(annotations[AffinityAnnotationKey]), &affinity)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return affinity, err
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		return &affinity, nil
 | 
			
		||||
	}
 | 
			
		||||
	return affinity, nil
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
 | 
			
		||||
 
 | 
			
		||||
@@ -1863,6 +1863,9 @@ func ValidateAffinityInPodAnnotations(annotations map[string]string, fldPath *fi
 | 
			
		||||
		allErrs = append(allErrs, field.Invalid(fldPath, api.AffinityAnnotationKey, err.Error()))
 | 
			
		||||
		return allErrs
 | 
			
		||||
	}
 | 
			
		||||
	if affinity == nil {
 | 
			
		||||
		return allErrs
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	affinityFldPath := fldPath.Child(api.AffinityAnnotationKey)
 | 
			
		||||
	if affinity.NodeAffinity != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user