[Feat] Add Mount Point Setting

This commit is contained in:
Harry-zklcdc 2025-02-09 20:26:54 +08:00
parent a6d4d48cf3
commit cfbd7d24db
5 changed files with 20 additions and 6 deletions

View File

@ -12,3 +12,4 @@ redis:
port: 6379
system:
verify: false
mount_dir: /path/to/mount

View File

@ -41,8 +41,9 @@ type logStruct struct {
}
type systemStruct struct {
Salt string `yaml:"salt,omitempty"`
Verify bool `yaml:"verify,omitempty"`
Salt string `yaml:"salt,omitempty"`
Verify bool `yaml:"verify,omitempty"`
MountDir string `yaml:"mount_dir,omitempty"`
}
var config = configStruct{

View File

@ -53,6 +53,10 @@ func GetSystemVerify() bool {
return config.GetSystemVerify()
}
func GetSystemMountDir() string {
return config.GetSystemMountDir()
}
func Save() error {
return config.Save()
}

View File

@ -40,6 +40,10 @@ func (c *configStruct) GetSystemVerify() bool {
return c.System.Verify
}
func (c *configStruct) GetSystemMountDir() string {
return c.System.MountDir
}
func (c *configStruct) Save() error {
return c.save()
}

View File

@ -6,6 +6,7 @@ import (
"errors"
"megrez/libs/crypto"
"megrez/libs/request"
"megrez/services/config"
"strconv"
)
@ -56,13 +57,16 @@ func createInstance(ip string, port int, apikey string,
Src: volumeName,
Dest: "/root/megrez-tmp",
},
{
Src: "/data/pub",
Dest: "/root/megrez-pub",
},
}
}
if config.GetSystemMountDir() != "" {
data.Binds = append(data.Binds, bindStruct{
Src: config.GetSystemMountDir(),
Dest: "/root/megrez",
})
}
reqBytes, err := json.Marshal(data)
if err != nil {
l.Error("marshal request data error: %v", err)