Return pointer for Affinity in api helper

This commit is contained in:
Wojciech Tyczynski
2016-07-22 12:48:35 +02:00
parent a63cccfafc
commit 898a6444e3
8 changed files with 36 additions and 17 deletions

View File

@@ -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