feat: add configuration management and update deployment files

This commit is contained in:
2026-01-10 19:56:51 +08:00
parent 6730ceafa6
commit d1a5240c34
10 changed files with 180 additions and 21 deletions

39
cmn/conf/conf.go Normal file
View File

@@ -0,0 +1,39 @@
package conf
import (
"os"
"github.com/spf13/viper"
)
func Init(file string) {
viper.AddConfigPath(".")
viper.AddConfigPath("..")
viper.SetConfigFile(file)
err := viper.ReadInConfig()
if err != nil {
panic(err)
}
// read test.key file
var keyFile *os.File
keyFile, err = os.Open(viper.GetString("certs.testKeyPath"))
if err != nil {
panic(err)
}
defer keyFile.Close()
var fileInfo os.FileInfo
fileInfo, err = keyFile.Stat()
if err != nil {
panic(err)
}
keyData := make([]byte, fileInfo.Size())
_, err = keyFile.Read(keyData)
if err != nil {
panic(err)
}
viper.Set("test.key", string(keyData))
}