Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Unified Diff: vpython/application/application.go

Issue 2917093003: [vpython] Allow default spec via enviornment. (Closed)
Patch Set: spec load Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | vpython/options.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/application/application.go
diff --git a/vpython/application/application.go b/vpython/application/application.go
index fcd178319f5be311d8c910efd320842f6851ae99..5cd6f168dfbcc5027e3b7824083aa87f0c36a2eb 100644
--- a/vpython/application/application.go
+++ b/vpython/application/application.go
@@ -43,6 +43,10 @@ const (
// Like "-root", if this value is present but empty, a tempdir will be used
// for the VirtualEnv root.
VirtualEnvRootENV = "VPYTHON_VIRTUALENV_ROOT"
+
+ // DefaultSpecENV is an enviornment variable that, if set, will be used as the
+ // default VirtualEnv spec file if none is provided or found through probing.
+ DefaultSpecENV = "VPYTHON_DEFAULT_SPEC"
)
// ReturnCodeError is an error wrapping a return code value.
@@ -199,10 +203,16 @@ func (a *application) mainImpl(c context.Context, argv0 string, args []string) e
// If an spec path was manually specified, load and use it.
if a.specPath != "" {
- var err error
- if a.opts.EnvConfig.Spec, err = spec.Load(a.specPath); err != nil {
- return errors.Annotate(err).Reason("failed to load specification file (-spec) from: %(path)s").
- D("path", a.specPath).
+ var sp vpythonAPI.Spec
+ if err := spec.Load(a.specPath, &sp); err != nil {
+ return err
+ }
+ a.opts.EnvConfig.Spec = &sp
+ } else if specPath := a.opts.Environ.GetEmpty(DefaultSpecENV); specPath != "" {
+ if err := spec.Load(specPath, &a.opts.DefaultSpec); err != nil {
+ return errors.Annotate(err).
+ Reason("failed to load default specification file ("+DefaultSpecENV+"from: %(path)s").
+ D("path", specPath).
Err()
}
}
« no previous file with comments | « no previous file | vpython/options.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698