mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
fix(spec): properly translate v0 into v1
This commit is contained in:
parent
f8be6a936f
commit
e28e7ff55b
4 changed files with 99 additions and 79 deletions
|
|
@ -19,6 +19,8 @@ import (
|
|||
"sort"
|
||||
)
|
||||
|
||||
const Version = 0
|
||||
|
||||
// JsonnetFile is the structure of a `.json` file describing a set of jsonnet
|
||||
// dependencies. It is used for both, the jsonnetFile and the lockFile.
|
||||
type JsonnetFile struct {
|
||||
|
|
|
|||
36
spec/v1/v0.go
Normal file
36
spec/v1/v0.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package spec
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
v0 "github.com/jsonnet-bundler/jsonnet-bundler/spec/v0"
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec/v1/deps"
|
||||
)
|
||||
|
||||
func FromV0(mv0 v0.JsonnetFile) (JsonnetFile, error) {
|
||||
m := New()
|
||||
m.LegacyImports = true
|
||||
|
||||
for name, old := range mv0.Dependencies {
|
||||
var d deps.Dependency
|
||||
|
||||
switch {
|
||||
case old.Source.GitSource != nil:
|
||||
d = *deps.Parse("", old.Source.GitSource.Remote)
|
||||
|
||||
subdir := filepath.Clean("/" + old.Source.GitSource.Subdir)
|
||||
d.Source.GitSource.Subdir = subdir
|
||||
|
||||
case old.Source.LocalSource != nil:
|
||||
d = *deps.Parse("", old.Source.LocalSource.Directory)
|
||||
}
|
||||
|
||||
d.Sum = old.Sum
|
||||
d.Version = old.Version
|
||||
d.LegacyNameCompat = name
|
||||
|
||||
m.Dependencies[d.Name()] = d
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue