You've already forked libdetectcloud
mirror of
https://github.com/netbirdio/libdetectcloud.git
synced 2026-05-22 17:09:55 -07:00
29 lines
560 B
Go
29 lines
560 B
Go
package libdetectcloud
|
|
|
|
import "net/http"
|
|
|
|
func detectIBMCloud() string {
|
|
req, err := http.NewRequest("PUT", "http://api.metadata.cloud.ibm.com/instance_identity/v1/token", nil)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
resp, err := hc.Do(req)
|
|
if err != nil {
|
|
req, err = http.NewRequest("PUT", "https://api.metadata.cloud.ibm.com/instance_identity/v1/token", nil)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
resp, err = hc.Do(req)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
if resp.StatusCode == http.StatusOK {
|
|
return "IBM Cloud"
|
|
}
|
|
return ""
|
|
}
|