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

Side by Side Diff: vpython/options.go

Issue 2917093003: [vpython] Allow default spec via enviornment. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package vpython 5 package vpython
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 9
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
11 11
12 "github.com/luci/luci-go/vpython/api/vpython" 12 "github.com/luci/luci-go/vpython/api/vpython"
13 "github.com/luci/luci-go/vpython/python" 13 "github.com/luci/luci-go/vpython/python"
14 "github.com/luci/luci-go/vpython/spec" 14 "github.com/luci/luci-go/vpython/spec"
15 "github.com/luci/luci-go/vpython/venv" 15 "github.com/luci/luci-go/vpython/venv"
16 16
17 "github.com/luci/luci-go/common/errors" 17 "github.com/luci/luci-go/common/errors"
18 "github.com/luci/luci-go/common/logging" 18 "github.com/luci/luci-go/common/logging"
19 "github.com/luci/luci-go/common/system/environ" 19 "github.com/luci/luci-go/common/system/environ"
20 "github.com/luci/luci-go/common/system/filesystem" 20 "github.com/luci/luci-go/common/system/filesystem"
21 ) 21 )
22 22
23 // Options is the set of options to use to construct and execute a VirtualEnv 23 // Options is the set of options to use to construct and execute a VirtualEnv
24 // Python application. 24 // Python application.
25 type Options struct { 25 type Options struct {
26 // EnvConfig is the VirtualEnv configuration to run from. 26 // EnvConfig is the VirtualEnv configuration to run from.
27 EnvConfig venv.Config 27 EnvConfig venv.Config
28 28
29 // DefaultSpec is the default specification to use, if no specification was
30 // supplied or probed.
31 DefaultSpec *vpython.Spec
32
29 // SpecLoader is the spec.Loader to use to load a specification file for a 33 // SpecLoader is the spec.Loader to use to load a specification file for a
30 // given script. 34 // given script.
31 // 35 //
32 // The empty value is a valid default spec.Loader. 36 // The empty value is a valid default spec.Loader.
33 SpecLoader spec.Loader 37 SpecLoader spec.Loader
34 38
35 // Args are the arguments to forward to the Python process. 39 // Args are the arguments to forward to the Python process.
36 Args []string 40 Args []string
37 41
38 // WaitForEnv, if true, means that if another agent holds a lock on the target 42 // WaitForEnv, if true, means that if another agent holds a lock on the target
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if v, ok := o.Environ.Get(EnvironmentStampPathENV); ok { 151 if v, ok := o.Environ.Get(EnvironmentStampPathENV); ok {
148 if o.EnvConfig.Spec, err = spec.Load(v); err != nil { 152 if o.EnvConfig.Spec, err = spec.Load(v); err != nil {
149 return errors.Annotate(err).Reason("failed to load envir onment-supplied spec from: %(path)s"). 153 return errors.Annotate(err).Reason("failed to load envir onment-supplied spec from: %(path)s").
150 D("path", v). 154 D("path", v).
151 Err() 155 Err()
152 } 156 }
153 logging.Infof(c, "Loaded spec from environment: %s", v) 157 logging.Infof(c, "Loaded spec from environment: %s", v)
154 return nil 158 return nil
155 } 159 }
156 160
161 // If standard resolution doesn't yield a spec, fall back on our default spec.
162 if o.DefaultSpec != nil {
163 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.
164 return nil
165 }
166
157 // Unable to load a spec. 167 // Unable to load a spec.
158 logging.Infof(c, "Unable to resolve specification path. Using empty spec ification.") 168 logging.Infof(c, "Unable to resolve specification path. Using empty spec ification.")
159 o.EnvConfig.Spec = &vpython.Spec{} 169 o.EnvConfig.Spec = &vpython.Spec{}
160 return nil 170 return nil
161 } 171 }
OLDNEW
« 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