mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 13:56:57 +00:00
Merge branch 'main' into feature/lru-cache
This commit is contained in:
commit
044c61dbb6
15 changed files with 121 additions and 67 deletions
|
@ -114,6 +114,23 @@ steps:
|
||||||
- event: ['push']
|
- event: ['push']
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
'Publish PR image':
|
||||||
|
image: woodpeckerci/plugin-docker-buildx:3.2.1
|
||||||
|
depends_on: test
|
||||||
|
settings:
|
||||||
|
registry: codeberg.org
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
repo: codeberg.org/codeberg/pages-server
|
||||||
|
tags: next
|
||||||
|
username:
|
||||||
|
from_secret: bot_user
|
||||||
|
password:
|
||||||
|
from_secret: bot_token
|
||||||
|
when:
|
||||||
|
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_image"'
|
||||||
|
event: pull_request
|
||||||
|
|
||||||
docker-tag:
|
docker-tag:
|
||||||
depends_on: vendor
|
depends_on: vendor
|
||||||
image: woodpeckerci/plugin-docker-buildx:3.2.1
|
image: woodpeckerci/plugin-docker-buildx:3.2.1
|
||||||
|
|
|
@ -8,7 +8,7 @@ when:
|
||||||
steps:
|
steps:
|
||||||
lint:
|
lint:
|
||||||
depends_on: []
|
depends_on: []
|
||||||
image: golangci/golangci-lint:v1.57.2
|
image: golangci/golangci-lint:v1.58.2
|
||||||
commands:
|
commands:
|
||||||
- go version
|
- go version
|
||||||
- go install mvdan.cc/gofumpt@latest
|
- go install mvdan.cc/gofumpt@latest
|
||||||
|
@ -21,14 +21,14 @@ steps:
|
||||||
|
|
||||||
editor-config:
|
editor-config:
|
||||||
depends_on: []
|
depends_on: []
|
||||||
image: mstruebing/editorconfig-checker:2.7.2
|
image: mstruebing/editorconfig-checker:v3.0.1
|
||||||
when:
|
when:
|
||||||
- event: pull_request
|
- event: pull_request
|
||||||
- event: push
|
- event: push
|
||||||
branch: renovate/*
|
branch: renovate/*
|
||||||
|
|
||||||
yamllint:
|
yamllint:
|
||||||
image: pipelinecomponents/yamllint:0.31.1
|
image: pipelinecomponents/yamllint:0.31.2
|
||||||
depends_on: []
|
depends_on: []
|
||||||
commands:
|
commands:
|
||||||
- yamllint .
|
- yamllint .
|
||||||
|
|
|
@ -16,13 +16,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg \
|
--mount=type=cache,target=/go/pkg \
|
||||||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 \
|
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 \
|
||||||
xgo -x -v --targets=${TARGETOS}/${TARGETARCH} -tags='sqlite sqlite_unlock_notify netgo' -ldflags='-s -w -extldflags "-static" -linkmode external' -out pages .
|
xgo -x -v --targets=${TARGETOS}/${TARGETARCH} -tags='sqlite sqlite_unlock_notify netgo' -ldflags='-s -w -extldflags "-static" -linkmode external' -out pages .
|
||||||
|
RUN mv -vf /build/pages-* /go/src/codeberg.org/codeberg/pages/pages
|
||||||
|
|
||||||
# Use a scratch image as the base image for the final container,
|
# Use a scratch image as the base image for the final container,
|
||||||
# which will contain only the built binary and the CA certificates
|
# which will contain only the built binary and the CA certificates
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
# Copy the built binary and the CA certificates from the build container to the final container
|
# Copy the built binary and the CA certificates from the build container to the final container
|
||||||
COPY --from=build /go/src/codeberg.org/codeberg/pages/ /pages
|
COPY --from=build /go/src/codeberg.org/codeberg/pages/pages /pages
|
||||||
COPY --from=build \
|
COPY --from=build \
|
||||||
/etc/ssl/certs/ca-certificates.crt \
|
/etc/ssl/certs/ca-certificates.crt \
|
||||||
/etc/ssl/certs/ca-certificates.crt
|
/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
11
README.md
11
README.md
|
@ -64,6 +64,9 @@ but forward the requests on the IP level to the Pages Server.
|
||||||
You can check out a proof of concept in the `examples/haproxy-sni` folder,
|
You can check out a proof of concept in the `examples/haproxy-sni` folder,
|
||||||
and especially have a look at [this section of the haproxy.cfg](https://codeberg.org/Codeberg/pages-server/src/branch/main/examples/haproxy-sni/haproxy.cfg#L38).
|
and especially have a look at [this section of the haproxy.cfg](https://codeberg.org/Codeberg/pages-server/src/branch/main/examples/haproxy-sni/haproxy.cfg#L38).
|
||||||
|
|
||||||
|
If you want to test a change, you can open a PR and ask for the label `build_pr_image` to be added.
|
||||||
|
This will trigger a build of the PR which will build a docker image to be used for testing.
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
- `HOST` & `PORT` (default: `[::]` & `443`): listen address.
|
- `HOST` & `PORT` (default: `[::]` & `443`): listen address.
|
||||||
|
@ -72,14 +75,14 @@ and especially have a look at [this section of the haproxy.cfg](https://codeberg
|
||||||
- `GITEA_ROOT` (default: `https://codeberg.org`): root of the upstream Gitea instance.
|
- `GITEA_ROOT` (default: `https://codeberg.org`): root of the upstream Gitea instance.
|
||||||
- `GITEA_API_TOKEN` (default: empty): API token for the Gitea instance to access non-public (e.g. limited) repos.
|
- `GITEA_API_TOKEN` (default: empty): API token for the Gitea instance to access non-public (e.g. limited) repos.
|
||||||
- `RAW_INFO_PAGE` (default: <https://docs.codeberg.org/pages/raw-content/>): info page for raw resources, shown if no resource is provided.
|
- `RAW_INFO_PAGE` (default: <https://docs.codeberg.org/pages/raw-content/>): info page for raw resources, shown if no resource is provided.
|
||||||
- `ACME_API` (default: <https://acme-v02.api.letsencrypt.org/directory>): set this to <https://acme.mock.director> to use invalid certificates without any verification (great for debugging).
|
- `ACME_API` (default: <https://acme-v02.api.letsencrypt.org/directory>): set this to <https://acme.mock.director> to use invalid certificates without any verification (great for debugging).
|
||||||
ZeroSSL might be better in the future as it doesn't have rate limits and doesn't clash with the official Codeberg certificates (which are using Let's Encrypt), but I couldn't get it to work yet.
|
ZeroSSL might be better in the future as it doesn't have rate limits and doesn't clash with the official Codeberg certificates (which are using Let's Encrypt), but I couldn't get it to work yet.
|
||||||
- `ACME_EMAIL` (default: `noreply@example.email`): Set the email sent to the ACME API server to receive, for example, renewal reminders.
|
- `ACME_EMAIL` (default: `noreply@example.email`): Set the email sent to the ACME API server to receive, for example, renewal reminders.
|
||||||
- `ACME_EAB_KID` & `ACME_EAB_HMAC` (default: don't use EAB): EAB credentials, for example for ZeroSSL.
|
- `ACME_EAB_KID` & `ACME_EAB_HMAC` (default: don't use EAB): EAB credentials, for example for ZeroSSL.
|
||||||
- `ACME_ACCEPT_TERMS` (default: use self-signed certificate): Set this to "true" to accept the Terms of Service of your ACME provider.
|
- `ACME_ACCEPT_TERMS` (default: use self-signed certificate): Set this to "true" to accept the Terms of Service of your ACME provider.
|
||||||
- `ACME_USE_RATE_LIMITS` (default: true): Set this to false to disable rate limits, e.g. with ZeroSSL.
|
- `ACME_USE_RATE_LIMITS` (default: true): Set this to false to disable rate limits, e.g. with ZeroSSL.
|
||||||
- `ENABLE_HTTP_SERVER` (default: false): Set this to true to enable the HTTP-01 challenge and redirect all other HTTP requests to HTTPS. Currently only works with port 80.
|
- `ENABLE_HTTP_SERVER` (default: false): Set this to true to enable the HTTP-01 challenge and redirect all other HTTP requests to HTTPS. Currently only works with port 80.
|
||||||
- `DNS_PROVIDER` (default: use self-signed certificate): Code of the ACME DNS provider for the main domain wildcard.
|
- `DNS_PROVIDER` (default: use self-signed certificate): Code of the ACME DNS provider for the main domain wildcard.
|
||||||
See <https://go-acme.github.io/lego/dns/> for available values & additional environment variables.
|
See <https://go-acme.github.io/lego/dns/> for available values & additional environment variables.
|
||||||
- `NO_DNS_01` (default: `false`): Disable the use of ACME DNS. This means that the wildcard certificate is self-signed and all domains and subdomains will have a distinct certificate. Because this may lead to a rate limit from the ACME provider, this option is not recommended for Gitea/Forgejo instances with open registrations or a great number of users/orgs.
|
- `NO_DNS_01` (default: `false`): Disable the use of ACME DNS. This means that the wildcard certificate is self-signed and all domains and subdomains will have a distinct certificate. Because this may lead to a rate limit from the ACME provider, this option is not recommended for Gitea/Forgejo instances with open registrations or a great number of users/orgs.
|
||||||
- `LOG_LEVEL` (default: warn): Set this to specify the level of logging.
|
- `LOG_LEVEL` (default: warn): Set this to specify the level of logging.
|
||||||
|
@ -104,7 +107,7 @@ Previous maintainers:
|
||||||
|
|
||||||
### First steps
|
### First steps
|
||||||
|
|
||||||
The code of this repository is split in several modules.
|
The code of this repository is split in several modules.
|
||||||
The [Architecture is explained](https://codeberg.org/Codeberg/pages-server/wiki/Architecture) in the wiki.
|
The [Architecture is explained](https://codeberg.org/Codeberg/pages-server/wiki/Architecture) in the wiki.
|
||||||
|
|
||||||
The `cmd` folder holds the data necessary for interacting with the service via the cli.
|
The `cmd` folder holds the data necessary for interacting with the service via the cli.
|
||||||
|
@ -117,7 +120,7 @@ Thank you very much.
|
||||||
|
|
||||||
Make sure you have [golang](https://go.dev) v1.21 or newer and [just](https://just.systems/man/en/) installed.
|
Make sure you have [golang](https://go.dev) v1.21 or newer and [just](https://just.systems/man/en/) installed.
|
||||||
|
|
||||||
run `just dev`
|
run `just dev`
|
||||||
now these pages should work:
|
now these pages should work:
|
||||||
|
|
||||||
- <https://cb_pages_tests.localhost.mock.directory:4430/images/827679288a.jpg>
|
- <https://cb_pages_tests.localhost.mock.directory:4430/images/827679288a.jpg>
|
||||||
|
|
24
cli/flags.go
24
cli/flags.go
|
@ -22,29 +22,31 @@ var (
|
||||||
|
|
||||||
ServerFlags = append(CertStorageFlags, []cli.Flag{
|
ServerFlags = append(CertStorageFlags, []cli.Flag{
|
||||||
// #############
|
// #############
|
||||||
// ### Gitea ###
|
// ### Forge ###
|
||||||
// #############
|
// #############
|
||||||
// GiteaRoot specifies the root URL of the Gitea instance, without a trailing slash.
|
// ForgeRoot specifies the root URL of the Forge instance, without a trailing slash.
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "gitea-root",
|
Name: "forge-root",
|
||||||
Usage: "specifies the root URL of the Gitea instance, without a trailing slash.",
|
Aliases: []string{"gitea-root"},
|
||||||
EnvVars: []string{"GITEA_ROOT"},
|
Usage: "specifies the root URL of the Forgejo/Gitea instance, without a trailing slash.",
|
||||||
|
EnvVars: []string{"FORGE_ROOT", "GITEA_ROOT"},
|
||||||
},
|
},
|
||||||
// GiteaApiToken specifies an api token for the Gitea instance
|
// ForgeApiToken specifies an api token for the Forge instance
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "gitea-api-token",
|
Name: "forge-api-token",
|
||||||
Usage: "specifies an api token for the Gitea instance",
|
Aliases: []string{"gitea-api-token"},
|
||||||
EnvVars: []string{"GITEA_API_TOKEN"},
|
Usage: "specifies an api token for the Forgejo/Gitea instance",
|
||||||
|
EnvVars: []string{"FORGE_API_TOKEN", "GITEA_API_TOKEN"},
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "enable-lfs-support",
|
Name: "enable-lfs-support",
|
||||||
Usage: "enable lfs support, require gitea >= v1.17.0 as backend",
|
Usage: "enable lfs support, gitea must be version v1.17.0 or higher",
|
||||||
EnvVars: []string{"ENABLE_LFS_SUPPORT"},
|
EnvVars: []string{"ENABLE_LFS_SUPPORT"},
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "enable-symlink-support",
|
Name: "enable-symlink-support",
|
||||||
Usage: "follow symlinks if enabled, require gitea >= v1.18.0 as backend",
|
Usage: "follow symlinks if enabled, gitea must be version v1.18.0 or higher",
|
||||||
EnvVars: []string{"ENABLE_SYMLINK_SUPPORT"},
|
EnvVars: []string{"ENABLE_SYMLINK_SUPPORT"},
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,8 +10,8 @@ rawDomain = 'raw.codeberg.page'
|
||||||
allowedCorsDomains = ['fonts.codeberg.org', 'design.codeberg.org']
|
allowedCorsDomains = ['fonts.codeberg.org', 'design.codeberg.org']
|
||||||
blacklistedPaths = ['do/not/use']
|
blacklistedPaths = ['do/not/use']
|
||||||
|
|
||||||
[gitea]
|
[forge]
|
||||||
root = 'codeberg.org'
|
root = 'https://codeberg.org'
|
||||||
token = 'XXXXXXXX'
|
token = 'XXXXXXXX'
|
||||||
lfsEnabled = true
|
lfsEnabled = true
|
||||||
followSymlinks = true
|
followSymlinks = true
|
||||||
|
|
|
@ -3,7 +3,7 @@ package config
|
||||||
type Config struct {
|
type Config struct {
|
||||||
LogLevel string `default:"warn"`
|
LogLevel string `default:"warn"`
|
||||||
Server ServerConfig
|
Server ServerConfig
|
||||||
Gitea GiteaConfig
|
Forge ForgeConfig
|
||||||
Database DatabaseConfig
|
Database DatabaseConfig
|
||||||
ACME ACMEConfig
|
ACME ACMEConfig
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ type ServerConfig struct {
|
||||||
BlacklistedPaths []string
|
BlacklistedPaths []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type GiteaConfig struct {
|
type ForgeConfig struct {
|
||||||
Root string
|
Root string
|
||||||
Token string
|
Token string
|
||||||
LFSEnabled bool `default:"false"`
|
LFSEnabled bool `default:"false"`
|
||||||
|
|
|
@ -51,7 +51,7 @@ func MergeConfig(ctx *cli.Context, config *Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeServerConfig(ctx, &config.Server)
|
mergeServerConfig(ctx, &config.Server)
|
||||||
mergeGiteaConfig(ctx, &config.Gitea)
|
mergeForgeConfig(ctx, &config.Forge)
|
||||||
mergeDatabaseConfig(ctx, &config.Database)
|
mergeDatabaseConfig(ctx, &config.Database)
|
||||||
mergeACMEConfig(ctx, &config.ACME)
|
mergeACMEConfig(ctx, &config.ACME)
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,12 @@ func mergeServerConfig(ctx *cli.Context, config *ServerConfig) {
|
||||||
config.BlacklistedPaths = append(config.BlacklistedPaths, ALWAYS_BLACKLISTED_PATHS...)
|
config.BlacklistedPaths = append(config.BlacklistedPaths, ALWAYS_BLACKLISTED_PATHS...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeGiteaConfig(ctx *cli.Context, config *GiteaConfig) {
|
func mergeForgeConfig(ctx *cli.Context, config *ForgeConfig) {
|
||||||
if ctx.IsSet("gitea-root") {
|
if ctx.IsSet("forge-root") {
|
||||||
config.Root = ctx.String("gitea-root")
|
config.Root = ctx.String("forge-root")
|
||||||
}
|
}
|
||||||
if ctx.IsSet("gitea-api-token") {
|
if ctx.IsSet("forge-api-token") {
|
||||||
config.Token = ctx.String("gitea-api-token")
|
config.Token = ctx.String("forge-api-token")
|
||||||
}
|
}
|
||||||
if ctx.IsSet("enable-lfs-support") {
|
if ctx.IsSet("enable-lfs-support") {
|
||||||
config.LFSEnabled = ctx.Bool("enable-lfs-support")
|
config.LFSEnabled = ctx.Bool("enable-lfs-support")
|
||||||
|
|
|
@ -110,7 +110,7 @@ func TestValuesReadFromConfigFileShouldBeOverwrittenByArgs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedConfig.LogLevel = "debug"
|
expectedConfig.LogLevel = "debug"
|
||||||
expectedConfig.Gitea.Root = "not-codeberg.org"
|
expectedConfig.Forge.Root = "not-codeberg.org"
|
||||||
expectedConfig.ACME.AcceptTerms = true
|
expectedConfig.ACME.AcceptTerms = true
|
||||||
expectedConfig.Server.Host = "172.17.0.2"
|
expectedConfig.Server.Host = "172.17.0.2"
|
||||||
expectedConfig.Server.BlacklistedPaths = append(expectedConfig.Server.BlacklistedPaths, ALWAYS_BLACKLISTED_PATHS...)
|
expectedConfig.Server.BlacklistedPaths = append(expectedConfig.Server.BlacklistedPaths, ALWAYS_BLACKLISTED_PATHS...)
|
||||||
|
@ -122,7 +122,7 @@ func TestValuesReadFromConfigFileShouldBeOverwrittenByArgs(t *testing.T) {
|
||||||
[]string{
|
[]string{
|
||||||
"--config-file", "assets/test_config.toml",
|
"--config-file", "assets/test_config.toml",
|
||||||
"--log-level", "debug",
|
"--log-level", "debug",
|
||||||
"--gitea-root", "not-codeberg.org",
|
"--forge-root", "not-codeberg.org",
|
||||||
"--acme-accept-terms",
|
"--acme-accept-terms",
|
||||||
"--host", "172.17.0.2",
|
"--host", "172.17.0.2",
|
||||||
},
|
},
|
||||||
|
@ -146,7 +146,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
|
||||||
AllowedCorsDomains: []string{"original"},
|
AllowedCorsDomains: []string{"original"},
|
||||||
BlacklistedPaths: []string{"original"},
|
BlacklistedPaths: []string{"original"},
|
||||||
},
|
},
|
||||||
Gitea: GiteaConfig{
|
Forge: ForgeConfig{
|
||||||
Root: "original",
|
Root: "original",
|
||||||
Token: "original",
|
Token: "original",
|
||||||
LFSEnabled: false,
|
LFSEnabled: false,
|
||||||
|
@ -186,7 +186,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
|
||||||
AllowedCorsDomains: []string{"changed"},
|
AllowedCorsDomains: []string{"changed"},
|
||||||
BlacklistedPaths: append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...),
|
BlacklistedPaths: append([]string{"changed"}, ALWAYS_BLACKLISTED_PATHS...),
|
||||||
},
|
},
|
||||||
Gitea: GiteaConfig{
|
Forge: ForgeConfig{
|
||||||
Root: "changed",
|
Root: "changed",
|
||||||
Token: "changed",
|
Token: "changed",
|
||||||
LFSEnabled: true,
|
LFSEnabled: true,
|
||||||
|
@ -227,9 +227,9 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
|
||||||
"--port", "8443",
|
"--port", "8443",
|
||||||
"--http-port", "443",
|
"--http-port", "443",
|
||||||
"--enable-http-server",
|
"--enable-http-server",
|
||||||
// Gitea
|
// Forge
|
||||||
"--gitea-root", "changed",
|
"--forge-root", "changed",
|
||||||
"--gitea-api-token", "changed",
|
"--forge-api-token", "changed",
|
||||||
"--enable-lfs-support",
|
"--enable-lfs-support",
|
||||||
"--enable-symlink-support",
|
"--enable-symlink-support",
|
||||||
"--default-mime-type", "changed",
|
"--default-mime-type", "changed",
|
||||||
|
@ -366,11 +366,11 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMergeGiteaConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T) {
|
func TestMergeForgeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T) {
|
||||||
runApp(
|
runApp(
|
||||||
t,
|
t,
|
||||||
func(ctx *cli.Context) error {
|
func(ctx *cli.Context) error {
|
||||||
cfg := &GiteaConfig{
|
cfg := &ForgeConfig{
|
||||||
Root: "original",
|
Root: "original",
|
||||||
Token: "original",
|
Token: "original",
|
||||||
LFSEnabled: false,
|
LFSEnabled: false,
|
||||||
|
@ -379,9 +379,9 @@ func TestMergeGiteaConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *test
|
||||||
ForbiddenMimeTypes: []string{"original"},
|
ForbiddenMimeTypes: []string{"original"},
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeGiteaConfig(ctx, cfg)
|
mergeForgeConfig(ctx, cfg)
|
||||||
|
|
||||||
expectedConfig := &GiteaConfig{
|
expectedConfig := &ForgeConfig{
|
||||||
Root: "changed",
|
Root: "changed",
|
||||||
Token: "changed",
|
Token: "changed",
|
||||||
LFSEnabled: true,
|
LFSEnabled: true,
|
||||||
|
@ -395,8 +395,8 @@ func TestMergeGiteaConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *test
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"--gitea-root", "changed",
|
"--forge-root", "changed",
|
||||||
"--gitea-api-token", "changed",
|
"--forge-api-token", "changed",
|
||||||
"--enable-lfs-support",
|
"--enable-lfs-support",
|
||||||
"--enable-symlink-support",
|
"--enable-symlink-support",
|
||||||
"--default-mime-type", "changed",
|
"--default-mime-type", "changed",
|
||||||
|
@ -405,25 +405,25 @@ func TestMergeGiteaConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *test
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMergeGiteaConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgExists(t *testing.T) {
|
func TestMergeForgeConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgExists(t *testing.T) {
|
||||||
type testValuePair struct {
|
type testValuePair struct {
|
||||||
args []string
|
args []string
|
||||||
callback func(*GiteaConfig)
|
callback func(*ForgeConfig)
|
||||||
}
|
}
|
||||||
testValuePairs := []testValuePair{
|
testValuePairs := []testValuePair{
|
||||||
{args: []string{"--gitea-root", "changed"}, callback: func(gc *GiteaConfig) { gc.Root = "changed" }},
|
{args: []string{"--forge-root", "changed"}, callback: func(gc *ForgeConfig) { gc.Root = "changed" }},
|
||||||
{args: []string{"--gitea-api-token", "changed"}, callback: func(gc *GiteaConfig) { gc.Token = "changed" }},
|
{args: []string{"--forge-api-token", "changed"}, callback: func(gc *ForgeConfig) { gc.Token = "changed" }},
|
||||||
{args: []string{"--enable-lfs-support"}, callback: func(gc *GiteaConfig) { gc.LFSEnabled = true }},
|
{args: []string{"--enable-lfs-support"}, callback: func(gc *ForgeConfig) { gc.LFSEnabled = true }},
|
||||||
{args: []string{"--enable-symlink-support"}, callback: func(gc *GiteaConfig) { gc.FollowSymlinks = true }},
|
{args: []string{"--enable-symlink-support"}, callback: func(gc *ForgeConfig) { gc.FollowSymlinks = true }},
|
||||||
{args: []string{"--default-mime-type", "changed"}, callback: func(gc *GiteaConfig) { gc.DefaultMimeType = "changed" }},
|
{args: []string{"--default-mime-type", "changed"}, callback: func(gc *ForgeConfig) { gc.DefaultMimeType = "changed" }},
|
||||||
{args: []string{"--forbidden-mime-types", "changed"}, callback: func(gc *GiteaConfig) { gc.ForbiddenMimeTypes = []string{"changed"} }},
|
{args: []string{"--forbidden-mime-types", "changed"}, callback: func(gc *ForgeConfig) { gc.ForbiddenMimeTypes = []string{"changed"} }},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pair := range testValuePairs {
|
for _, pair := range testValuePairs {
|
||||||
runApp(
|
runApp(
|
||||||
t,
|
t,
|
||||||
func(ctx *cli.Context) error {
|
func(ctx *cli.Context) error {
|
||||||
cfg := GiteaConfig{
|
cfg := ForgeConfig{
|
||||||
Root: "original",
|
Root: "original",
|
||||||
Token: "original",
|
Token: "original",
|
||||||
LFSEnabled: false,
|
LFSEnabled: false,
|
||||||
|
@ -435,7 +435,7 @@ func TestMergeGiteaConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgEx
|
||||||
expectedConfig := cfg
|
expectedConfig := cfg
|
||||||
pair.callback(&expectedConfig)
|
pair.callback(&expectedConfig)
|
||||||
|
|
||||||
mergeGiteaConfig(ctx, &cfg)
|
mergeForgeConfig(ctx, &cfg)
|
||||||
|
|
||||||
expectedConfig.ForbiddenMimeTypes = fixArrayFromCtx(ctx, "forbidden-mime-types", expectedConfig.ForbiddenMimeTypes)
|
expectedConfig.ForbiddenMimeTypes = fixArrayFromCtx(ctx, "forbidden-mime-types", expectedConfig.ForbiddenMimeTypes)
|
||||||
|
|
||||||
|
@ -448,6 +448,33 @@ func TestMergeGiteaConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMergeForgeConfigShouldReplaceValuesGivenGiteaOptionsExist(t *testing.T) {
|
||||||
|
runApp(
|
||||||
|
t,
|
||||||
|
func(ctx *cli.Context) error {
|
||||||
|
cfg := &ForgeConfig{
|
||||||
|
Root: "original",
|
||||||
|
Token: "original",
|
||||||
|
}
|
||||||
|
|
||||||
|
mergeForgeConfig(ctx, cfg)
|
||||||
|
|
||||||
|
expectedConfig := &ForgeConfig{
|
||||||
|
Root: "changed",
|
||||||
|
Token: "changed",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, expectedConfig, cfg)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"--gitea-root", "changed",
|
||||||
|
"--gitea-api-token", "changed",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func TestMergeDatabaseConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T) {
|
func TestMergeDatabaseConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T) {
|
||||||
runApp(
|
runApp(
|
||||||
t,
|
t,
|
||||||
|
|
|
@ -11,7 +11,7 @@ pagesBranches = ["pages"]
|
||||||
allowedCorsDomains = []
|
allowedCorsDomains = []
|
||||||
blacklistedPaths = []
|
blacklistedPaths = []
|
||||||
|
|
||||||
[gitea]
|
[forge]
|
||||||
root = 'https://codeberg.org'
|
root = 'https://codeberg.org'
|
||||||
token = 'ASDF1234'
|
token = 'ASDF1234'
|
||||||
lfsEnabled = true
|
lfsEnabled = true
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -20,7 +20,7 @@ require (
|
||||||
github.com/rs/zerolog v1.27.0
|
github.com/rs/zerolog v1.27.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/urfave/cli/v2 v2.3.0
|
github.com/urfave/cli/v2 v2.3.0
|
||||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
|
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
|
||||||
xorm.io/xorm v1.3.2
|
xorm.io/xorm v1.3.2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
17
go.sum
17
go.sum
|
@ -254,8 +254,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
|
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
|
@ -786,8 +786,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
|
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
||||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
@ -809,8 +809,9 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||||
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
@ -866,8 +867,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||||
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
@ -1001,8 +1003,9 @@ golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef/go.mod h1:EkVYQZoAsY45+roY
|
||||||
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
|
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
|
||||||
|
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|
|
@ -57,12 +57,13 @@ type Client struct {
|
||||||
defaultMimeType string
|
defaultMimeType string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(cfg config.GiteaConfig, respCache cache.ICache) (*Client, error) {
|
func NewClient(cfg config.ForgeConfig, respCache cache.ICache) (*Client, error) {
|
||||||
rootURL, err := url.Parse(cfg.Root)
|
// url.Parse returns valid on almost anything...
|
||||||
|
rootURL, err := url.ParseRequestURI(cfg.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("invalid forgejo/gitea root url: %w", err)
|
||||||
}
|
}
|
||||||
giteaRoot := strings.Trim(rootURL.String(), "/")
|
giteaRoot := strings.TrimSuffix(rootURL.String(), "/")
|
||||||
|
|
||||||
stdClient := http.Client{Timeout: 10 * time.Second}
|
stdClient := http.Client{Timeout: 10 * time.Second}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHandlerPerformance(t *testing.T) {
|
func TestHandlerPerformance(t *testing.T) {
|
||||||
cfg := config.GiteaConfig{
|
cfg := config.ForgeConfig{
|
||||||
Root: "https://codeberg.org",
|
Root: "https://codeberg.org",
|
||||||
Token: "",
|
Token: "",
|
||||||
LFSEnabled: false,
|
LFSEnabled: false,
|
||||||
|
|
|
@ -74,7 +74,7 @@ func Serve(ctx *cli.Context) error {
|
||||||
// clientResponseCache stores responses from the Gitea server
|
// clientResponseCache stores responses from the Gitea server
|
||||||
clientResponseCache := cache.NewInMemoryCache()
|
clientResponseCache := cache.NewInMemoryCache()
|
||||||
|
|
||||||
giteaClient, err := gitea.NewClient(cfg.Gitea, clientResponseCache)
|
giteaClient, err := gitea.NewClient(cfg.Forge, clientResponseCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create new gitea client: %v", err)
|
return fmt.Errorf("could not create new gitea client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue