diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 198c5de..ea56b65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,14 @@ jobs: steps: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: '1.17' + - name: Get dependencies + run: go mod tidy - name: Lint code with golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: version: v1.42.1 only-new-issues: true diff --git a/README.md b/README.md index edd2cde..4bb3cdb 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,12 @@ import ( func main() { // Create new core.Engine instance - app := core.New() + app := core.New(core.AppInfo{ + Version: "v1.0", + Commit: "bcef82e", + Build: "v1.0-bcef82e", + BuildDate: "1649766442", + }) // Load configuration app.Config = core.NewConfig("config.yml") diff --git a/core/config/config.go b/core/config/config.go index beb21b7..1e0f07f 100644 --- a/core/config/config.go +++ b/core/config/config.go @@ -57,6 +57,7 @@ type Info struct { type AWS struct { AccessKeyID string `yaml:"access_key_id"` SecretAccessKey string `yaml:"secret_access_key"` + Endpoint string `yaml:"endpoint"` Region string `yaml:"region"` Bucket string `yaml:"bucket"` FolderName string `yaml:"folder_name"` diff --git a/core/config/config_test.go b/core/config/config_test.go index 9d8794f..0b143d4 100644 --- a/core/config/config_test.go +++ b/core/config/config_test.go @@ -48,6 +48,7 @@ http_client: config_aws: access_key_id: key secret_access_key: secret + endpoint: https://endpoint.com region: region bucket: bucket folder_name: folder @@ -100,6 +101,7 @@ func (c *ConfigTest) Test_GetUpdateInterval() { func (c *ConfigTest) Test_GetConfigAWS() { assert.Equal(c.T(), "key", c.config.GetAWSConfig().AccessKeyID) assert.Equal(c.T(), "secret", c.config.GetAWSConfig().SecretAccessKey) + assert.Equal(c.T(), "https://endpoint.com", c.config.GetAWSConfig().Endpoint) assert.Equal(c.T(), "region", c.config.GetAWSConfig().Region) assert.Equal(c.T(), "bucket", c.config.GetAWSConfig().Bucket) assert.Equal(c.T(), "folder", c.config.GetAWSConfig().FolderName) diff --git a/core/util/utils.go b/core/util/utils.go index bee836d..59e29da 100644 --- a/core/util/utils.go +++ b/core/util/utils.go @@ -185,6 +185,10 @@ func (u *Utils) UploadUserAvatar(url string) (picURLs3 string, err error) { Region: aws.String(u.AWS.Region), } + if u.AWS.Endpoint != "" { + s3Config.Endpoint = aws.String(u.AWS.Endpoint) + } + s := session.Must(session.NewSession(s3Config)) uploader := s3manager.NewUploader(s)