github.com/Rookout/GoSDK@v0.1.48/pkg/information/platform.go (about)

     1  package information
     2  
     3  import (
     4  	pb "github.com/Rookout/GoSDK/pkg/protobuf"
     5  	"io/ioutil"
     6  	"os"
     7  	"runtime"
     8  )
     9  
    10  func collectPlatform(info *AgentInformation) error {
    11  	platformInfo := &pb.PlatformInformation{
    12  		Platform: "golang",
    13  		Version:  runtime.Version(),
    14  		Variant:  "golang",
    15  	}
    16  	info.Platform = platformInfo
    17  	return nil
    18  }
    19  
    20  func collectK8sNamespace(information *AgentInformation) error {
    21  	defaultK8sNamespaceFile := "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
    22  
    23  	if information.K8sNamespaceFileName == "" {
    24  		information.K8sNamespaceFileName = defaultK8sNamespaceFile
    25  	}
    26  
    27  	if namespace, err := ioutil.ReadFile(information.K8sNamespaceFileName); err == nil {
    28  		information.K8sNamespace = string(namespace)
    29  	} else if !os.IsNotExist(err) {
    30  		return err
    31  	}
    32  
    33  	return nil
    34  }