use some opts via environment vars

This commit is contained in:
6543 2022-06-10 19:27:03 +02:00
parent a961655d2c
commit a211ecee0d
2 changed files with 16 additions and 4 deletions

View file

@ -31,3 +31,8 @@ pipeline:
detach: true detach: true
commands: commands:
- go test -tags integration codeberg.org/codeberg/pages/integration/... - go test -tags integration codeberg.org/codeberg/pages/integration/...
environment:
- ACME_API=https://acme.mock.directory
- PAGES_DOMAIN=localhost.mock.directory
- RAW_DOMAIN=raw.localhost.mock.directory
- PORT=4430

View file

@ -3,6 +3,7 @@ package integration
import ( import (
"context" "context"
"log" "log"
"os"
"testing" "testing"
"time" "time"
@ -31,11 +32,11 @@ func startServer(ctx context.Context) error {
args := []string{ args := []string{
"--verbose", "--verbose",
"--acme-accept-terms", "true", "--acme-accept-terms", "true",
"--acme-api-endpoint", "https://acme.mock.directory",
"--pages-domain", "localhost.mock.directory",
"--raw-domain", "raw.localhost.mock.directory",
"--port", "4430",
} }
setEnvIfNotSet("ACME_API", "https://acme.mock.directory")
setEnvIfNotSet("PAGES_DOMAIN", "localhost.mock.directory")
setEnvIfNotSet("RAW_DOMAIN", "raw.localhost.mock.directory")
setEnvIfNotSet("PORT", "4430")
app := cli.NewApp() app := cli.NewApp()
app.Name = "pages-server" app.Name = "pages-server"
@ -46,3 +47,9 @@ func startServer(ctx context.Context) error {
return nil return nil
} }
func setEnvIfNotSet(key, value string) {
if _, set := os.LookupEnv(key); !set {
os.Setenv(key, value)
}
}