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

Side by Side Diff: client/cmd/kitchen/recipe.go

Issue 2055283002: kitchen: CURRENT_TIMESTAMP support (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Created 4 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
« no previous file with comments | « client/cmd/kitchen/cook.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 main 5 package main
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "io/ioutil" 9 "io/ioutil"
10 "os" 10 "os"
(...skipping 23 matching lines...) Expand all
34 type recipeRun struct { 34 type recipeRun struct {
35 repositoryPath string 35 repositoryPath string
36 36
37 // The following are command line recipes.py command line arguments. 37 // The following are command line recipes.py command line arguments.
38 38
39 recipe string 39 recipe string
40 propertiesJSON string 40 propertiesJSON string
41 propertiesFile string 41 propertiesFile string
42 outputResultJSONFile string 42 outputResultJSONFile string
43 workDir string // Where to run the recipe. 43 workDir string // Where to run the recipe.
44 timestamps bool // Whether to print CURRENT_TIMESTAMP annota tions.
44 } 45 }
45 46
46 // Command creates a exec.Cmd for running a recipe. 47 // Command creates a exec.Cmd for running a recipe.
47 func (r *recipeRun) Command() (*exec.Cmd, error) { 48 func (r *recipeRun) Command() (*exec.Cmd, error) {
48 cfgPath := filepath.Join(r.repositoryPath, "infra/config/recipes.cfg") 49 cfgPath := filepath.Join(r.repositoryPath, "infra/config/recipes.cfg")
49 cfg, err := readConfig(cfgPath) 50 cfg, err := readConfig(cfgPath)
50 if err != nil { 51 if err != nil {
51 return nil, err 52 return nil, err
52 } 53 }
53 54
54 if cfg.RecipesPath == nil || *cfg.RecipesPath == "" { 55 if cfg.RecipesPath == nil || *cfg.RecipesPath == "" {
55 return nil, fmt.Errorf("recipe_path is unspecified in %q", cfgPa th) 56 return nil, fmt.Errorf("recipe_path is unspecified in %q", cfgPa th)
56 } 57 }
57 58
58 recipesPy := path.Join(r.repositoryPath, *cfg.RecipesPath, "recipes.py") 59 recipesPy := path.Join(r.repositoryPath, *cfg.RecipesPath, "recipes.py")
59 if _, err := os.Stat(recipesPy); os.IsNotExist(err) { 60 if _, err := os.Stat(recipesPy); os.IsNotExist(err) {
60 return nil, fmt.Errorf("%q does not exist", recipesPy) 61 return nil, fmt.Errorf("%q does not exist", recipesPy)
61 } 62 }
62 63
63 cmd := exec.Command( 64 cmd := exec.Command(
64 "python", recipesPy, 65 "python", recipesPy,
65 "run", 66 "run",
66 "--properties", r.propertiesJSON, 67 "--properties", r.propertiesJSON,
67 "--properties-file", r.propertiesFile, 68 "--properties-file", r.propertiesFile,
68 "--workdir", r.workDir, 69 "--workdir", r.workDir,
69 "--output-result-json", r.outputResultJSONFile, 70 "--output-result-json", r.outputResultJSONFile,
70 r.recipe,
71 ) 71 )
72 if r.timestamps {
73 cmd.Args = append(cmd.Args, "--timestamps")
74 }
75 cmd.Args = append(cmd.Args, r.recipe)
76
72 cmd.Stdout = os.Stdout 77 cmd.Stdout = os.Stdout
73 cmd.Stderr = os.Stderr 78 cmd.Stderr = os.Stderr
74 return cmd, nil 79 return cmd, nil
75 } 80 }
OLDNEW
« no previous file with comments | « client/cmd/kitchen/cook.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698