Merge pull request #2264 from withchao/release-v3.7

fix: minio config url recognition error
pull/2285/head
chao 7 months ago committed by GitHub
commit eb4698a44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,14 +15,13 @@
package config package config
import ( import (
"fmt"
"github.com/openimsdk/tools/db/mongoutil" "github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/redisutil" "github.com/openimsdk/tools/db/redisutil"
"github.com/openimsdk/tools/mq/kafka" "github.com/openimsdk/tools/mq/kafka"
"github.com/openimsdk/tools/s3/cos" "github.com/openimsdk/tools/s3/cos"
"github.com/openimsdk/tools/s3/minio" "github.com/openimsdk/tools/s3/minio"
"github.com/openimsdk/tools/s3/oss" "github.com/openimsdk/tools/s3/oss"
"net" "strings"
"time" "time"
) )
@ -473,25 +472,23 @@ func (k *Kafka) Build() *kafka.Config {
}, },
} }
} }
func (m *Minio) Build() *minio.Config { func (m *Minio) Build() *minio.Config {
conf := minio.Config{ formatEndpoint := func(address string) string {
if strings.HasPrefix(address, "http://") || strings.HasPrefix(address, "https://") {
return address
}
return "http://" + address
}
return &minio.Config{
Bucket: m.Bucket, Bucket: m.Bucket,
AccessKeyID: m.AccessKeyID, AccessKeyID: m.AccessKeyID,
SecretAccessKey: m.SecretAccessKey, SecretAccessKey: m.SecretAccessKey,
SessionToken: m.SessionToken, SessionToken: m.SessionToken,
PublicRead: m.PublicRead, PublicRead: m.PublicRead,
Endpoint: formatEndpoint(m.InternalAddress),
SignEndpoint: formatEndpoint(m.ExternalAddress),
} }
if _, _, err := net.SplitHostPort(m.InternalAddress); err == nil {
conf.Endpoint = fmt.Sprintf("http://%s", m.InternalAddress)
} else {
conf.Endpoint = m.InternalAddress
}
if _, _, err := net.SplitHostPort(m.ExternalAddress); err == nil {
conf.SignEndpoint = fmt.Sprintf("http://%s", m.ExternalAddress)
} else {
conf.SignEndpoint = m.ExternalAddress
}
return &conf
} }
func (c *Cos) Build() *cos.Config { func (c *Cos) Build() *cos.Config {
return &cos.Config{ return &cos.Config{

Loading…
Cancel
Save