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

Unified Diff: vpython/options.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
« vpython/application/application.go ('K') | « vpython/application/application.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/options.go
diff --git a/vpython/options.go b/vpython/options.go
index f24b3ff69f074305fef4d86ac515e30154b9ae90..dd026afd111fb80573941dce786f42adab7dba7e 100644
--- a/vpython/options.go
+++ b/vpython/options.go
@@ -26,6 +26,10 @@ type Options struct {
// EnvConfig is the VirtualEnv configuration to run from.
EnvConfig venv.Config
+ // DefaultSpec is the default specification to use, if no specification was
+ // supplied or probed.
+ DefaultSpec *vpython.Spec
+
// SpecLoader is the spec.Loader to use to load a specification file for a
// given script.
//
@@ -154,6 +158,12 @@ func (o *Options) ResolveSpec(c context.Context) error {
return nil
}
+ // If standard resolution doesn't yield a spec, fall back on our default spec.
+ if o.DefaultSpec != nil {
+ o.EnvConfig.Spec = o.DefaultSpec
iannucci 2017/06/05 19:46:36 would it make sense to have this be by-value, then
dnj 2017/06/06 13:40:39 Yeah I suppose it would. Done.
+ return nil
+ }
+
// Unable to load a spec.
logging.Infof(c, "Unable to resolve specification path. Using empty specification.")
o.EnvConfig.Spec = &vpython.Spec{}
« vpython/application/application.go ('K') | « vpython/application/application.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698