Skip to content

Commit 64da426

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix input.value attr for RequiredClaimName/Value (go-gitea#20946) Move some files into models' sub packages (go-gitea#20262) [skip ci] Updated translations via Crowdin docs[zh-cn]: Install on Kubernetes (go-gitea#20874) Return 404 NotFound if requested attachment does not exist (go-gitea#20886) Avoid frequent string2bytes conversions (go-gitea#20940)
2 parents f0e7544 + a2db810 commit 64da426

File tree

158 files changed

+1874
-1746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1874
-1746
lines changed

cmd/admin.go

+17-18
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import (
1313
"strings"
1414
"text/tabwriter"
1515

16-
"code.gitea.io/gitea/models"
1716
asymkey_model "code.gitea.io/gitea/models/asymkey"
18-
"code.gitea.io/gitea/models/auth"
17+
auth_model "code.gitea.io/gitea/models/auth"
1918
"code.gitea.io/gitea/models/db"
2019
repo_model "code.gitea.io/gitea/models/repo"
2120
user_model "code.gitea.io/gitea/models/user"
@@ -593,12 +592,12 @@ func runCreateUser(c *cli.Context) error {
593592
}
594593

595594
if c.Bool("access-token") {
596-
t := &models.AccessToken{
595+
t := &auth_model.AccessToken{
597596
Name: "gitea-admin",
598597
UID: u.ID,
599598
}
600599

601-
if err := models.NewAccessToken(t); err != nil {
600+
if err := auth_model.NewAccessToken(t); err != nil {
602601
return err
603602
}
604603

@@ -700,12 +699,12 @@ func runGenerateAccessToken(c *cli.Context) error {
700699
return err
701700
}
702701

703-
t := &models.AccessToken{
702+
t := &auth_model.AccessToken{
704703
Name: c.String("token-name"),
705704
UID: user.ID,
706705
}
707706

708-
if err := models.NewAccessToken(t); err != nil {
707+
if err := auth_model.NewAccessToken(t); err != nil {
709708
return err
710709
}
711710

@@ -779,9 +778,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
779778
}
780779

781780
func getReleaseCount(id int64) (int64, error) {
782-
return models.GetReleaseCountByRepoID(
781+
return repo_model.GetReleaseCountByRepoID(
783782
id,
784-
models.FindReleasesOptions{
783+
repo_model.FindReleasesOptions{
785784
IncludeTags: true,
786785
},
787786
)
@@ -844,8 +843,8 @@ func runAddOauth(c *cli.Context) error {
844843
return err
845844
}
846845

847-
return auth.CreateSource(&auth.Source{
848-
Type: auth.OAuth2,
846+
return auth_model.CreateSource(&auth_model.Source{
847+
Type: auth_model.OAuth2,
849848
Name: c.String("name"),
850849
IsActive: true,
851850
Cfg: parseOAuth2Config(c),
@@ -864,7 +863,7 @@ func runUpdateOauth(c *cli.Context) error {
864863
return err
865864
}
866865

867-
source, err := auth.GetSourceByID(c.Int64("id"))
866+
source, err := auth_model.GetSourceByID(c.Int64("id"))
868867
if err != nil {
869868
return err
870869
}
@@ -944,7 +943,7 @@ func runUpdateOauth(c *cli.Context) error {
944943
oAuth2Config.CustomURLMapping = customURLMapping
945944
source.Cfg = oAuth2Config
946945

947-
return auth.UpdateSource(source)
946+
return auth_model.UpdateSource(source)
948947
}
949948

950949
func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
@@ -1015,8 +1014,8 @@ func runAddSMTP(c *cli.Context) error {
10151014
smtpConfig.Auth = "PLAIN"
10161015
}
10171016

1018-
return auth.CreateSource(&auth.Source{
1019-
Type: auth.SMTP,
1017+
return auth_model.CreateSource(&auth_model.Source{
1018+
Type: auth_model.SMTP,
10201019
Name: c.String("name"),
10211020
IsActive: active,
10221021
Cfg: &smtpConfig,
@@ -1035,7 +1034,7 @@ func runUpdateSMTP(c *cli.Context) error {
10351034
return err
10361035
}
10371036

1038-
source, err := auth.GetSourceByID(c.Int64("id"))
1037+
source, err := auth_model.GetSourceByID(c.Int64("id"))
10391038
if err != nil {
10401039
return err
10411040
}
@@ -1056,7 +1055,7 @@ func runUpdateSMTP(c *cli.Context) error {
10561055

10571056
source.Cfg = smtpConfig
10581057

1059-
return auth.UpdateSource(source)
1058+
return auth_model.UpdateSource(source)
10601059
}
10611060

10621061
func runListAuth(c *cli.Context) error {
@@ -1067,7 +1066,7 @@ func runListAuth(c *cli.Context) error {
10671066
return err
10681067
}
10691068

1070-
authSources, err := auth.Sources()
1069+
authSources, err := auth_model.Sources()
10711070
if err != nil {
10721071
return err
10731072
}
@@ -1105,7 +1104,7 @@ func runDeleteAuth(c *cli.Context) error {
11051104
return err
11061105
}
11071106

1108-
source, err := auth.GetSourceByID(c.Int64("id"))
1107+
source, err := auth_model.GetSourceByID(c.Int64("id"))
11091108
if err != nil {
11101109
return err
11111110
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
date: "2020-03-19T19:27:00+02:00"
3+
title: "在 Kubernetes 安装 Gitea"
4+
slug: "install-on-kubernetes"
5+
weight: 10
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "installation"
11+
name: "Kubernetes"
12+
weight: 50
13+
identifier: "install-on-kubernetes"
14+
---
15+
16+
# 使用 Helm 在 Kubernetes 云原生环境中安装 Gitea
17+
18+
Gitea 已经提供了便于在 Kubernetes 云原生环境中安装所需的 Helm Chart
19+
20+
默认安装指令为:
21+
22+
```bash
23+
helm repo add gitea https://dl.gitea.io/charts
24+
helm repo update
25+
helm install gitea gitea/gitea
26+
```
27+
28+
如果采用默认安装指令,Helm 会部署单实例的 Gitea, PostgreSQL, Memcached。若您想实现自定义安装(包括配置 Gitea 集群、NGINX Ingress、MySQL、MariaDB、持久存储等),请前往阅读:[Gitea Helm Chart](https://gitea.com/gitea/helm-chart/)
29+
30+
您也可以通过 `helm show` 命令导出 `README.md` 和配置文件 `values.yaml` 进行学习和编辑,例如:
31+
32+
```bash
33+
helm show values gitea > values.yaml
34+
helm show readme gitea > README.md
35+
36+
# 使用自定义的配置文件 values.yaml
37+
helm install gitea -f values.yaml gitea/gitea
38+
```
39+
40+
## 运行状况检查接口
41+
42+
Gitea 附带了一个运行状况检查接口 `/api/healthz`,你可以像这样在 Kubernetes 中配置它:
43+
44+
```yaml
45+
livenessProbe:
46+
httpGet:
47+
path: /api/healthz
48+
port: http
49+
initialDelaySeconds: 200
50+
timeoutSeconds: 5
51+
periodSeconds: 10
52+
successThreshold: 1
53+
failureThreshold: 10
54+
```
55+
56+
成功的运行状况检查响应代码为 HTTP `200`,下面是示例:
57+
58+
```
59+
HTTP/1.1 200 OK
60+
61+
62+
{
63+
"status": "pass",
64+
"description": "Gitea: Git with a cup of tea",
65+
"checks": {
66+
"cache:ping": [
67+
{
68+
"status": "pass",
69+
"time": "2022-02-19T09:16:08Z"
70+
}
71+
],
72+
"database:ping": [
73+
{
74+
"status": "pass",
75+
"time": "2022-02-19T09:16:08Z"
76+
}
77+
]
78+
}
79+
}
80+
```
81+
82+
有关更多信息,请参考 Kubernetes 文档 [配置存活、就绪和启动探测器](https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)

integrations/api_notification_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"code.gitea.io/gitea/models"
12+
activities_model "code.gitea.io/gitea/models/activities"
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
"code.gitea.io/gitea/models/unittest"
1515
user_model "code.gitea.io/gitea/models/user"
@@ -23,7 +23,7 @@ func TestAPINotification(t *testing.T) {
2323

2424
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
2525
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
26-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
26+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
2727
assert.NoError(t, thread5.LoadAttributes())
2828
session := loginUser(t, user2.Name)
2929
token := getTokenForLoggedInUser(t, session)
@@ -126,9 +126,9 @@ func TestAPINotification(t *testing.T) {
126126
req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
127127
session.MakeRequest(t, req, http.StatusResetContent)
128128

129-
assert.Equal(t, models.NotificationStatusUnread, thread5.Status)
130-
thread5 = unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
131-
assert.Equal(t, models.NotificationStatusRead, thread5.Status)
129+
assert.Equal(t, activities_model.NotificationStatusUnread, thread5.Status)
130+
thread5 = unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
131+
assert.Equal(t, activities_model.NotificationStatusRead, thread5.Status)
132132

133133
// -- check notifications --
134134
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token))
@@ -141,7 +141,7 @@ func TestAPINotificationPUT(t *testing.T) {
141141
defer prepareTestEnv(t)()
142142

143143
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
144-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
144+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
145145
assert.NoError(t, thread5.LoadAttributes())
146146
session := loginUser(t, user2.Name)
147147
token := getTokenForLoggedInUser(t, session)

integrations/api_releases_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"code.gitea.io/gitea/models"
1413
repo_model "code.gitea.io/gitea/models/repo"
1514
"code.gitea.io/gitea/models/unittest"
1615
user_model "code.gitea.io/gitea/models/user"
@@ -84,7 +83,7 @@ func createNewReleaseUsingAPI(t *testing.T, session *TestSession, token string,
8483

8584
var newRelease api.Release
8685
DecodeJSON(t, resp, &newRelease)
87-
rel := &models.Release{
86+
rel := &repo_model.Release{
8887
ID: newRelease.ID,
8988
TagName: newRelease.TagName,
9089
Title: newRelease.Title,
@@ -138,7 +137,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) {
138137
resp = session.MakeRequest(t, req, http.StatusOK)
139138

140139
DecodeJSON(t, resp, &newRelease)
141-
rel := &models.Release{
140+
rel := &repo_model.Release{
142141
ID: newRelease.ID,
143142
TagName: newRelease.TagName,
144143
Title: newRelease.Title,

integrations/api_token_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/http"
99
"testing"
1010

11-
"code.gitea.io/gitea/models"
11+
auth_model "code.gitea.io/gitea/models/auth"
1212
"code.gitea.io/gitea/models/unittest"
1313
user_model "code.gitea.io/gitea/models/user"
1414
api "code.gitea.io/gitea/modules/structs"
@@ -27,7 +27,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
2727

2828
var newAccessToken api.AccessToken
2929
DecodeJSON(t, resp, &newAccessToken)
30-
unittest.AssertExistsAndLoadBean(t, &models.AccessToken{
30+
unittest.AssertExistsAndLoadBean(t, &auth_model.AccessToken{
3131
ID: newAccessToken.ID,
3232
Name: newAccessToken.Name,
3333
Token: newAccessToken.Token,
@@ -38,7 +38,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
3838
req = AddBasicAuthHeader(req, user.Name)
3939
MakeRequest(t, req, http.StatusNoContent)
4040

41-
unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
41+
unittest.AssertNotExistsBean(t, &auth_model.AccessToken{ID: newAccessToken.ID})
4242

4343
req = NewRequestWithJSON(t, "POST", "/api/v1/users/user1/tokens", map[string]string{
4444
"name": "test-key-2",
@@ -51,7 +51,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
5151
req = AddBasicAuthHeader(req, user.Name)
5252
MakeRequest(t, req, http.StatusNoContent)
5353

54-
unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
54+
unittest.AssertNotExistsBean(t, &auth_model.AccessToken{ID: newAccessToken.ID})
5555
}
5656

5757
// TestAPIDeleteMissingToken ensures that error is thrown when token not found

integrations/api_user_heatmap_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"code.gitea.io/gitea/models"
13+
activities_model "code.gitea.io/gitea/models/activities"
1414
"code.gitea.io/gitea/modules/timeutil"
1515

1616
"github.com/stretchr/testify/assert"
@@ -29,10 +29,10 @@ func TestUserHeatmap(t *testing.T) {
2929
urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap?token=%s", normalUsername, token)
3030
req := NewRequest(t, "GET", urlStr)
3131
resp := MakeRequest(t, req, http.StatusOK)
32-
var heatmap []*models.UserHeatmapData
32+
var heatmap []*activities_model.UserHeatmapData
3333
DecodeJSON(t, resp, &heatmap)
34-
var dummyheatmap []*models.UserHeatmapData
35-
dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
34+
var dummyheatmap []*activities_model.UserHeatmapData
35+
dummyheatmap = append(dummyheatmap, &activities_model.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
3636

3737
assert.Equal(t, dummyheatmap, heatmap)
3838
}

integrations/eventsource_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"code.gitea.io/gitea/models"
13+
activities_model "code.gitea.io/gitea/models/activities"
1414
repo_model "code.gitea.io/gitea/models/repo"
1515
"code.gitea.io/gitea/models/unittest"
1616
user_model "code.gitea.io/gitea/models/user"
@@ -42,7 +42,7 @@ func TestEventSourceManagerRun(t *testing.T) {
4242
if !ok {
4343
return false
4444
}
45-
data, ok := event.Data.(models.UserIDCount)
45+
data, ok := event.Data.(activities_model.UserIDCount)
4646
if !ok {
4747
return false
4848
}
@@ -55,7 +55,7 @@ func TestEventSourceManagerRun(t *testing.T) {
5555

5656
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
5757
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
58-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
58+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
5959
assert.NoError(t, thread5.LoadAttributes())
6060
session := loginUser(t, user2.Name)
6161
token := getTokenForLoggedInUser(t, session)

0 commit comments

Comments
 (0)