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

Side by Side Diff: go/src/infra/tools/kitchen/kitchen.go

Issue 2146403002: Kitchen: Generate LogDog prefix from Swarming. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Kitchen: Generate LogDog prefix from Swarming. Created 4 years, 5 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 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 "bytes" 8 "bytes"
9 "os" 9 "os"
10 "os/signal" 10 "os/signal"
11 11
12 "github.com/maruel/subcommands" 12 "github.com/maruel/subcommands"
13 "golang.org/x/net/context" 13 "golang.org/x/net/context"
14 14
15 "github.com/luci/luci-go/common/cli" 15 "github.com/luci/luci-go/common/cli"
16 "github.com/luci/luci-go/common/environ"
16 "github.com/luci/luci-go/common/errors" 17 "github.com/luci/luci-go/common/errors"
17 log "github.com/luci/luci-go/common/logging" 18 log "github.com/luci/luci-go/common/logging"
18 "github.com/luci/luci-go/common/logging/gologger" 19 "github.com/luci/luci-go/common/logging/gologger"
19 ) 20 )
20 21
21 var application = &cli.Application{ 22 var application = &cli.Application{
22 Name: "kitchen", 23 Name: "kitchen",
23 Title: "Kitchen. It can run a recipe.", 24 Title: "Kitchen. It can run a recipe.",
24 Context: func(ctx context.Context) context.Context { 25 Context: func(ctx context.Context) context.Context {
25 ctx = gologger.StdConfig.Use(ctx) 26 ctx = gologger.StdConfig.Use(ctx)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 62
62 var buf bytes.Buffer 63 var buf bytes.Buffer
63 st := errors.RenderStack(err) 64 st := errors.RenderStack(err)
64 if _, derr := st.DumpTo(&buf); derr != nil { 65 if _, derr := st.DumpTo(&buf); derr != nil {
65 // This can't really fail, since we're rendering to a Buffer. 66 // This can't really fail, since we're rendering to a Buffer.
66 panic(derr) 67 panic(derr)
67 } 68 }
68 69
69 log.Errorf(ctx, "Annotated error stack:\n%s", buf.String()) 70 log.Errorf(ctx, "Annotated error stack:\n%s", buf.String())
70 } 71 }
72
73 // getSwarmingTaskParameters retrieves the Swarming task parameters from the
74 // environment.
75 func getSwarmingTaskParameters(env environ.Env) (host, taskID string, err error) {
76 if host, _ = env.Get("SWARMING_SERVER"); host == "" {
77 err = errors.Reason("missing or empty SWARMING_SERVER").Err()
78 return
79 }
80 if taskID, _ = env.Get("SWARMING_TASK_ID"); taskID == "" {
81 err = errors.Reason("missing SWARMING_TASK_ID").Err()
82 return
83 }
84
85 return
86 }
OLDNEW
« go/src/infra/tools/kitchen/cook.go ('K') | « go/src/infra/tools/kitchen/cook_logdog_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698