feat(spec): version field (#85)

Adds a `version` field to the `jsonnetfile.json`, so that `jb` can automatically recognize too old / too new schema versions, instead of panicking.
This commit is contained in:
Matthias Loibl 2020-02-28 17:41:49 +01:00 committed by GitHub
parent efe0c9e864
commit bcd89fd33d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 454 additions and 102 deletions

View file

@ -22,12 +22,12 @@ import (
"reflect"
"github.com/pkg/errors"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/jsonnet-bundler/jsonnet-bundler/pkg"
"github.com/jsonnet-bundler/jsonnet-bundler/pkg/jsonnetfile"
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
"github.com/jsonnet-bundler/jsonnet-bundler/spec/deps"
v1 "github.com/jsonnet-bundler/jsonnet-bundler/spec/v1"
"github.com/jsonnet-bundler/jsonnet-bundler/spec/v1/deps"
)
func installCommand(dir, jsonnetHome string, uris []string) int {
@ -78,7 +78,7 @@ func installCommand(dir, jsonnetHome string, uris []string) int {
"updating jsonnetfile.json")
kingpin.FatalIfError(
writeChangedJsonnetFile(jblockfilebytes, &spec.JsonnetFile{Dependencies: locked}, filepath.Join(dir, jsonnetfile.LockFile)),
writeChangedJsonnetFile(jblockfilebytes, &v1.JsonnetFile{Dependencies: locked}, filepath.Join(dir, jsonnetfile.LockFile)),
"updating jsonnetfile.lock.json")
return 0
@ -102,7 +102,7 @@ func writeJSONFile(name string, d interface{}) error {
return ioutil.WriteFile(name, b, 0644)
}
func writeChangedJsonnetFile(originalBytes []byte, modified *spec.JsonnetFile, path string) error {
func writeChangedJsonnetFile(originalBytes []byte, modified *v1.JsonnetFile, path string) error {
origJsonnetFile, err := jsonnetfile.Unmarshal(originalBytes)
if err != nil {
return err