2020-11-20 16:52:42 -05:00
|
|
|
# libdetectcloud
|
2019-02-26 21:46:56 +00:00
|
|
|
|
2020-11-20 16:52:42 -05:00
|
|
|
http.Client timeout is set to `300ms`. Sometimes hitting the metadata service to fast will return empty instead of the cloud provider detected.
|
2019-02-26 17:03:16 -05:00
|
|
|
|
2020-11-20 16:54:09 -05:00
|
|
|
```go
|
2019-02-26 17:03:16 -05:00
|
|
|
package main
|
2020-11-20 16:52:42 -05:00
|
|
|
|
2019-02-26 17:03:16 -05:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"gitlab.com/taskfitio/lib/detectcloud"
|
|
|
|
|
)
|
2020-11-20 16:52:42 -05:00
|
|
|
|
2019-02-26 17:03:16 -05:00
|
|
|
func main() {
|
2020-11-20 16:52:42 -05:00
|
|
|
|
|
|
|
|
// detectcloud.Detect() will return an empty string or
|
|
|
|
|
// Amazon Web Services, Microsoft Azure, Digital Ocean
|
|
|
|
|
// Google Compute Engine, OpenStack, SoftLayer, Vultr
|
|
|
|
|
// K8S Container, Container
|
2019-02-26 17:03:16 -05:00
|
|
|
|
|
|
|
|
fmt.Println(detectcloud.Detect())
|
2020-11-20 16:52:42 -05:00
|
|
|
|
2019-02-26 17:03:16 -05:00
|
|
|
}
|
2020-11-20 16:54:09 -05:00
|
|
|
```
|