Match-id-1e87107c3e24b4d20298eaa1b6a44ff3faa8e550

This commit is contained in:
BianTanggui
2022-07-04 17:45:13 +08:00
parent 5885984358
commit fb6ad111b5
3 changed files with 6 additions and 8 deletions

View File

@@ -108,7 +108,7 @@ func process() error {
return writeJson(destFilePath, writeContent)
}
func createJsonString(srcFilePath, runtimeFilePath, action string) ([]byte, error) {
func createJSONString(srcFilePath, runtimeFilePath, action string) ([]byte, error) {
var writeContent []byte
if _, err := os.Stat(srcFilePath); err == nil {
daemon, err := modifyDaemon(srcFilePath, runtimeFilePath, action)
@@ -128,7 +128,7 @@ func createJsonString(srcFilePath, runtimeFilePath, action string) ([]byte, erro
return writeContent, nil
}
func writeJson(destFilePath string, writeContent []byte) error {
func writeJSON(destFilePath string, writeContent []byte) error {
if _, err := os.Stat(destFilePath); os.IsNotExist(err) {
const perm = 0600
file, err := os.OpenFile(destFilePath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, perm)
@@ -145,9 +145,8 @@ func writeJson(destFilePath string, writeContent []byte) error {
return fmt.Errorf("close target file failed")
}
return nil
} else {
return fmt.Errorf("target file already existed")
}
return fmt.Errorf("target file already existed")
}
func modifyDaemon(srcFilePath, runtimeFilePath, action string) (map[string]interface{}, error) {
@@ -191,7 +190,7 @@ func modifyDaemon(srcFilePath, runtimeFilePath, action string) (map[string]inter
return daemon, nil
}
func loadOriginJson(srcFilePath string) (map[string]interface{}, error) {
func loadOrigin(srcFilePath string) (map[string]interface{}, error) {
if fileInfo, err := os.Stat(srcFilePath); err != nil {
return nil, err
} else if fileInfo.Size() > maxFileSize {

View File

@@ -9,7 +9,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
)
const mockDeviceId = 100
const mockDeviceID = 100
type mockWorker struct{}

View File

@@ -19,9 +19,8 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
"go.uber.org/zap"
"mindxcheckutils"
"huawei.com/npu-exporter/hwlog"
"mindxcheckutils"
)
const (