Skip to content

Commit 4d0309f

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Put web editor into a segment (go-gitea#30966) Check if the release is converted from the tag when updating the release (go-gitea#30984) Supports forced use of S3 virtual-hosted style (go-gitea#30969)
2 parents 21aaf94 + ea8e4ba commit 4d0309f

File tree

8 files changed

+77
-25
lines changed

8 files changed

+77
-25
lines changed

cmd/migrate_storage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ var CmdMigrateStorage = &cli.Command{
9191
Value: "",
9292
Usage: "Minio checksum algorithm (default/md5)",
9393
},
94+
&cli.StringFlag{
95+
Name: "minio-bucket-lookup-type",
96+
Value: "",
97+
Usage: "Minio bucket lookup type",
98+
},
9499
},
95100
}
96101

@@ -220,6 +225,7 @@ func runMigrateStorage(ctx *cli.Context) error {
220225
UseSSL: ctx.Bool("minio-use-ssl"),
221226
InsecureSkipVerify: ctx.Bool("minio-insecure-skip-verify"),
222227
ChecksumAlgorithm: ctx.String("minio-checksum-algorithm"),
228+
BucketLookUpType: ctx.String("minio-bucket-lookup-type"),
223229
},
224230
})
225231
default:

custom/conf/app.example.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,9 @@ LEVEL = Info
18951895
;;
18961896
;; Minio checksum algorithm: default (for MinIO or AWS S3) or md5 (for Cloudflare or Backblaze)
18971897
;MINIO_CHECKSUM_ALGORITHM = default
1898+
;;
1899+
;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
1900+
;MINIO_BUCKET_LOOKUP_TYPE = auto
18981901

18991902
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19001903
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2576,6 +2579,9 @@ LEVEL = Info
25762579
;;
25772580
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
25782581
;MINIO_INSECURE_SKIP_VERIFY = false
2582+
;;
2583+
;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
2584+
;MINIO_BUCKET_LOOKUP_TYPE = auto
25792585

25802586
;[proxy]
25812587
;; Enable the proxy, all requests to external via HTTP will be affected

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ Default templates for project boards:
851851
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio`
852852
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
853853
- `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio checksum algorithm: `default` (for MinIO or AWS S3) or `md5` (for Cloudflare or Backblaze)
854+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
854855

855856
## Log (`log`)
856857

@@ -1272,6 +1273,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`.
12721273
- `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
12731274
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
12741275
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
1276+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
12751277

12761278
## Storage (`storage`)
12771279

@@ -1286,6 +1288,7 @@ Default storage configuration for attachments, lfs, avatars, repo-avatars, repo-
12861288
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
12871289
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
12881290
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
1291+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
12891292

12901293
The recommended storage configuration for minio like below:
12911294

@@ -1307,6 +1310,8 @@ MINIO_USE_SSL = false
13071310
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
13081311
MINIO_INSECURE_SKIP_VERIFY = false
13091312
SERVE_DIRECT = true
1313+
; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
1314+
MINIO_BUCKET_LOOKUP_TYPE = auto
13101315
```
13111316

13121317
Defaultly every storage has their default base path like below
@@ -1353,6 +1358,8 @@ MINIO_LOCATION = us-east-1
13531358
MINIO_USE_SSL = false
13541359
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
13551360
MINIO_INSECURE_SKIP_VERIFY = false
1361+
; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
1362+
MINIO_BUCKET_LOOKUP_TYPE = auto
13561363
```
13571364

13581365
## Repository Archive Storage (`storage.repo-archive`)
@@ -1372,6 +1379,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`.
13721379
- `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
13731380
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
13741381
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
1382+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
13751383

13761384
## Repository Archives (`repo-archive`)
13771385

docs/content/administration/config-cheat-sheet.zh-cn.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ Gitea 创建以下非唯一队列:
796796
- `MINIO_USE_SSL`: **false**: Minio 启用 SSL,仅当 STORAGE_TYPE 为 `minio` 时可用。
797797
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio 跳过 SSL 验证,仅当 STORAGE_TYPE 为 `minio` 时可用。
798798
- `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio 校验算法:`default`(适用于 MinIO 或 AWS S3)或 `md5`(适用于 Cloudflare 或 Backblaze)
799+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE``minio`时可用。
799800

800801
## 日志 (`log`)
801802

@@ -1201,6 +1202,7 @@ ALLOW_DATA_URI_IMAGES = true
12011202
- `MINIO_BASE_PATH`**lfs/**:桶上的 Minio 基本路径,仅在 `STORAGE_TYPE``minio` 时可用。
12021203
- `MINIO_USE_SSL`**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE``minio` 时可用。
12031204
- `MINIO_INSECURE_SKIP_VERIFY`**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE``minio` 时可用。
1205+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE``minio`时可用。
12041206

12051207
## 存储 (`storage`)
12061208

@@ -1215,6 +1217,7 @@ ALLOW_DATA_URI_IMAGES = true
12151217
- `MINIO_LOCATION`**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE``minio` 时可用。
12161218
- `MINIO_USE_SSL`**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE``minio` 时可用。
12171219
- `MINIO_INSECURE_SKIP_VERIFY`**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE``minio` 时可用。
1220+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE``minio`时可用。
12181221

12191222
建议的 minio 存储配置如下:
12201223

@@ -1236,6 +1239,8 @@ MINIO_USE_SSL = false
12361239
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
12371240
MINIO_INSECURE_SKIP_VERIFY = false
12381241
SERVE_DIRECT = true
1242+
; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
1243+
MINIO_BUCKET_LOOKUP_TYPE = auto
12391244
```
12401245

12411246
默认情况下,每个存储都有其默认的基本路径,如下所示:
@@ -1282,6 +1287,8 @@ MINIO_LOCATION = us-east-1
12821287
MINIO_USE_SSL = false
12831288
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
12841289
MINIO_INSECURE_SKIP_VERIFY = false
1290+
; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio`
1291+
MINIO_BUCKET_LOOKUP_TYPE = auto
12851292
```
12861293

12871294
### 存储库归档存储 (`storage.repo-archive`)
@@ -1299,6 +1306,7 @@ MINIO_INSECURE_SKIP_VERIFY = false
12991306
- `MINIO_BASE_PATH`: **repo-archive/**:存储桶上的Minio基本路径,仅在`STORAGE_TYPE``minio`时可用。
13001307
- `MINIO_USE_SSL`: **false**:启用Minio的SSL,仅在`STORAGE_TYPE``minio`时可用。
13011308
- `MINIO_INSECURE_SKIP_VERIFY`: **false**:跳过Minio的SSL验证,仅在`STORAGE_TYPE``minio`时可用。
1309+
- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE``minio`时可用。
13021310

13031311
### 存储库归档 (`repo-archive`)
13041312

modules/setting/storage.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type MinioStorageConfig struct {
4747
InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"`
4848
ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"`
4949
ServeDirect bool `ini:"SERVE_DIRECT"`
50+
BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE" json:",omitempty"`
5051
}
5152

5253
// Storage represents configuration of storages
@@ -82,6 +83,7 @@ func getDefaultStorageSection(rootCfg ConfigProvider) ConfigSection {
8283
storageSec.Key("MINIO_USE_SSL").MustBool(false)
8384
storageSec.Key("MINIO_INSECURE_SKIP_VERIFY").MustBool(false)
8485
storageSec.Key("MINIO_CHECKSUM_ALGORITHM").MustString("default")
86+
storageSec.Key("MINIO_BUCKET_LOOKUP_TYPE").MustString("auto")
8587
return storageSec
8688
}
8789

modules/storage/minio.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,23 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
8585

8686
log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath)
8787

88+
var lookup minio.BucketLookupType
89+
if config.BucketLookUpType == "auto" || config.BucketLookUpType == "" {
90+
lookup = minio.BucketLookupAuto
91+
} else if config.BucketLookUpType == "dns" {
92+
lookup = minio.BucketLookupDNS
93+
} else if config.BucketLookUpType == "path" {
94+
lookup = minio.BucketLookupPath
95+
} else {
96+
return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.BucketLookUpType)
97+
}
98+
8899
minioClient, err := minio.New(config.Endpoint, &minio.Options{
89-
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
90-
Secure: config.UseSSL,
91-
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
92-
Region: config.Location,
100+
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
101+
Secure: config.UseSSL,
102+
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
103+
Region: config.Location,
104+
BucketLookup: lookup,
93105
})
94106
if err != nil {
95107
return nil, convertMinioErr(err)

services/release/release.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
204204
if rel.ID == 0 {
205205
return errors.New("UpdateRelease only accepts an exist release")
206206
}
207-
isCreated, err := createTag(gitRepo.Ctx, gitRepo, rel, "")
207+
isTagCreated, err := createTag(gitRepo.Ctx, gitRepo, rel, "")
208208
if err != nil {
209209
return err
210210
}
@@ -216,6 +216,12 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
216216
}
217217
defer committer.Close()
218218

219+
oldRelease, err := repo_model.GetReleaseByID(ctx, rel.ID)
220+
if err != nil {
221+
return err
222+
}
223+
isConvertedFromTag := oldRelease.IsTag && !rel.IsTag
224+
219225
if err = repo_model.UpdateRelease(ctx, rel); err != nil {
220226
return err
221227
}
@@ -292,7 +298,7 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
292298
}
293299

294300
if !rel.IsDraft {
295-
if !isCreated {
301+
if !isTagCreated && !isConvertedFromTag {
296302
notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
297303
return nil
298304
}

templates/repo/editor/edit.tmpl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,30 @@
2626
</div>
2727
</div>
2828
<div class="field">
29-
<div class="ui compact small menu small-menu-items repo-editor-menu">
30-
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a>
31-
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
32-
{{if not .IsNewFile}}
33-
<a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a>
34-
{{end}}
35-
</div>
36-
<div class="ui active tab segment tw-rounded" data-tab="write">
37-
<textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}"
38-
data-url="{{.Repository.Link}}/markup"
39-
data-context="{{.RepoLink}}"
40-
data-previewable-extensions="{{.PreviewableExtensions}}"
41-
data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea>
42-
<div class="editor-loading is-loading"></div>
43-
</div>
44-
<div class="ui tab segment markup tw-rounded" data-tab="preview">
45-
{{ctx.Locale.Tr "loading"}}
29+
<div class="ui top attached header">
30+
<div class="ui compact small menu small-menu-items repo-editor-menu">
31+
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a>
32+
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
33+
{{if not .IsNewFile}}
34+
<a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a>
35+
{{end}}
36+
</div>
4637
</div>
47-
<div class="ui tab segment diff edit-diff" data-tab="diff">
48-
<div class="tw-p-16"></div>
38+
<div class="ui bottom attached segment tw-p-0">
39+
<div class="ui active tab tw-rounded" data-tab="write">
40+
<textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}"
41+
data-url="{{.Repository.Link}}/markup"
42+
data-context="{{.RepoLink}}"
43+
data-previewable-extensions="{{.PreviewableExtensions}}"
44+
data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea>
45+
<div class="editor-loading is-loading"></div>
46+
</div>
47+
<div class="ui tab markup tw-px-4 tw-py-3" data-tab="preview">
48+
{{ctx.Locale.Tr "loading"}}
49+
</div>
50+
<div class="ui tab diff edit-diff" data-tab="diff">
51+
<div class="tw-p-16"></div>
52+
</div>
4953
</div>
5054
</div>
5155
{{template "repo/editor/commit_form" .}}

0 commit comments

Comments
 (0)