server/public/ -- pre-requisite changes (#23278)
* invert depdendency: filestore -> model
* markdown: nolint:misspell
* inline jsonutils within model
* push model.GetInfoForBytes -> channels/app
* push channel/utils.CompileGo* -> plugin/utils
* push plugin/scheduler -> channels/jobs/plugins
* push utils.Copy(File|Dir) -> model
* oauthproiders/gitlab -> channels/app/oauthproviders/gitlab
* decouple plugin from einterfaces.MetricsInterface
* fix TestGetInfoForFile
* Revert "Run golangci in server CI (#23240)"
This reverts commit 349e5d4573.
* add model/utils
---------
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5c28071fb3
Коммит
f28a2bcca7
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/server/v8/model"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -57,6 +58,30 @@ type FileBackendSettings struct {
|
||||
AmazonS3RequestTimeoutMilliseconds int64
|
||||
}
|
||||
|
||||
func NewFileBackendSettingsFromConfig(fileSettings *model.FileSettings, enableComplianceFeature bool, skipVerify bool) FileBackendSettings {
|
||||
if *fileSettings.DriverName == model.ImageDriverLocal {
|
||||
return FileBackendSettings{
|
||||
DriverName: *fileSettings.DriverName,
|
||||
Directory: *fileSettings.Directory,
|
||||
}
|
||||
}
|
||||
return FileBackendSettings{
|
||||
DriverName: *fileSettings.DriverName,
|
||||
AmazonS3AccessKeyId: *fileSettings.AmazonS3AccessKeyId,
|
||||
AmazonS3SecretAccessKey: *fileSettings.AmazonS3SecretAccessKey,
|
||||
AmazonS3Bucket: *fileSettings.AmazonS3Bucket,
|
||||
AmazonS3PathPrefix: *fileSettings.AmazonS3PathPrefix,
|
||||
AmazonS3Region: *fileSettings.AmazonS3Region,
|
||||
AmazonS3Endpoint: *fileSettings.AmazonS3Endpoint,
|
||||
AmazonS3SSL: fileSettings.AmazonS3SSL == nil || *fileSettings.AmazonS3SSL,
|
||||
AmazonS3SignV2: fileSettings.AmazonS3SignV2 != nil && *fileSettings.AmazonS3SignV2,
|
||||
AmazonS3SSE: fileSettings.AmazonS3SSE != nil && *fileSettings.AmazonS3SSE && enableComplianceFeature,
|
||||
AmazonS3Trace: fileSettings.AmazonS3Trace != nil && *fileSettings.AmazonS3Trace,
|
||||
AmazonS3RequestTimeoutMilliseconds: *fileSettings.AmazonS3RequestTimeoutMilliseconds,
|
||||
SkipVerify: skipVerify,
|
||||
}
|
||||
}
|
||||
|
||||
func (settings *FileBackendSettings) CheckMandatoryS3Fields() error {
|
||||
if settings.AmazonS3Bucket == "" {
|
||||
return errors.New("missing s3 bucket settings")
|
||||
|
||||
@@ -18,17 +18,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/server/v8/model"
|
||||
s3 "github.com/minio/minio-go/v7"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Copied from model/config.go to avoid an import cycle
|
||||
const (
|
||||
MinioAccessKey = "minioaccesskey"
|
||||
MinioSecretKey = "miniosecretkey"
|
||||
ImageDriverS3 = "amazons3"
|
||||
)
|
||||
|
||||
func TestCheckMandatoryS3Fields(t *testing.T) {
|
||||
cfg := FileBackendSettings{}
|
||||
|
||||
@@ -69,9 +63,9 @@ func TestMakeBucket(t *testing.T) {
|
||||
bucketName = strings.Replace(bucketName, "/", "", -1)
|
||||
|
||||
cfg := FileBackendSettings{
|
||||
DriverName: ImageDriverS3,
|
||||
AmazonS3AccessKeyId: MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: MinioSecretKey,
|
||||
DriverName: model.ImageDriverS3,
|
||||
AmazonS3AccessKeyId: model.MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: model.MinioSecretKey,
|
||||
AmazonS3Bucket: bucketName,
|
||||
AmazonS3Endpoint: s3Endpoint,
|
||||
AmazonS3Region: "",
|
||||
@@ -110,9 +104,9 @@ func TestTimeout(t *testing.T) {
|
||||
bucketName = strings.Replace(bucketName, "/", "", -1)
|
||||
|
||||
cfg := FileBackendSettings{
|
||||
DriverName: ImageDriverS3,
|
||||
AmazonS3AccessKeyId: MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: MinioSecretKey,
|
||||
DriverName: model.ImageDriverS3,
|
||||
AmazonS3AccessKeyId: model.MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: model.MinioSecretKey,
|
||||
AmazonS3Bucket: bucketName,
|
||||
AmazonS3Endpoint: s3Endpoint,
|
||||
AmazonS3Region: "",
|
||||
@@ -171,9 +165,9 @@ func TestInsecureMakeBucket(t *testing.T) {
|
||||
bucketName = strings.Replace(bucketName, "/", "", -1)
|
||||
|
||||
cfg := FileBackendSettings{
|
||||
DriverName: ImageDriverS3,
|
||||
AmazonS3AccessKeyId: MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: MinioSecretKey,
|
||||
DriverName: model.ImageDriverS3,
|
||||
AmazonS3AccessKeyId: model.MinioAccessKey,
|
||||
AmazonS3SecretAccessKey: model.MinioSecretKey,
|
||||
AmazonS3Bucket: bucketName,
|
||||
AmazonS3Endpoint: proxySelfSignedHTTPS.URL[8:],
|
||||
AmazonS3Region: "",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
//nolint:misspell
|
||||
package markdown
|
||||
|
||||
var htmlEntities = map[string]string{
|
||||
|
||||
Ссылка в новой задаче
Block a user