mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
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:
parent
4b6e2d89e9
commit
6e3e7b2fdd
4 changed files with 52 additions and 17 deletions
|
|
@ -34,15 +34,15 @@ func installCommand(dir, jsonnetHome string, uris []string) int {
|
|||
}
|
||||
|
||||
kingpin.FatalIfError(
|
||||
os.MkdirAll(filepath.Join(dir, "vendor", ".tmp"), os.ModePerm),
|
||||
"creating vendor/ folder")
|
||||
os.MkdirAll(filepath.Join(dir, jsonnetHome, ".tmp"), os.ModePerm),
|
||||
"creating vendor folder")
|
||||
|
||||
jsonnetFile, err := jsonnetfile.Load(filepath.Join(dir, jsonnetfile.File))
|
||||
kingpin.FatalIfError(err, "failed to load jsonnetfile")
|
||||
|
||||
for _, u := range uris {
|
||||
d := parseDependency(dir, u)
|
||||
jsonnetFile.Dependencies = append(jsonnetFile.Dependencies, *d)
|
||||
jsonnetFile.Dependencies[d.Name] = *d
|
||||
}
|
||||
|
||||
lockFile, err := jsonnetfile.Load(filepath.Join(dir, jsonnetfile.LockFile))
|
||||
|
|
@ -50,12 +50,7 @@ func installCommand(dir, jsonnetHome string, uris []string) int {
|
|||
kingpin.FatalIfError(err, "failed to load lockfile")
|
||||
}
|
||||
|
||||
locks := make(map[string]spec.Dependency)
|
||||
for _, d := range lockFile.Dependencies {
|
||||
locks[d.Name] = d
|
||||
}
|
||||
|
||||
locked, err := pkg.Ensure(jsonnetFile, jsonnetHome, locks)
|
||||
locked, err := pkg.Ensure(jsonnetFile, jsonnetHome, lockFile.Dependencies)
|
||||
kingpin.FatalIfError(err, "failed to install packages")
|
||||
|
||||
kingpin.FatalIfError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue