~bigbes/core-go

f0b0e702 — Conrad Hoffmann 1 year, 2 months ago
Add sourcehut-migrate, a unified DB migration tool

This tool will replace both the old `srht-migrate` as well as all
`<SERVICE>-migrate` tools, but services need to be migrated over to it
one by one. This tool is based on brant [1].

Invocation in both production and development can be as simple as:

    sourcehut-migrate <SERVICE> up

The tool will read a config like a regular service (first in ., then
/etc/sr.ht, etc.). The database connection details are taken from the
config. To facilitate development, the tool will check if a folder
./migrations exists; if it does, migrations will be loaded from there.
If no ./migrations folder was found, it will look for migrations in
`<ASSETS>/migrations/<SERVICE>`, where <ASSETS> is also taken from the
config, with a default of `/usr/share/sourcehut`.

For an explanation of the available commands, see brant [1].

This tool also supports a simple command to initialize a newly created
database to the current version (much like the `<SERVICE>-initdb` tools
used to):

    sourcehut-migrate <SERVICE> stamp head

will automatically set the database version to whatever the latest
available migration version is.

[1]: https://git.sr.ht/~bitfehler/brant
bdb0f7e8 — Drew DeVault 1 year, 1 month ago
server: disable logging for release mode

This was partially implemented a while ago but we missed the main point
where it matters.
c1d572b5 — Conrad Hoffmann 1 year, 3 months ago
config: add GetBool convenience method

It's the boolean equivalent of `GetInt()`. The value handling is taken
from the Python version (`srht.config.cfgb()`).
55ab6c4b — Simon Martin 1 year, 4 months ago
config: add missing private ip ranges

I noticed that 172.16.0.0/12 is missing from the default private IP
address space; following a quick discussion in [1], this patches adds
it, as well as link local ranges.

[1] https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3C20241218140750.2393901-1-robin@jarry.cc%3E

Fixes: deb699c9d01a ("add global internal-ipnet setting")
Signed-off-by: Simon Martin <simon@nasilyan.com>
29a3ebfe — Taavi Väänänen 1 year, 4 months ago
errors: Fix ErrUnsupported error code
d89f65e8 — Drew DeVault 1 year, 4 months ago
errors.Field: return the error
79dad627 — Drew DeVault 1 year, 4 months ago
server: add pprof endpoint

This adds a pprof endpoint to all SourceHut APIs. It picks an
OS-assigned port on localhost to run it on and prints this port to
stdout. This ensures a unique port is selected even if several APIs are
running on a single host.
Allow unix scheme for redis url

Recently, the logic for creating redis client
has been changed and mistakenly unix scheme
has been removed from supported schemes.
1e3cd785 — Drew DeVault 1 year, 5 months ago
errors: add ERR_UNSUPPORTED
0bea6849 — Drew DeVault 1 year, 5 months ago
server: enable request logging only in debug mode

To improve the signal:noise ratio in the production logs.
8e729e75 — Drew DeVault 1 year, 5 months ago
errors: new module for common GQL errors

This package provides a means of creating GraphQL-aware errors and
a location for common error codes.
dbdf194f — Conrad Hoffmann 1 year, 5 months ago
email/worker: catch some PGP error earlier

The writer returned by pgpmail.Encryption() will have the keyring
parsed, but it only tries to determine the encryption key once it is
being written to. Hence, certain errors will only occur later on, when
it is too late to fall back to unencrypted email.

Catch these errors earlier by checking if a valid encryption key is
found.
redis: avoid building UniversalOptions for standard mode

This makes it support all options that go-redis recognizes in ParseURL,
by constructing a standard client directly instead of building
UniversalOptions ourselves.
293ca65a — Conrad Hoffmann 1 year, 5 months ago
auth: fix middleware tests

They got broken with 6eae2199 because the tests cannot use
`config.LoadConfig`, so the list of internal IP nets never gets
populated.
server/email: print correct var on type assertion failure
c3d11991 — Drew DeVault 1 year, 6 months ago
webhooks: fix filter for internal auth
e4b0261f — Drew DeVault 1 year, 6 months ago
Export webhooks public key via api-meta.json
d3f7b91a — Drew DeVault 1 year, 6 months ago
webhooks: implement internal webhook users

AUTH_INTERNAL requests previously could not register webhooks. This
commit adds the necessary changes to allow for this.
465a6f71 — Drew DeVault 1 year, 6 months ago
all: pass errors to panic, not strings

GraphQL's recovery middleware can't handle strings so it just logs a
very not useful <nil>
Next