mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
Make use of File and LockFile constants of jsonnetfile package
This commit is contained in:
parent
9d10f90924
commit
30a3cde870
2 changed files with 10 additions and 12 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
"regexp"
|
||||
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/pkg"
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/pkg/jsonnetfile"
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
|
|
@ -218,9 +219,7 @@ func parseGithubDependency(urlString string) *spec.Dependency {
|
|||
}
|
||||
|
||||
func updateCommand(jsonnetHome string, urls ...*url.URL) int {
|
||||
jsonnetfile := pkg.JsonnetFile
|
||||
|
||||
m, err := pkg.LoadJsonnetfile(jsonnetfile)
|
||||
m, err := pkg.LoadJsonnetfile(jsonnetfile.File)
|
||||
if err != nil {
|
||||
kingpin.Fatalf("failed to load jsonnetfile: %v", err)
|
||||
return 1
|
||||
|
|
@ -234,7 +233,7 @@ func updateCommand(jsonnetHome string, urls ...*url.URL) int {
|
|||
|
||||
// When updating, the lockfile is explicitly ignored.
|
||||
isLock := false
|
||||
lock, err := pkg.Install(context.TODO(), isLock, jsonnetfile, m, jsonnetHome)
|
||||
lock, err := pkg.Install(context.TODO(), isLock, jsonnetfile.File, m, jsonnetHome)
|
||||
if err != nil {
|
||||
kingpin.Fatalf("failed to install: %v", err)
|
||||
return 3
|
||||
|
|
@ -247,7 +246,7 @@ func updateCommand(jsonnetHome string, urls ...*url.URL) int {
|
|||
}
|
||||
b = append(b, []byte("\n")...)
|
||||
|
||||
err = ioutil.WriteFile(pkg.JsonnetLockFile, b, 0644)
|
||||
err = ioutil.WriteFile(jsonnetfile.LockFile, b, 0644)
|
||||
if err != nil {
|
||||
kingpin.Fatalf("failed to write lock file: %v", err)
|
||||
return 3
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/pkg/jsonnetfile"
|
||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
JsonnetFile = "jsonnetfile.json"
|
||||
JsonnetLockFile = "jsonnetfile.lock.json"
|
||||
VersionMismatch = errors.New("multiple colliding versions specified")
|
||||
)
|
||||
|
||||
|
|
@ -161,18 +160,18 @@ func FileExists(path string) (bool, error) {
|
|||
}
|
||||
|
||||
func ChooseJsonnetFile(dir string) (string, bool, error) {
|
||||
lockfile := path.Join(dir, JsonnetLockFile)
|
||||
jsonnetfile := path.Join(dir, JsonnetFile)
|
||||
filename := lockfile
|
||||
lockfilePath := path.Join(dir, jsonnetfile.LockFile)
|
||||
jsonnetfilePath := path.Join(dir, jsonnetfile.File)
|
||||
filename := lockfilePath
|
||||
isLock := true
|
||||
|
||||
lockExists, err := FileExists(filepath.Join(dir, JsonnetLockFile))
|
||||
lockExists, err := FileExists(filepath.Join(dir, jsonnetfile.LockFile))
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
if !lockExists {
|
||||
filename = jsonnetfile
|
||||
filename = jsonnetfilePath
|
||||
isLock = false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue