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

Unified Diff: vpython/application/application.go

Issue 2917093003: [vpython] Allow default spec via enviornment. (Closed)
Patch Set: Created 3 years, 7 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') | vpython/options.go » ('J')
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 0fcfcbfdb634419348e4f990ae75b560a3379ee6..0961460b411b986bb2e2ca2c3ffbb98dfcb83fb0 100644
--- a/vpython/application/application.go
+++ b/vpython/application/application.go
@@ -42,6 +42,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.
@@ -177,10 +181,19 @@ func (a *application) mainImpl(c context.Context, args []string) error {
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").
+ return errors.Annotate(err).
+ Reason("failed to load specification file (%(source)s) from: %(path)s").
D("path", a.specPath).
iannucci 2017/06/05 19:46:36 no D for source?
dnj 2017/06/06 13:40:39 oops, "source" is old.
Err()
}
+ } else if specPath := a.opts.Environ.GetEmpty(DefaultSpecENV); specPath != "" {
+ var err error
+ if a.opts.DefaultSpec, err = spec.Load(specPath); err != nil {
+ return errors.Annotate(err).
+ Reason("failed to load default specification file ("+DefaultSpecENV+"from: %(path)s").
+ D("path", specPath).
+ Err()
+ }
}
// If an empty BaseDir was specified, use a temporary directory and clean it
« no previous file with comments | « no previous file | vpython/options.go » ('j') | vpython/options.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698