You've already forked libdetectcloud
mirror of
https://github.com/netbirdio/libdetectcloud.git
synced 2026-05-22 17:09:55 -07:00
28 lines
372 B
Go
28 lines
372 B
Go
package libdetectcloud
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"strings"
|
|
)
|
|
|
|
func detectContainer() string {
|
|
b, err := ioutil.ReadFile("/proc/self/cgroup")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
fc := string(b)
|
|
kube := strings.Contains(fc, "kube")
|
|
container := strings.Contains(fc, "containerd")
|
|
|
|
if kube {
|
|
return "K8S Container"
|
|
}
|
|
|
|
if container {
|
|
return "Container"
|
|
}
|
|
|
|
return ""
|
|
}
|