mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-26 20:19:15 +08:00
33 lines
648 B
Go
33 lines
648 B
Go
|
package service
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestDocker(t *testing.T) {
|
||
|
file, err := ioutil.ReadFile("/opt/1Panel/docker/daemon.json")
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
var conf daemonJsonItem
|
||
|
deamonMap := make(map[string]interface{})
|
||
|
if err := json.Unmarshal(file, &deamonMap); err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
arr, err := json.Marshal(deamonMap)
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
_ = json.Unmarshal(arr, &conf)
|
||
|
|
||
|
for _, opt := range conf.ExecOpts {
|
||
|
if strings.HasPrefix(opt, "native.cgroupdriver=") {
|
||
|
fmt.Println(strings.ReplaceAll(opt, "native.cgroupdriver=", ""))
|
||
|
}
|
||
|
}
|
||
|
}
|