OLD | NEW |
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 application | 5 package application |
6 | 6 |
7 import ( | 7 import ( |
8 "strings" | 8 "strings" |
9 | 9 |
10 "github.com/maruel/subcommands" | 10 "github.com/maruel/subcommands" |
(...skipping 22 matching lines...) Expand all Loading... |
33 subcommands.CommandRunBase | 33 subcommands.CommandRunBase |
34 } | 34 } |
35 | 35 |
36 func (cr *verifyCommandRun) Run(app subcommands.Application, args []string, env
subcommands.Env) int { | 36 func (cr *verifyCommandRun) Run(app subcommands.Application, args []string, env
subcommands.Env) int { |
37 c := cli.GetContext(app, cr, env) | 37 c := cli.GetContext(app, cr, env) |
38 a := getApplication(c, args) | 38 a := getApplication(c, args) |
39 | 39 |
40 return run(c, func(c context.Context) error { | 40 return run(c, func(c context.Context) error { |
41 // Make sure that we can resolve the referenced specifiction. | 41 // Make sure that we can resolve the referenced specifiction. |
42 if err := a.opts.ResolveSpec(c); err != nil { | 42 if err := a.opts.ResolveSpec(c); err != nil { |
43 » » » return errors.Annotate(err).Reason("failed to resolve sp
ecification").Err() | 43 » » » return errors.Annotate(err, "failed to resolve specifica
tion").Err() |
44 } | 44 } |
45 | 45 |
46 s := a.opts.EnvConfig.Spec | 46 s := a.opts.EnvConfig.Spec |
47 if s == nil { | 47 if s == nil { |
48 s = &vpython.Spec{} | 48 s = &vpython.Spec{} |
49 } | 49 } |
50 if s.Virtualenv == nil { | 50 if s.Virtualenv == nil { |
51 s.Virtualenv = &a.opts.EnvConfig.Package | 51 s.Virtualenv = &a.opts.EnvConfig.Package |
52 } | 52 } |
53 | 53 |
54 // Verify that the spec can be normalized. This may modify it, s
o we will | 54 // Verify that the spec can be normalized. This may modify it, s
o we will |
55 // normalize a clone. | 55 // normalize a clone. |
56 if err := spec.NormalizeSpec(s.Clone(), nil); err != nil { | 56 if err := spec.NormalizeSpec(s.Clone(), nil); err != nil { |
57 » » » return errors.Annotate(err).Reason("failed to normalize
specification").Err() | 57 » » » return errors.Annotate(err, "failed to normalize specifi
cation").Err() |
58 } | 58 } |
59 | 59 |
60 renderedSpec := spec.Render(s) | 60 renderedSpec := spec.Render(s) |
61 logging.Infof(c, "Successfully verified specification:\n%s", ren
deredSpec) | 61 logging.Infof(c, "Successfully verified specification:\n%s", ren
deredSpec) |
62 | 62 |
63 // Run our Verification generator and verify each generated envi
ronment. | 63 // Run our Verification generator and verify each generated envi
ronment. |
64 if a.WithVerificationConfig != nil { | 64 if a.WithVerificationConfig != nil { |
65 err := a.WithVerificationConfig(c, func(cfg Config, veri
ficationScenarios []*vpython.PEP425Tag) error { | 65 err := a.WithVerificationConfig(c, func(cfg Config, veri
ficationScenarios []*vpython.PEP425Tag) error { |
66 if len(s.VerifyPep425Tag) > 0 { | 66 if len(s.VerifyPep425Tag) > 0 { |
67 verificationScenarios = s.VerifyPep425Ta
g | 67 verificationScenarios = s.VerifyPep425Ta
g |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return nil | 99 return nil |
100 }) | 100 }) |
101 if err != nil { | 101 if err != nil { |
102 return err | 102 return err |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 return nil | 106 return nil |
107 }) | 107 }) |
108 } | 108 } |
OLD | NEW |