[Feat] Add Mount Point Setting

This commit is contained in:
Harry-zklcdc
2025-02-09 20:26:54 +08:00
parent a6d4d48cf3
commit 2b36fc7bcb
5 changed files with 20 additions and 6 deletions
+1
View File
@@ -12,3 +12,4 @@ redis:
port: 6379 port: 6379
system: system:
verify: false verify: false
mount_dir: /path/to/mount
+3 -2
View File
@@ -41,8 +41,9 @@ type logStruct struct {
} }
type systemStruct struct { type systemStruct struct {
Salt string `yaml:"salt,omitempty"` Salt string `yaml:"salt,omitempty"`
Verify bool `yaml:"verify,omitempty"` Verify bool `yaml:"verify,omitempty"`
MountDir string `yaml:"mount_dir,omitempty"`
} }
var config = configStruct{ var config = configStruct{
+4
View File
@@ -53,6 +53,10 @@ func GetSystemVerify() bool {
return config.GetSystemVerify() return config.GetSystemVerify()
} }
func GetSystemMountDir() string {
return config.GetSystemMountDir()
}
func Save() error { func Save() error {
return config.Save() return config.Save()
} }
+4
View File
@@ -40,6 +40,10 @@ func (c *configStruct) GetSystemVerify() bool {
return c.System.Verify return c.System.Verify
} }
func (c *configStruct) GetSystemMountDir() string {
return c.System.MountDir
}
func (c *configStruct) Save() error { func (c *configStruct) Save() error {
return c.save() return c.save()
} }
@@ -6,6 +6,7 @@ import (
"errors" "errors"
"megrez/libs/crypto" "megrez/libs/crypto"
"megrez/libs/request" "megrez/libs/request"
"megrez/services/config"
"strconv" "strconv"
) )
@@ -56,13 +57,16 @@ func createInstance(ip string, port int, apikey string,
Src: volumeName, Src: volumeName,
Dest: "/root/megrez-tmp", 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) reqBytes, err := json.Marshal(data)
if err != nil { if err != nil {
l.Error("marshal request data error: %v", err) l.Error("marshal request data error: %v", err)