| OLD | NEW |
| 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 remote | 5 package remote |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/base64" | 8 "encoding/base64" |
| 9 "fmt" | 9 "fmt" |
| 10 "net/http" | 10 "net/http" |
| 11 "net/url" | 11 "net/url" |
| 12 | 12 |
| 13 "golang.org/x/net/context" | 13 "golang.org/x/net/context" |
| 14 "google.golang.org/api/googleapi" | 14 "google.golang.org/api/googleapi" |
| 15 | 15 |
| 16 configApi "github.com/luci/luci-go/common/api/luci_config/config/v1" | 16 configApi "github.com/luci/luci-go/common/api/luci_config/config/v1" |
| 17 "github.com/luci/luci-go/common/config" | 17 "github.com/luci/luci-go/common/config" |
| 18 "github.com/luci/luci-go/common/errors" | |
| 19 "github.com/luci/luci-go/common/logging" | 18 "github.com/luci/luci-go/common/logging" |
| 19 "github.com/luci/luci-go/common/retry" |
| 20 ) | 20 ) |
| 21 | 21 |
| 22 // ClientFactory returns HTTP client to use (given a context). | 22 // ClientFactory returns HTTP client to use (given a context). |
| 23 // | 23 // |
| 24 // See 'New' for more details. | 24 // See 'New' for more details. |
| 25 type ClientFactory func(context.Context) (*http.Client, error) | 25 type ClientFactory func(context.Context) (*http.Client, error) |
| 26 | 26 |
| 27 // New returns an implementation of the config service which talks to the actual | 27 // New returns an implementation of the config service which talks to the actual |
| 28 // luci-config service using given transport. | 28 // luci-config service using given transport. |
| 29 // | 29 // |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // apiErr converts googleapi.Error to an appropriate type. | 286 // apiErr converts googleapi.Error to an appropriate type. |
| 287 func apiErr(e error) error { | 287 func apiErr(e error) error { |
| 288 err, ok := e.(*googleapi.Error) | 288 err, ok := e.(*googleapi.Error) |
| 289 if !ok { | 289 if !ok { |
| 290 return e | 290 return e |
| 291 } | 291 } |
| 292 if err.Code == 404 { | 292 if err.Code == 404 { |
| 293 return config.ErrNoConfig | 293 return config.ErrNoConfig |
| 294 } | 294 } |
| 295 if err.Code >= 500 { | 295 if err.Code >= 500 { |
| 296 » » return errors.WrapTransient(err) | 296 » » return retry.Tag.Apply(err) |
| 297 } | 297 } |
| 298 return err | 298 return err |
| 299 } | 299 } |
| OLD | NEW |