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

Side by Side Diff: milo/build_source/raw_presentation/html.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 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
« no previous file with comments | « lucictx/lucictx.go ('k') | milo/build_source/swarming/build.go » ('j') | 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 raw_presentation 5 package raw_presentation
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 "strings" 9 "strings"
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 81
82 func resolveHost(host string) (string, error) { 82 func resolveHost(host string) (string, error) {
83 // Resolveour our Host, and validate it against a host whitelist. 83 // Resolveour our Host, and validate it against a host whitelist.
84 switch host { 84 switch host {
85 case "": 85 case "":
86 return defaultLogDogHost, nil 86 return defaultLogDogHost, nil
87 case defaultLogDogHost, "luci-logdog-dev.appspot.com": 87 case defaultLogDogHost, "luci-logdog-dev.appspot.com":
88 return host, nil 88 return host, nil
89 default: 89 default:
90 » » return "", errors.Reason("host %(host)q is not whitelisted"). 90 » » return "", errors.Reason("host %q is not whitelisted", host).Err ()
91 » » » D("host", host).
92 » » » Err()
93 } 91 }
94 } 92 }
95 93
96 // NewClient generates a new LogDog client that issues requests on behalf of the 94 // NewClient generates a new LogDog client that issues requests on behalf of the
97 // current user. 95 // current user.
98 func NewClient(c context.Context, host string) (*coordinator.Client, error) { 96 func NewClient(c context.Context, host string) (*coordinator.Client, error) {
99 var err error 97 var err error
100 if host, err = resolveHost(host); err != nil { 98 if host, err = resolveHost(host); err != nil {
101 return nil, err 99 return nil, err
102 } 100 }
103 101
104 // Initialize the LogDog client authentication. 102 // Initialize the LogDog client authentication.
105 t, err := auth.GetRPCTransport(c, auth.AsUser) 103 t, err := auth.GetRPCTransport(c, auth.AsUser)
106 if err != nil { 104 if err != nil {
107 return nil, errors.New("failed to get transport for LogDog serve r") 105 return nil, errors.New("failed to get transport for LogDog serve r")
108 } 106 }
109 107
110 // Setup our LogDog client. 108 // Setup our LogDog client.
111 return coordinator.NewClient(&prpc.Client{ 109 return coordinator.NewClient(&prpc.Client{
112 C: &http.Client{ 110 C: &http.Client{
113 Transport: t, 111 Transport: t,
114 }, 112 },
115 Host: host, 113 Host: host,
116 }), nil 114 }), nil
117 } 115 }
OLDNEW
« no previous file with comments | « lucictx/lucictx.go ('k') | milo/build_source/swarming/build.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698