Nacos AMC or KMS

This commit is contained in:
yoyofx 2021-06-01 19:33:47 +08:00
parent 66c4e16397
commit badd6647dc
3 changed files with 22 additions and 0 deletions

View File

@ -18,3 +18,8 @@ yoyogo:
enable: true enable: true
username: "root" username: "root"
password: "1234" password: "1234"
endpoint: ""
regionId: ""
accessKey: ""
secretKey: ""
openKMS: false

View File

@ -34,9 +34,15 @@ func NewNacosConfigManager(option *Option) (*nacosConfigManager, error) {
MaxAge: 3, MaxAge: 3,
LogLevel: "info", LogLevel: "info",
} }
if option.Auth != nil && option.Auth.Enable { if option.Auth != nil && option.Auth.Enable {
clientConfig.Username = option.Auth.User clientConfig.Username = option.Auth.User
clientConfig.Password = option.Auth.Password clientConfig.Password = option.Auth.Password
clientConfig.Endpoint = option.Auth.Endpoint
clientConfig.RegionId = option.Auth.RegionId
clientConfig.AccessKey = option.Auth.AccessKey
clientConfig.SecretKey = option.Auth.SecretKey
clientConfig.OpenKMS = option.Auth.OpenKMS
} }
client, err := clients.CreateConfigClient(map[string]interface{}{ client, err := clients.CreateConfigClient(map[string]interface{}{
"serverConfigs": serverConfigs, "serverConfigs": serverConfigs,

View File

@ -17,4 +17,15 @@ type Auth struct {
Enable bool `mapstructure:"enable"` Enable bool `mapstructure:"enable"`
User string `mapstructure:"username"` User string `mapstructure:"username"`
Password string `mapstructure:"password"` Password string `mapstructure:"password"`
// ACM Endpoint
Endpoint string `mapstructure:"endpoint"`
// ACM RegionId
RegionId string `mapstructure:"regionId"`
// ACM AccessKey
AccessKey string `mapstructure:"accessKey"`
// ACM SecretKey
SecretKey string `mapstructure:"secretKey"`
// ACM OpenKMS
OpenKMS bool `mapstructure:"openKMS"`
} }