(t testing.TB)
| 63 | } |
| 64 | |
| 65 | func metadataClient(t testing.TB) *metadata.Client { |
| 66 | // When not running in Google Cloud, the default metadata client will |
| 67 | // leak a goroutine. |
| 68 | // |
| 69 | // We use a very short timeout because the metadata server should be |
| 70 | // within the same datacenter as the cloud instance. |
| 71 | tp := http.DefaultTransport.(*http.Transport).Clone() |
| 72 | httpClient := &http.Client{ |
| 73 | Timeout: time.Second * 3, |
| 74 | Transport: tp, |
| 75 | } |
| 76 | client := metadata.NewClient(httpClient) |
| 77 | t.Cleanup(httpClient.CloseIdleConnections) |
| 78 | return client |
| 79 | } |
no test coverage detected