func writeLock(conf, confcopy *cfg.Config, base string) { hash, err := conf.Hash() if err != nil { msg.Die("Failed to generate config hash. Unable to generate lock file.") } lock := cfg.NewLockfile(confcopy.Imports, hash) if err := lock.WriteFile(filepath.Join(base, gpath.LockFile)); err != nil { msg.Die("Failed to write glide lock file: %s", err) } }
// LoadLockfile loads the contents of a glide.lock file. // // TODO: This should go in another package. func LoadLockfile(base string, conf *cfg.Config) (*cfg.Lockfile, error) { yml, err := ioutil.ReadFile(filepath.Join(base, gpath.LockFile)) if err != nil { return nil, err } lock, err := cfg.LockfileFromYaml(yml) if err != nil { return nil, err } hash, err := conf.Hash() if err != nil { return nil, err } if hash != lock.Hash { msg.Warn("Lock file may be out of date. Hash check of YAML failed. You may need to run 'update'") } return lock, nil }