Merge pull request #1 from nikhil-prabhu/master

Add detection for Alibaba Cloud
This commit is contained in:
Tim Ski
2023-07-21 15:51:48 -04:00
committed by GitHub
2 changed files with 30 additions and 9 deletions
+13
View File
@@ -0,0 +1,13 @@
package libdetectcloud
import (
"net/http"
)
func detectAlibabaCloud() string {
resp, err := hc.Get("http://100.100.100.200/latest/")
if err == nil && resp.StatusCode == http.StatusOK {
return "Alibaba Cloud"
}
return ""
}
+17 -9
View File
@@ -11,14 +11,15 @@ var hc = &http.Client{Timeout: 300 * time.Millisecond}
// Clouds type
type Clouds struct {
Aws string
Azure string
Do string
Gce string
Ost string
Sl string
Vr string
Container string
AlibabaCloud string
Aws string
Azure string
Do string
Gce string
Ost string
Sl string
Vr string
Container string
}
// Detect function
@@ -26,7 +27,11 @@ func Detect() string {
if runtime.GOOS != "darwin" {
var c Clouds
var wg sync.WaitGroup
wg.Add(8)
wg.Add(9)
go func() {
defer wg.Done()
c.AlibabaCloud = detectAlibabaCloud()
}()
go func() {
defer wg.Done()
c.Aws = detectAWS()
@@ -61,6 +66,9 @@ func Detect() string {
}()
wg.Wait()
if c.AlibabaCloud != "" {
return c.AlibabaCloud
}
if c.Aws != "" {
return c.Aws
}