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

Unified Diff: vpython/options.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 | « vpython/application/application.go ('k') | vpython/spec/load.go » ('j') | 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..8d7e9535b22587b2ad491cbb6e3c48d26bc78a29 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.
//
@@ -145,17 +149,20 @@ func (o *Options) ResolveSpec(c context.Context) error {
// Do we have a spec file in the environment?
if v, ok := o.Environ.Get(EnvironmentStampPathENV); ok {
- if o.EnvConfig.Spec, err = spec.Load(v); err != nil {
+ var sp vpython.Spec
+ if err := spec.Load(v, &sp); err != nil {
return errors.Annotate(err).Reason("failed to load environment-supplied spec from: %(path)s").
D("path", v).
Err()
}
+
logging.Infof(c, "Loaded spec from environment: %s", v)
+ o.EnvConfig.Spec = &sp
return nil
}
- // Unable to load a spec.
- logging.Infof(c, "Unable to resolve specification path. Using empty specification.")
- o.EnvConfig.Spec = &vpython.Spec{}
+ // If standard resolution doesn't yield a spec, fall back on our default spec.
+ logging.Infof(c, "Unable to resolve specification path. Using default specification.")
+ o.EnvConfig.Spec = &o.DefaultSpec
return nil
}
« no previous file with comments | « vpython/application/application.go ('k') | vpython/spec/load.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698