mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
Azure blob storage support (#30995)
This PR implemented object storages(LFS/Packages/Attachments and etc.) for Azure Blob Storage. It depends on azure official golang SDK and can support both the azure blob storage cloud service and azurite mock server. Replace #25458 Fix #22527 - [x] CI Tests - [x] integration test, MSSQL integration tests will now based on azureblob - [x] unit test - [x] CLI Migrate Storage - [x] Documentation for configuration added ------ TODO (other PRs): - [ ] Improve performance of `blob download`. --------- Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
@ -144,18 +144,29 @@ func TestPackageGeneric(t *testing.T) {
|
||||
t.Run("ServeDirect", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
if setting.Packages.Storage.Type != setting.MinioStorageType {
|
||||
t.Skip("Test skipped for non-Minio-storage.")
|
||||
if setting.Packages.Storage.Type != setting.MinioStorageType && setting.Packages.Storage.Type != setting.AzureBlobStorageType {
|
||||
t.Skip("Test skipped for non-Minio-storage and non-AzureBlob-storage.")
|
||||
return
|
||||
}
|
||||
|
||||
if !setting.Packages.Storage.MinioConfig.ServeDirect {
|
||||
old := setting.Packages.Storage.MinioConfig.ServeDirect
|
||||
defer func() {
|
||||
setting.Packages.Storage.MinioConfig.ServeDirect = old
|
||||
}()
|
||||
if setting.Packages.Storage.Type == setting.MinioStorageType {
|
||||
if !setting.Packages.Storage.MinioConfig.ServeDirect {
|
||||
old := setting.Packages.Storage.MinioConfig.ServeDirect
|
||||
defer func() {
|
||||
setting.Packages.Storage.MinioConfig.ServeDirect = old
|
||||
}()
|
||||
|
||||
setting.Packages.Storage.MinioConfig.ServeDirect = true
|
||||
setting.Packages.Storage.MinioConfig.ServeDirect = true
|
||||
}
|
||||
} else if setting.Packages.Storage.Type == setting.AzureBlobStorageType {
|
||||
if !setting.Packages.Storage.AzureBlobConfig.ServeDirect {
|
||||
old := setting.Packages.Storage.AzureBlobConfig.ServeDirect
|
||||
defer func() {
|
||||
setting.Packages.Storage.AzureBlobConfig.ServeDirect = old
|
||||
}()
|
||||
|
||||
setting.Packages.Storage.AzureBlobConfig.ServeDirect = true
|
||||
}
|
||||
}
|
||||
|
||||
req := NewRequest(t, "GET", url+"/"+filename)
|
||||
@ -168,7 +179,7 @@ func TestPackageGeneric(t *testing.T) {
|
||||
|
||||
resp2, err := (&http.Client{}).Get(location)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, http.StatusOK, resp2.StatusCode)
|
||||
assert.Equal(t, http.StatusOK, resp2.StatusCode, location)
|
||||
|
||||
body, err := io.ReadAll(resp2.Body)
|
||||
assert.NoError(t, err)
|
||||
|
@ -53,9 +53,6 @@ APP_DATA_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data
|
||||
BUILTIN_SSH_SERVER_USER = git
|
||||
SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXWo7GMxTchtzmJHYzfN6sZ9FAPFR4ijMLfGki+olvOMO5Fql1/yGnGfbELQa1S6y4shSvj/5K+zUFScmEXYf3Gcr87RqilLkyk16RS+cHNB1u87xTHbETaa3nyCJeGQRpd4IQ4NKob745mwDZ7jQBH8AZEng50Oh8y8fi8skBBBzaYp1ilgvzG740L7uex6fHV62myq0SXeCa+oJUjq326FU8y+Vsa32H8A3e7tOgXZPdt2TVNltx2S9H2WO8RMi7LfaSwARNfy1zu+bfR50r6ef8Yx5YKCMz4wWb1SHU1GS800mjOjlInLQORYRNMlSwR1+vLlVDciOqFapDSbj+YOVOawR0R1aqlSKpZkt33DuOBPx9qe6CVnIi7Z+Px/KqM+OLCzlLY/RS+LbxQpDWcfTVRiP+S5qRTcE3M3UioN/e0BE/1+MpX90IGpvVkA63ILYbKEa4bM3ASL7ChTCr6xN5XT+GpVJveFKK1cfNx9ExHI4rzYE=
|
||||
|
||||
[attachment]
|
||||
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/attachments
|
||||
|
||||
[mailer]
|
||||
ENABLED = true
|
||||
PROTOCOL = dummy
|
||||
@ -102,8 +99,13 @@ SECRET_KEY = 9pCviYTWSb
|
||||
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
|
||||
DISABLE_QUERY_AUTH_TOKEN = true
|
||||
|
||||
[lfs]
|
||||
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/lfs
|
||||
[storage]
|
||||
STORAGE_TYPE = azureblob
|
||||
AZURE_BLOB_ENDPOINT = http://devstoreaccount1.azurite.local:10000
|
||||
AZURE_BLOB_ACCOUNT_NAME = devstoreaccount1
|
||||
AZURE_BLOB_ACCOUNT_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
||||
AZURE_BLOB_CONTAINER = gitea
|
||||
SERVE_DIRECT = false
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
@ -54,9 +54,6 @@ APP_DATA_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data
|
||||
BUILTIN_SSH_SERVER_USER = git
|
||||
SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXWo7GMxTchtzmJHYzfN6sZ9FAPFR4ijMLfGki+olvOMO5Fql1/yGnGfbELQa1S6y4shSvj/5K+zUFScmEXYf3Gcr87RqilLkyk16RS+cHNB1u87xTHbETaa3nyCJeGQRpd4IQ4NKob745mwDZ7jQBH8AZEng50Oh8y8fi8skBBBzaYp1ilgvzG740L7uex6fHV62myq0SXeCa+oJUjq326FU8y+Vsa32H8A3e7tOgXZPdt2TVNltx2S9H2WO8RMi7LfaSwARNfy1zu+bfR50r6ef8Yx5YKCMz4wWb1SHU1GS800mjOjlInLQORYRNMlSwR1+vLlVDciOqFapDSbj+YOVOawR0R1aqlSKpZkt33DuOBPx9qe6CVnIi7Z+Px/KqM+OLCzlLY/RS+LbxQpDWcfTVRiP+S5qRTcE3M3UioN/e0BE/1+MpX90IGpvVkA63ILYbKEa4bM3ASL7ChTCr6xN5XT+GpVJveFKK1cfNx9ExHI4rzYE=
|
||||
|
||||
[attachment]
|
||||
PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data/attachments
|
||||
|
||||
[mailer]
|
||||
ENABLED = true
|
||||
PROTOCOL = dummy
|
||||
|
Reference in New Issue
Block a user