MCPcopy Index your code
hub / github.com/cloudfoundry/cli / UnmarshalYAML

Method UnmarshalYAML

util/manifestparser/application.go:63–97  ·  view source on GitHub ↗
(unmarshal func(v interface{}) error)

Source from the content-addressed store, hash-verified

61}
62
63func (application *Application) UnmarshalYAML(unmarshal func(v interface{}) error) error {
64 // This prevents infinite recursion. The alias type does not implement the unmarshaller interface
65 // so by casting application to a alias pointer, it will unmarshal into the same memory without calling
66 // UnmarshalYAML on itself infinite times
67 type Alias Application
68 aliasPntr := (*Alias)(application)
69
70 err := unmarshal(aliasPntr)
71 if err != nil {
72 return err
73 }
74
75 err = unmarshal(&application.RemainingManifestFields)
76 if err != nil {
77 return err
78 }
79
80 value := reflect.ValueOf(*application)
81 removeDuplicateMapKeys(value, application.RemainingManifestFields)
82 // old style was `disk_quota` (underscore not hyphen)
83 // we maintain backwards-compatibility by supporting both flavors
84 if application.RemainingManifestFields["disk_quota"] != nil {
85 if application.DiskQuota != "" {
86 return errors.New("cannot define both `disk_quota` and `disk-quota`")
87 }
88 diskQuota, ok := application.RemainingManifestFields["disk_quota"].(string)
89 if !ok {
90 return errors.New("`disk_quota` must be a string")
91 }
92 application.DiskQuota = diskQuota
93 delete(application.RemainingManifestFields, "disk_quota")
94 }
95
96 return nil
97}

Callers

nothing calls this directly

Calls 1

removeDuplicateMapKeysFunction · 0.85

Tested by

no test coverage detected