You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
909 B
Go
39 lines
909 B
Go
package initialize
|
|
|
|
import (
|
|
"fmt"
|
|
"gopkg.in/yaml.v3"
|
|
"os"
|
|
"uploader/config"
|
|
"uploader/global"
|
|
"uploader/utils/storage"
|
|
)
|
|
|
|
func InitConfig(configFilePath string) *config.Config {
|
|
fmt.Println("configFilePath: " + configFilePath)
|
|
content, err := os.ReadFile(configFilePath)
|
|
if err != nil {
|
|
fmt.Printf("err: %v\n", err)
|
|
panic(err)
|
|
}
|
|
var conf config.Config
|
|
if err := yaml.Unmarshal(content, &conf); err != nil {
|
|
fmt.Printf("err: %v\n", err)
|
|
panic(err)
|
|
}
|
|
|
|
return &conf
|
|
}
|
|
|
|
func InitStorage() storage.Storage {
|
|
if global.Config.Storage.StorageType == "oss" {
|
|
return storage.NewOssStorage(global.Config.Storage.Oss)
|
|
} else if global.Config.Storage.StorageType == "obs" {
|
|
return storage.NewObsStorage(global.Config.Storage.Obs)
|
|
} else if global.Config.Storage.StorageType == "cos" {
|
|
return storage.NewCosStorage(global.Config.Storage.Cos)
|
|
} else {
|
|
panic("存储系统不存在")
|
|
}
|
|
}
|