refactor: use a map instead of a slice

Packages are unique anyways so it makes sense to use a map to avoid having
duplicates.

For compatibility reasons custom json (un)marshallers hide this change from the
end user
This commit is contained in:
sh0rez 2019-10-16 17:36:25 +02:00
parent 4b6e2d89e9
commit 6e3e7b2fdd
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
4 changed files with 52 additions and 17 deletions

View file

@ -66,6 +66,9 @@ func Load(filepath string) (spec.JsonnetFile, error) {
if err := json.Unmarshal(bytes, &m); err != nil {
return m, errors.Wrap(err, "failed to unmarshal file")
}
if m.Dependencies == nil {
m.Dependencies = make(map[string]spec.Dependency)
}
return m, nil
}