aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2023-04-24 11:50:37 +0100
committerGitHub <noreply@github.com>2023-04-24 11:50:37 +0100
commit4679098a6415ea8bfb7728ddafa587780849c059 (patch)
tree3d79888665972179fcb778f7a5f550f5c5b9d410
parent1647213facae52e2c8889fbc848ffc5d3a5792f0 (diff)
Use IRoomVersion (#3064)
This is a step towards allowing arbitrary room version impls.
-rw-r--r--clientapi/clientapi_test.go2
-rw-r--r--clientapi/routing/capabilities.go2
-rw-r--r--cmd/dendrite-upgrade-tests/main.go16
-rw-r--r--federationapi/routing/invite.go1
-rw-r--r--go.mod2
-rw-r--r--go.sum12
-rw-r--r--roomserver/version/version.go10
7 files changed, 25 insertions, 20 deletions
diff --git a/clientapi/clientapi_test.go b/clientapi/clientapi_test.go
index 0be26273..b6fb42a7 100644
--- a/clientapi/clientapi_test.go
+++ b/clientapi/clientapi_test.go
@@ -909,7 +909,7 @@ func TestCapabilities(t *testing.T) {
// construct the expected result
versionsMap := map[gomatrixserverlib.RoomVersion]string{}
for v, desc := range version.SupportedRoomVersions() {
- if desc.Stable {
+ if desc.Stable() {
versionsMap[v] = "stable"
} else {
versionsMap[v] = "unstable"
diff --git a/clientapi/routing/capabilities.go b/clientapi/routing/capabilities.go
index e6c1a9b8..fa50fa1a 100644
--- a/clientapi/routing/capabilities.go
+++ b/clientapi/routing/capabilities.go
@@ -27,7 +27,7 @@ import (
func GetCapabilities() util.JSONResponse {
versionsMap := map[gomatrixserverlib.RoomVersion]string{}
for v, desc := range version.SupportedRoomVersions() {
- if desc.Stable {
+ if desc.Stable() {
versionsMap[v] = "stable"
} else {
versionsMap[v] = "unstable"
diff --git a/cmd/dendrite-upgrade-tests/main.go b/cmd/dendrite-upgrade-tests/main.go
index 6a0e2179..dcc45bdc 100644
--- a/cmd/dendrite-upgrade-tests/main.go
+++ b/cmd/dendrite-upgrade-tests/main.go
@@ -55,7 +55,7 @@ var latest, _ = semver.NewVersion("v6.6.6") // Dummy version, used as "HEAD"
// due to the error:
// When using COPY with more than one source file, the destination must be a directory and end with a /
// We need to run a postgres anyway, so use the dockerfile associated with Complement instead.
-const DockerfilePostgreSQL = `FROM golang:1.18-stretch as build
+const DockerfilePostgreSQL = `FROM golang:1.18-buster as build
RUN apt-get update && apt-get install -y postgresql
WORKDIR /build
ARG BINARY
@@ -72,18 +72,18 @@ RUN ./generate-config --ci > dendrite.yaml
RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key
# Replace the connection string with a single postgres DB, using user/db = 'postgres' and no password
-RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml
+RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml
# No password when connecting over localhost
-RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/9.6/main/pg_hba.conf
+RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/11/main/pg_hba.conf
# Bump up max conns for moar concurrency
-RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/9.6/main/postgresql.conf
+RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/11/main/postgresql.conf
RUN sed -i 's/max_open_conns:.*$/max_open_conns: 100/g' dendrite.yaml
# This entry script starts postgres, waits for it to be up then starts dendrite
RUN echo '\
#!/bin/bash -eu \n\
pg_lsclusters \n\
-pg_ctlcluster 9.6 main start \n\
+pg_ctlcluster 11 main start \n\
\n\
until pg_isready \n\
do \n\
@@ -101,7 +101,7 @@ ENV BINARY=dendrite
EXPOSE 8008 8448
CMD /build/run_dendrite.sh`
-const DockerfileSQLite = `FROM golang:1.18-stretch as build
+const DockerfileSQLite = `FROM golang:1.18-buster as build
RUN apt-get update && apt-get install -y postgresql
WORKDIR /build
ARG BINARY
@@ -119,7 +119,7 @@ RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key
# Make sure the SQLite databases are in a persistent location, we're already mapping
# the postgresql folder so let's just use that for simplicity
-RUN sed -i "s%connection_string:.file:%connection_string: file:\/var\/lib\/postgresql\/9.6\/main\/%g" dendrite.yaml
+RUN sed -i "s%connection_string:.file:%connection_string: file:\/var\/lib\/postgresql\/11\/main\/%g" dendrite.yaml
# This entry script starts postgres, waits for it to be up then starts dendrite
RUN echo '\
@@ -402,7 +402,7 @@ func runImage(dockerClient *client.Client, volumeName string, branchNameToImageI
{
Type: mount.TypeVolume,
Source: volumeName,
- Target: "/var/lib/postgresql/9.6/main",
+ Target: "/var/lib/postgresql/11/main",
},
},
}, nil, nil, "dendrite_upgrade_test_"+branchName)
diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go
index b13e59f0..88071892 100644
--- a/federationapi/routing/invite.go
+++ b/federationapi/routing/invite.go
@@ -77,6 +77,7 @@ func InviteV1(
) util.JSONResponse {
roomVer := gomatrixserverlib.RoomVersionV1
body := request.Content()
+ // roomVer is hardcoded to v1 so we know we won't panic on Must
event, err := gomatrixserverlib.MustGetRoomVersion(roomVer).NewEventFromTrustedJSON(body, false)
switch err.(type) {
case gomatrixserverlib.BadJSONError:
diff --git a/go.mod b/go.mod
index bff99dc1..75320aa6 100644
--- a/go.mod
+++ b/go.mod
@@ -22,7 +22,7 @@ require (
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
- github.com/matrix-org/gomatrixserverlib v0.0.0-20230421153744-40a91492619e
+ github.com/matrix-org/gomatrixserverlib v0.0.0-20230424084733-070fb6767374
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
github.com/mattn/go-sqlite3 v1.14.16
diff --git a/go.sum b/go.sum
index 70995a93..71950c1b 100644
--- a/go.sum
+++ b/go.sum
@@ -339,10 +339,14 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20230420172450-7ea8ead4a832 h1:xE
github.com/matrix-org/gomatrixserverlib v0.0.0-20230420172450-7ea8ead4a832/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
github.com/matrix-org/gomatrixserverlib v0.0.0-20230421103805-98f1fbf26443 h1:UxYdP/B+wN67pOWpvzlNeASMn9K1reF/bPHFo1wpqXQ=
github.com/matrix-org/gomatrixserverlib v0.0.0-20230421103805-98f1fbf26443/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
-github.com/matrix-org/gomatrixserverlib v0.0.0-20230421152946-4e6e880889e3 h1:+svc0Md8R2SYlcJu45NR+/JO1aYzMrMAi7rGLS1UfsM=
-github.com/matrix-org/gomatrixserverlib v0.0.0-20230421152946-4e6e880889e3/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
-github.com/matrix-org/gomatrixserverlib v0.0.0-20230421153744-40a91492619e h1:lGhoTgpiLYPkVIAHOW/7itugzkLWs81tNlpHI6bhT5I=
-github.com/matrix-org/gomatrixserverlib v0.0.0-20230421153744-40a91492619e/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421124419-d1e66b713adc h1:MBbfplk/2QE6i3ylkSVnn3eZ6DUlmftn6aF1fyBwiF4=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421124419-d1e66b713adc/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421161959-65453e03e060 h1:LsP+VWtl+jKfvramnoL9HK2A+n1RLpIXpHsWyWLrlcQ=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421161959-65453e03e060/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421163103-6550f4f6d63a h1:aj2f5OtVYMmO2UWx622B/KRNGtAWdXO2q8AYGxw8+6M=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230421163103-6550f4f6d63a/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230424084733-070fb6767374 h1:ZZPQN31NKW1Rbpvmz2D6QF6l70vmQAQMEs0p+wjmS2E=
+github.com/matrix-org/gomatrixserverlib v0.0.0-20230424084733-070fb6767374/go.mod h1:7HTbSZe+CIdmeqVyFMekwD5dFU8khWQyngKATvd12FU=
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
diff --git a/roomserver/version/version.go b/roomserver/version/version.go
index 7ede3c98..270d4289 100644
--- a/roomserver/version/version.go
+++ b/roomserver/version/version.go
@@ -28,31 +28,31 @@ func DefaultRoomVersion() gomatrixserverlib.RoomVersion {
// RoomVersions returns a map of all known room versions to this
// server.
-func RoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.RoomVersionImpl {
+func RoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.IRoomVersion {
return gomatrixserverlib.RoomVersions()
}
// SupportedRoomVersions returns a map of descriptions for room
// versions that are supported by this homeserver.
-func SupportedRoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.RoomVersionImpl {
+func SupportedRoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.IRoomVersion {
return gomatrixserverlib.RoomVersions()
}
// RoomVersion returns information about a specific room version.
// An UnknownVersionError is returned if the version is not known
// to the server.
-func RoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.RoomVersionImpl, error) {
+func RoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.IRoomVersion, error) {
if version, ok := gomatrixserverlib.RoomVersions()[version]; ok {
return version, nil
}
- return gomatrixserverlib.RoomVersionImpl{}, UnknownVersionError{version}
+ return nil, UnknownVersionError{version}
}
// SupportedRoomVersion returns information about a specific room
// version. An UnknownVersionError is returned if the version is not
// known to the server, or an UnsupportedVersionError is returned if
// the version is known but specifically marked as unsupported.
-func SupportedRoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.RoomVersionImpl, error) {
+func SupportedRoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.IRoomVersion, error) {
return RoomVersion(version)
}