Endpoint field for aws config

* endpoint fields for aws config
* fix for linter
* fix for demo in the readme
This commit is contained in:
Pavel 2022-04-12 17:11:52 +03:00 committed by GitHub
parent 604e6fda58
commit 54326b4193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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")

View File

@ -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"`

View File

@ -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)

View File

@ -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)