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

Side by Side Diff: common/tsmon/iface.go

Issue 2225933003: tsmon: read hostname and region from config file (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Fixed error in test Created 4 years, 4 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 | « common/tsmon/config_test.go ('k') | common/tsmon/iface_test.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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "net/http" 9 "net/http"
10 "net/url" 10 "net/url"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return err 92 return err
93 case mon == nil: 93 case mon == nil:
94 return nil // tsmon is disabled 94 return nil // tsmon is disabled
95 } 95 }
96 96
97 // Monitoring is enabled, so get the expensive default values for hostna me, 97 // Monitoring is enabled, so get the expensive default values for hostna me,
98 // etc. 98 // etc.
99 if config.AutoGenHostname { 99 if config.AutoGenHostname {
100 fl.Target.AutoGenHostname = true 100 fl.Target.AutoGenHostname = true
101 } 101 }
102 if config.Hostname != "" {
103 if fl.Target.DeviceHostname == "" {
104 fl.Target.DeviceHostname = config.Hostname
105 }
106 if fl.Target.TaskHostname == "" {
107 fl.Target.TaskHostname = config.Hostname
108 }
109 }
110 if config.Region != "" {
111 if fl.Target.DeviceRegion == "" {
112 fl.Target.DeviceRegion = config.Region
113 }
114 if fl.Target.TaskRegion == "" {
115 fl.Target.TaskRegion = config.Region
116 }
117 }
102 fl.Target.SetDefaultsFromHostname() 118 fl.Target.SetDefaultsFromHostname()
103 t, err := target.NewFromFlags(&fl.Target) 119 t, err := target.NewFromFlags(&fl.Target)
104 if err != nil { 120 if err != nil {
105 return err 121 return err
106 } 122 }
107 123
108 Initialize(c, mon, store.NewInMemory(t)) 124 Initialize(c, mon, store.NewInMemory(t))
109 125
110 state := GetState(c) 126 state := GetState(c)
111 if state.Flusher != nil { 127 if state.Flusher != nil {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 case "": 221 case "":
206 // Let the Authenticator choose. 222 // Let the Authenticator choose.
207 break 223 break
208 224
209 default: 225 default:
210 authOpts.Method = auth.ServiceAccountMethod 226 authOpts.Method = auth.ServiceAccountMethod
211 authOpts.ServiceAccountJSONPath = credentials 227 authOpts.ServiceAccountJSONPath = credentials
212 } 228 }
213 return auth.NewAuthenticator(ctx, auth.SilentLogin, authOpts).Client() 229 return auth.NewAuthenticator(ctx, auth.SilentLogin, authOpts).Client()
214 } 230 }
OLDNEW
« no previous file with comments | « common/tsmon/config_test.go ('k') | common/tsmon/iface_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698