Skip to content

Commit eb12e65

Browse files
authored
Merge branch 'main' into refactor-git-cmd
2 parents 4db2bde + 8913916 commit eb12e65

File tree

235 files changed

+2246
-622
lines changed

Some content is hidden

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

235 files changed

+2246
-622
lines changed

cmd/admin.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ var (
180180
Name: "raw",
181181
Usage: "Display only the token value",
182182
},
183+
cli.StringFlag{
184+
Name: "scopes",
185+
Value: "",
186+
Usage: "Comma separated list of scopes to apply to access token",
187+
},
183188
},
184189
Action: runGenerateAccessToken,
185190
}
@@ -698,9 +703,15 @@ func runGenerateAccessToken(c *cli.Context) error {
698703
return err
699704
}
700705

706+
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
707+
if err != nil {
708+
return err
709+
}
710+
701711
t := &auth_model.AccessToken{
702-
Name: c.String("token-name"),
703-
UID: user.ID,
712+
Name: c.String("token-name"),
713+
UID: user.ID,
714+
Scope: accessTokenScope,
704715
}
705716

706717
if err := auth_model.NewAccessToken(t); err != nil {

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,8 @@ ROUTER = console
24582458
;LIMIT_SIZE_COMPOSER = -1
24592459
;; Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24602460
;LIMIT_SIZE_CONAN = -1
2461+
;; Maximum size of a Conda upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2462+
;LIMIT_SIZE_CONDA = -1
24612463
;; Maximum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24622464
;LIMIT_SIZE_CONTAINER = -1
24632465
;; Maximum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
12141214
- `LIMIT_TOTAL_OWNER_SIZE`: **-1**: Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12151215
- `LIMIT_SIZE_COMPOSER`: **-1**: Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12161216
- `LIMIT_SIZE_CONAN`: **-1**: Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1217+
- `LIMIT_SIZE_CONDA`: **-1**: Maximum size of a Conda upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12171218
- `LIMIT_SIZE_CONTAINER`: **-1**: Maximum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12181219
- `LIMIT_SIZE_GENERIC`: **-1**: Maximum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12191220
- `LIMIT_SIZE_HELM`: **-1**: Maximum size of a Helm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
date: "2022-12-28T00:00:00+00:00"
3+
title: "Conda Packages Repository"
4+
slug: "packages/conda"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "Conda"
11+
weight: 25
12+
identifier: "conda"
13+
---
14+
15+
# Conda Packages Repository
16+
17+
Publish [Conda](https://docs.conda.io/en/latest/) packages for your user or organization.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
To work with the Conda package registry, you need to use [conda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html).
26+
27+
## Configuring the package registry
28+
29+
To register the package registry and provide credentials, edit your `.condarc` file:
30+
31+
```yaml
32+
channel_alias: https://gitea.example.com/api/packages/{owner}/conda
33+
channels:
34+
- https://gitea.example.com/api/packages/{owner}/conda
35+
default_channels:
36+
- https://gitea.example.com/api/packages/{owner}/conda
37+
```
38+
39+
| Placeholder | Description |
40+
| ------------ | ----------- |
41+
| `owner` | The owner of the package. |
42+
43+
See the [official documentation](https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html) for explanations of the individual settings.
44+
45+
If you need to provide credentials, you may embed them as part of the channel url (`https://user:password@gitea.example.com/...`).
46+
47+
## Publish a package
48+
49+
To publish a package, perform a HTTP PUT operation with the package content in the request body.
50+
51+
```
52+
PUT https://gitea.example.com/api/packages/{owner}/conda/{channel}/{filename}
53+
```
54+
55+
| Placeholder | Description |
56+
| ------------ | ----------- |
57+
| `owner` | The owner of the package. |
58+
| `channel` | The [channel](https://conda.io/projects/conda/en/latest/user-guide/concepts/channels.html) of the package. (optional) |
59+
| `filename` | The name of the file. |
60+
61+
Example request using HTTP Basic authentication:
62+
63+
```shell
64+
curl --user your_username:your_password_or_token \
65+
--upload-file path/to/package-1.0.conda \
66+
https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda
67+
```
68+
69+
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
70+
71+
## Install a package
72+
73+
To install a package from the package registry, execute one of the following commands:
74+
75+
```shell
76+
conda install {package_name}
77+
conda install {package_name}={package_version}
78+
conda install -c {channel} {package_name}
79+
```
80+
81+
| Parameter | Description |
82+
| ----------------- | ----------- |
83+
| `package_name` | The package name. |
84+
| `package_version` | The package version. |
85+
| `channel` | The channel of the package. (optional) |

docs/content/doc/packages/overview.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following package managers are currently supported:
2828
| ---- | -------- | -------------- |
2929
| [Composer]({{< relref "doc/packages/composer.en-us.md" >}}) | PHP | `composer` |
3030
| [Conan]({{< relref "doc/packages/conan.en-us.md" >}}) | C++ | `conan` |
31+
| [Conda]({{< relref "doc/packages/conda.en-us.md" >}}) | - | `conda` |
3132
| [Container]({{< relref "doc/packages/container.en-us.md" >}}) | - | any OCI compliant client |
3233
| [Generic]({{< relref "doc/packages/generic.en-us.md" >}}) | - | any HTTP client |
3334
| [Helm]({{< relref "doc/packages/helm.en-us.md" >}}) | - | any HTTP client, `cm-push` |

docs/content/doc/secrets/overview.en-us.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2022-12-19T21:26:00+08:00"
3-
title: "Encrypted secrets"
3+
title: "Secrets"
44
slug: "secrets/overview"
55
draft: false
66
toc: false
@@ -12,24 +12,24 @@ menu:
1212
identifier: "overview"
1313
---
1414

15-
# Encrypted secrets
15+
# Secrets
1616

17-
Encrypted secrets allow you to store sensitive information in your organization or repository.
17+
Secrets allow you to store sensitive information in your user, organization or repository.
1818
Secrets are available on Gitea 1.19+.
1919

2020
# Naming your secrets
2121

2222
The following rules apply to secret names:
2323

24-
Secret names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
24+
- Secret names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
2525

26-
Secret names must not start with the `GITHUB_` and `GITEA_` prefix.
26+
- Secret names must not start with the `GITHUB_` and `GITEA_` prefix.
2727

28-
Secret names must not start with a number.
28+
- Secret names must not start with a number.
2929

30-
Secret names are not case-sensitive.
30+
- Secret names are not case-sensitive.
3131

32-
Secret names must be unique at the level they are created at.
32+
- Secret names must be unique at the level they are created at.
3333

3434
For example, a secret created at the repository level must have a unique name in that repository, and a secret created at the organization level must have a unique name at that level.
3535

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21
2727
github.com/djherbis/buffer v1.2.0
2828
github.com/djherbis/nio/v3 v3.0.1
29+
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5
2930
github.com/dustin/go-humanize v1.0.0
3031
github.com/editorconfig/editorconfig-core-go/v2 v2.5.1
3132
github.com/emersion/go-imap v1.2.1
@@ -161,7 +162,6 @@ require (
161162
github.com/davecgh/go-spew v1.1.1 // indirect
162163
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
163164
github.com/dlclark/regexp2 v1.7.0 // indirect
164-
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
165165
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect
166166
github.com/fatih/color v1.13.0 // indirect
167167
github.com/felixge/httpsnoop v1.0.3 // indirect
@@ -284,7 +284,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
284284

285285
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
286286

287-
replace github.com/nektos/act => gitea.com/gitea/act v0.234.0
287+
replace github.com/nektos/act => gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744
288288

289289
exclude github.com/gofrs/uuid v3.2.0+incompatible
290290

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
7070
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
7171
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
7272
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
73-
gitea.com/gitea/act v0.234.0 h1:gWgMPMKdNcMrp/o2CF/SyVKiiJLBFl+xmzfvoHCpykU=
74-
gitea.com/gitea/act v0.234.0/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14=
73+
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744 h1:cqzKmGlX0wynSXO04NILpL25eBGwogDrKpkkbwmIpj4=
74+
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14=
7575
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
7676
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
7777
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=

models/asymkey/error.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func (err ErrKeyUnableVerify) Error() string {
2424
return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
2525
}
2626

27+
// ErrKeyIsPrivate is returned when the provided key is a private key not a public key
28+
var ErrKeyIsPrivate = util.NewSilentWrapErrorf(util.ErrInvalidArgument, "the provided key is a private key")
29+
2730
// ErrKeyNotExist represents a "KeyNotExist" kind of error.
2831
type ErrKeyNotExist struct {
2932
ID int64

models/asymkey/ssh_key_parse.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func parseKeyString(content string) (string, error) {
9696
if block == nil {
9797
return "", fmt.Errorf("failed to parse PEM block containing the public key")
9898
}
99+
if strings.Contains(block.Type, "PRIVATE") {
100+
return "", ErrKeyIsPrivate
101+
}
99102

100103
pub, err := x509.ParsePKIXPublicKey(block.Bytes)
101104
if err != nil {

models/dbfs/dbfs.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
)
1212

13+
/*
14+
The reasons behind the DBFS (database-filesystem) package:
15+
When a Gitea action is running, the Gitea action server should collect and store all the logs.
16+
17+
The requirements are:
18+
* The running logs must be stored across the cluster if the Gitea servers are deployed as a cluster.
19+
* The logs will be archived to Object Storage (S3/MinIO, etc.) after a period of time.
20+
* The Gitea action UI should be able to render the running logs and the archived logs.
21+
22+
Some possible solutions for the running logs:
23+
* [Not ideal] Using local temp file: it can not be shared across the cluster.
24+
* [Not ideal] Using shared file in the filesystem of git repository: although at the moment, the Gitea cluster's
25+
git repositories must be stored in a shared filesystem, in the future, Gitea may need a dedicated Git Service Server
26+
to decouple the shared filesystem. Then the action logs will become a blocker.
27+
* [Not ideal] Record the logs in a database table line by line: it has a couple of problems:
28+
- It's difficult to make multiple increasing sequence (log line number) for different databases.
29+
- The database table will have a lot of rows and be affected by the big-table performance problem.
30+
- It's difficult to load logs by using the same interface as other storages.
31+
- It's difficult to calculate the size of the logs.
32+
33+
The DBFS solution:
34+
* It can be used in a cluster.
35+
* It can share the same interface (Read/Write/Seek) as other storages.
36+
* It's very friendly to database because it only needs to store much fewer rows than the log-line solution.
37+
* In the future, when Gitea action needs to limit the log size (other CI/CD services also do so), it's easier to calculate the log file size.
38+
* Even sometimes the UI needs to render the tailing lines, the tailing lines can be found be counting the "\n" from the end of the file by seek.
39+
The seeking and finding is not the fastest way, but it's still acceptable and won't affect the performance too much.
40+
*/
41+
1342
type dbfsMeta struct {
1443
ID int64 `xorm:"pk autoincr"`
1544
FullPath string `xorm:"VARCHAR(500) UNIQUE NOT NULL"`

0 commit comments

Comments
 (0)