Runway 1.2.0
This commit is contained in:
1 parent
5fa0c1ef9f
commit
9144c206be
90 files changed
+2737
-554
No files matched your search
@@ -2,6 +2,22 @@
|
||||
|
||||
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [2.0.0] — 2026-10-30
|
||||
|
||||
### Upgrade note
|
||||
|
||||
- Install it together with `database` 2.0.0, on Runway 1.2.0 or later, and move the PostgreSQL server's
|
||||
settings into this plugin as the `database` 2.0.0 *Upgrade note* says. On Runway 1.1.x, keep 1.0.0 of both.
|
||||
|
||||
### Changed
|
||||
|
||||
- **This plugin holds the PostgreSQL server's settings**: host, port, database, username, password, TLS and CA
|
||||
certificate, on its own settings page (**Plugins → Database — PostgreSQL → Settings**; file
|
||||
`external/plugin-settings/database-postgresql.yml`, under `runway.plugin.database-postgresql`). Until 2.0.0 they were the `database` plugin's;
|
||||
move them as its 2.0.0 *Upgrade note* says.
|
||||
- Requires `database >= 2.0.0` and Runway SPI 1.2.0 (Runway 1.2.0), whose `PluginSettings.savedApp` hands the saved
|
||||
settings to the database plugin's connection test.
|
||||
|
||||
## [1.0.0] — 2026-10-29
|
||||
|
||||
First public release of `database-postgresql`: the PostgreSQL 14+ provider for the `database` plugin, with the
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
|
||||
Lets the [`database`](../database) plugin use **PostgreSQL 14 or later** (database encoding `UTF8`). It bundles the
|
||||
pgjdbc driver and builds a configured, unpooled `DataSource`; every statement Runway runs is written in the database
|
||||
plugin. Choose it with the database plugin's `provider: postgresql` setting.
|
||||
plugin. Since 2.0.0 it also holds the server's settings: host, port, database, account, password and TLS,
|
||||
on its own settings page (**Plugins → Database — PostgreSQL → Settings**, file `external/plugin-settings/database-postgresql.yml`).
|
||||
With both providers installed, choose this one with the database plugin's `provider: postgresql` setting; with one
|
||||
installed, it is used.
|
||||
|
||||
- **Plugin id:** `database-postgresql` (v`1.0.0`) — install folder `external/plugins/database-postgresql/`
|
||||
- **Requires:** `database >= 1.0.0`, Runway SPI `1.1.0` or later
|
||||
- **Plugin id:** `database-postgresql` (v`2.0.0`) — install folder `external/plugins/database-postgresql/`
|
||||
- **Requires:** `database >= 2.0.0`, Runway SPI `1.2.0` or later (Runway 1.2.0)
|
||||
- **Bundles:** pgjdbc `42.7.10` (BSD-2-Clause) in `lib/`; its license is in `THIRD-PARTY-NOTICES`
|
||||
|
||||
Setup, grants and settings: the kernel's ADMINISTRATION §11.1. Details: [`docs/DATABASE-POSTGRESQL-PLUGIN.md`](docs/DATABASE-POSTGRESQL-PLUGIN.md),
|
||||
Setup, grants and settings: the kernel's ADMINISTRATION §11.1 — step by step, the settings file for a setup
|
||||
without the console, upgrading from 1.x, and a table for when it does not connect. Details: [`docs/DATABASE-POSTGRESQL-PLUGIN.md`](docs/DATABASE-POSTGRESQL-PLUGIN.md),
|
||||
[`CHANGELOG.md`](CHANGELOG.md).
|
||||
@@ -21,3 +21,17 @@ The provider is one bean, `databasePostgresqlProvider`, collected by type. Tests
|
||||
properties for each TLS policy, a real connection when `-Ddb.it.postgresql=host:port` and
|
||||
`-Ddb.it.password-file=…` are set, the bean name, and the linkage scan). End to end:
|
||||
`../database/scripts/verify-against-host.sh` with `PROVIDER=postgresql`.
|
||||
|
||||
## Its settings (since 2.0.0)
|
||||
|
||||
The server's settings are this plugin's own app-level settings (`runway.plugin.database-postgresql.*`, the console's **Plugins →
|
||||
Database — PostgreSQL → Settings**): `host`, `port`, `database`, `username`, `password` (a `secret`, bound to the
|
||||
others), `tls`, `caCertificate`. The provider hands them to the database plugin raw; the database
|
||||
plugin checks every one before use, as before:
|
||||
|
||||
- **running** (`runningSettings()`): bound at startup into a `ProviderSettingsProps` bean
|
||||
(`databasePostgresqlSettings`), the password read in clear with `PluginSettings.appSecret("password")`;
|
||||
- **saved** (`savedSettings()`): read with `PluginSettings.savedApp(key)` (SPI 1.2.0) from the settings file as it is
|
||||
now, for the database plugin's connection test before a restart applies them.
|
||||
|
||||
A `collation` written into this plugin's file by hand is never handed over: it is a MariaDB setting.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Runway Database — PostgreSQL provider — English
|
||||
database-postgresql.group.connection=Server
|
||||
database-postgresql.group.connection.help=The PostgreSQL server Runway keeps plugins' data on. Changes apply after a restart; test them first with the connection tests on the Database plugin's settings page. In a cluster every node needs the same values.
|
||||
database-postgresql.set.host=Host
|
||||
database-postgresql.set.host.help=A host name or an IP address. One server only.
|
||||
database-postgresql.set.port=Port
|
||||
database-postgresql.set.port.help=Leave blank for PostgreSQL's default, 5432.
|
||||
database-postgresql.set.database=Database
|
||||
database-postgresql.set.database.help=An existing database on the server. Runway creates its schemas inside it.
|
||||
database-postgresql.set.username=Username
|
||||
database-postgresql.set.password=Password
|
||||
database-postgresql.set.tls=TLS
|
||||
database-postgresql.set.tls.help=verify-full checks the server's certificate and name. require encrypts without checking who the server is. Use disable only for a database on the same host or a private network you trust.
|
||||
database-postgresql.set.caCertificate=CA certificate (PEM)
|
||||
database-postgresql.set.caCertificate.help=The certificate authority that signed the server's certificate, when the Java trust store does not know it.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Runway Database — PostgreSQL provider — español
|
||||
database-postgresql.group.connection=Servidor
|
||||
database-postgresql.group.connection.help=El servidor PostgreSQL donde Runway guarda los datos de los plugins. Los cambios se aplican al reiniciar; pruébelos antes con las pruebas de conexión de la página de ajustes del plugin Base de datos. En un clúster, todos los nodos necesitan los mismos valores.
|
||||
database-postgresql.set.host=Servidor
|
||||
database-postgresql.set.host.help=Un nombre de host o una dirección IP. Un solo servidor.
|
||||
database-postgresql.set.port=Puerto
|
||||
database-postgresql.set.port.help=Déjelo en blanco para usar el predeterminado de PostgreSQL, 5432.
|
||||
database-postgresql.set.database=Base de datos
|
||||
database-postgresql.set.database.help=Una base de datos existente en el servidor. Runway crea sus esquemas dentro de ella.
|
||||
database-postgresql.set.username=Usuario
|
||||
database-postgresql.set.password=Contraseña
|
||||
database-postgresql.set.tls=TLS
|
||||
database-postgresql.set.tls.help=verify-full comprueba el certificado y el nombre del servidor. require cifra sin comprobar quién es el servidor. Use disable solo para una base de datos en el mismo equipo o en una red privada de confianza.
|
||||
database-postgresql.set.caCertificate=Certificado de la CA (PEM)
|
||||
database-postgresql.set.caCertificate.help=La autoridad que firmó el certificado del servidor, cuando el almacén de confianza de Java no la conoce.
|
||||
@@ -4,16 +4,44 @@
|
||||
# driver (BSD-2-Clause, in lib/) and builds a configured DataSource; every
|
||||
# statement Runway runs is written in the database plugin.
|
||||
#
|
||||
# Choose it with the database plugin's `provider: postgresql` setting.
|
||||
# The server, the account and TLS are set on THIS plugin's settings page
|
||||
# (since 2.0.0); the database plugin keeps the provider choice and the
|
||||
# limits. With both providers installed, choose this one with the database
|
||||
# plugin's `provider: postgresql` setting.
|
||||
#
|
||||
# The install folder name MUST equal this `id`: external/plugins/database-postgresql/.
|
||||
# =============================================================================
|
||||
id: database-postgresql
|
||||
name: Database — PostgreSQL
|
||||
version: 1.0.0
|
||||
version: 2.0.0
|
||||
|
||||
mainClass: mx.quest.database.postgresql.PostgresProviderConfig
|
||||
|
||||
# The database plugin publishes the DatabaseProvider interface this plugin implements.
|
||||
requires: [ "database >= 1.0.0" ]
|
||||
requires: [ "database >= 2.0.0" ]
|
||||
|
||||
requiresSpi: ">=1.1.0"
|
||||
# SPI 1.2.0: PluginSettings.savedApp, which hands the saved settings to the connection test.
|
||||
requiresSpi: ">=1.2.0"
|
||||
|
||||
settingGroups:
|
||||
- { id: connection, label: database-postgresql.group.connection, help: database-postgresql.group.connection.help }
|
||||
|
||||
# Runway-wide settings, applied on RESTART. In a cluster every node needs the same values and the same platform
|
||||
# secret key. Test them before restarting: Plugins -> Database -> Settings, "Connection tests".
|
||||
settings:
|
||||
- { key: host, type: string, group: connection, label: database-postgresql.set.host, help: database-postgresql.set.host.help }
|
||||
- { key: port, type: int, range: "1..65535", group: connection, label: database-postgresql.set.port,
|
||||
help: database-postgresql.set.port.help }
|
||||
- { key: database, type: string, group: connection, label: database-postgresql.set.database,
|
||||
help: database-postgresql.set.database.help }
|
||||
- { key: username, type: string, group: connection, label: database-postgresql.set.username }
|
||||
# Bound to where it goes: changing any of these without typing the password again removes the stored one.
|
||||
- key: password
|
||||
type: secret
|
||||
group: connection
|
||||
label: database-postgresql.set.password
|
||||
secretBoundTo: [host, port, database, username, tls, caCertificate]
|
||||
- { key: tls, type: enum, range: "verify-full,require,disable", default: verify-full, group: connection,
|
||||
label: database-postgresql.set.tls, help: database-postgresql.set.tls.help }
|
||||
- { key: caCertificate, type: text, group: connection, advanced: true, label: database-postgresql.set.caCertificate,
|
||||
help: database-postgresql.set.caCertificate.help }
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<groupId>mx.quest</groupId>
|
||||
<artifactId>runway-plugin-database-postgresql</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>2.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Runway Database — PostgreSQL</name>
|
||||
<licenses>
|
||||
@@ -38,11 +38,11 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Reproducible builds: pins every archive entry's timestamp. Bump at each release. -->
|
||||
<project.build.outputTimestamp>2026-10-29T00:00:00Z</project.build.outputTimestamp>
|
||||
<!-- The runway-spi this plugin compiles against: SPI 1.1.0 adds PluginSettings.appSecret. -->
|
||||
<runway.version>1.1.0</runway.version>
|
||||
<!-- The runway-spi this plugin compiles against: SPI 1.2.0 adds PluginSettings.savedApp. -->
|
||||
<runway.version>1.2.0</runway.version>
|
||||
<!-- The database plugin whose SPI this provider implements (provided: the shared plugin class loader
|
||||
supplies it; install ../database first). -->
|
||||
<database.version>1.0.0</database.version>
|
||||
<database.version>2.0.0</database.version>
|
||||
<!-- The driver bundled in lib/. Pinned so the bundle never drifts from what the notices name. -->
|
||||
<postgresql.version>42.7.10</postgresql.version>
|
||||
</properties>
|
||||
@@ -138,6 +138,9 @@
|
||||
<copy todir="${stage}/lib">
|
||||
<fileset dir="${project.build.directory}/staged-lib"/>
|
||||
</copy>
|
||||
<copy todir="${stage}/i18n">
|
||||
<fileset dir="${project.basedir}/i18n"/>
|
||||
</copy>
|
||||
<!-- Never a plugin zip without its libraries (it would load and fail at its first use). -->
|
||||
<fail message="no library in ${stage}/lib">
|
||||
<condition><resourcecount when="equal" count="0">
|
||||
|
||||
+38
@@ -1,9 +1,12 @@
|
||||
package mx.quest.database.postgresql;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import javax.sql.DataSource;
|
||||
import mx.quest.database.spi.ConnectionSettings;
|
||||
import mx.quest.database.spi.DatabaseProvider;
|
||||
import mx.quest.database.spi.ProviderSettings;
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
import org.postgresql.util.DriverInfo;
|
||||
|
||||
@@ -28,6 +31,25 @@ public final class PostgresProvider implements DatabaseProvider {
|
||||
static final String JVM_TRUST = "org.postgresql.ssl.DefaultJavaSSLFactory";
|
||||
static final String CA_FILE = "org.postgresql.ssl.LibPQFactory";
|
||||
|
||||
private final Supplier<ProviderSettings> running;
|
||||
private final Supplier<ProviderSettings> saved;
|
||||
|
||||
/**
|
||||
* Without settings, as before database 2.0.0: for building data sources only (tests).
|
||||
*/
|
||||
public PostgresProvider() {
|
||||
this(() -> null, () -> null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param running the server settings the application started with, from this plugin's own settings page
|
||||
* @param saved the server settings saved on that page now, which the next restart applies
|
||||
*/
|
||||
public PostgresProvider(Supplier<ProviderSettings> running, Supplier<ProviderSettings> saved) {
|
||||
this.running = Objects.requireNonNull(running, "running");
|
||||
this.saved = Objects.requireNonNull(saved, "saved");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return "postgresql";
|
||||
@@ -76,4 +98,20 @@ public final class PostgresProvider implements DatabaseProvider {
|
||||
private static int seconds(long value) {
|
||||
return (int) Math.max(1, Math.min(Integer.MAX_VALUE, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ProviderSettings> runningSettings() {
|
||||
return Optional.ofNullable(withoutCollation(running.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ProviderSettings> savedSettings() {
|
||||
return Optional.ofNullable(withoutCollation(saved.get()));
|
||||
}
|
||||
|
||||
/** A collation is a MariaDB setting: never handed over from here, even when written into the file by hand. */
|
||||
private static ProviderSettings withoutCollation(ProviderSettings s) {
|
||||
return s == null ? null : new ProviderSettings(s.host(), s.port(), s.database(), s.username(), s.password(),
|
||||
s.tls(), s.caCertificate(), null);
|
||||
}
|
||||
}
|
||||
+22
-3
@@ -1,14 +1,33 @@
|
||||
package mx.quest.database.postgresql;
|
||||
|
||||
import mx.quest.database.spi.ProviderSettings;
|
||||
import mx.quest.database.spi.ProviderSettingsProps;
|
||||
import mx.quest.runway.spi.service.PluginSettings;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/** Registers the PostgreSQL provider; the database plugin collects it by type. */
|
||||
/**
|
||||
* Registers the PostgreSQL provider; the database plugin collects it by type. The server's settings are this plugin's
|
||||
* own app-level settings ({@code runway.plugin.database-postgresql.*}, since database 2.0.0): the running ones as
|
||||
* bound at startup, the password through {@link PluginSettings#appSecret}, and the saved ones through
|
||||
* {@link PluginSettings#savedApp} for the connection test. With both providers installed the context holds two
|
||||
* {@link ProviderSettingsProps} beans, hence the qualifier.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class PostgresProviderConfig {
|
||||
|
||||
@Bean
|
||||
public PostgresProvider databasePostgresqlProvider() {
|
||||
return new PostgresProvider();
|
||||
@ConfigurationProperties("runway.plugin.database-postgresql")
|
||||
public ProviderSettingsProps databasePostgresqlSettings() {
|
||||
return new ProviderSettingsProps();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PostgresProvider databasePostgresqlProvider(
|
||||
@Qualifier("databasePostgresqlSettings") ProviderSettingsProps server, PluginSettings settings) {
|
||||
return new PostgresProvider(() -> server.toSettings(settings.appSecret(ProviderSettings.PASSWORD)),
|
||||
() -> ProviderSettings.read(settings::savedApp));
|
||||
}
|
||||
}
|
||||
+61
-3
@@ -12,14 +12,21 @@ import java.sql.Statement;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import mx.quest.database.spi.ConnectionSettings;
|
||||
import mx.quest.database.spi.ConnectionSettings.Tls;
|
||||
import mx.quest.database.spi.ConnectionSettings;
|
||||
import mx.quest.database.spi.ProviderSettings;
|
||||
import mx.quest.runway.spi.service.PluginSettings;
|
||||
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
|
||||
class PostgresProviderTest {
|
||||
|
||||
@@ -67,15 +74,66 @@ class PostgresProviderTest {
|
||||
assertThat(new PostgresProvider().driverVersion()).isEqualTo("pgjdbc 42.7.10");
|
||||
}
|
||||
|
||||
/** Turns on @ConfigurationProperties binding, as the kernel's context does. */
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties
|
||||
static class Binding {
|
||||
}
|
||||
|
||||
@Test
|
||||
void theConfigurationRegistersOneProviderNamedForThePlugin() {
|
||||
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
PostgresProviderConfig.class)) {
|
||||
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
|
||||
ctx.registerBean(PluginSettings.class, FakePluginSettings::new);
|
||||
ctx.register(Binding.class, PostgresProviderConfig.class);
|
||||
ctx.refresh();
|
||||
assertThat(ctx.getBeanNamesForType(mx.quest.database.spi.DatabaseProvider.class))
|
||||
.containsExactly("databasePostgresqlProvider");
|
||||
for (String name : ctx.getBeanDefinitionNames()) {
|
||||
if ("postgresProviderConfig".equals(ctx.getBeanDefinition(name).getFactoryBeanName())) {
|
||||
assertThat(name).as("bean names carry the plugin id").startsWith("databasePostgresql");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void theServerSettingsAreThisPluginsOwnRunningAndSaved() {
|
||||
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
|
||||
String prefix = "runway.plugin.database-postgresql.";
|
||||
ctx.getEnvironment().getPropertySources().addFirst(new MapPropertySource("test", Map.of(
|
||||
prefix + "host", "db.running", prefix + "port", "6000", prefix + "database", "runway",
|
||||
prefix + "username", "rw", prefix + "password", "ENC(only-the-stored-form)",
|
||||
prefix + "tls", "require", prefix + "collation", "utf8mb4_uca1400_ai_ci",
|
||||
"runway.plugin.database.host", "not-this-plugins")));
|
||||
ctx.registerBean(PluginSettings.class, () -> new FakePluginSettings().appSecret("password", "running-pw")
|
||||
.savedApp("host", "db.saved").savedApp("database", "runway").savedApp("username", "rw2")
|
||||
.savedApp("password", "saved-pw"));
|
||||
ctx.register(Binding.class, PostgresProviderConfig.class);
|
||||
ctx.refresh();
|
||||
PostgresProvider provider = ctx.getBean(PostgresProvider.class);
|
||||
|
||||
ProviderSettings running = provider.runningSettings().orElseThrow();
|
||||
assertThat(running.host()).isEqualTo("db.running");
|
||||
assertThat(running.port()).isEqualTo("6000");
|
||||
assertThat(running.username()).isEqualTo("rw");
|
||||
assertThat(running.tls()).isEqualTo("require");
|
||||
assertThat(running.password()).as("in clear, from appSecret").isEqualTo("running-pw");
|
||||
assertThat(running.collation()).as("a MariaDB setting, never handed over").isNull();
|
||||
|
||||
ProviderSettings saved = provider.savedSettings().orElseThrow();
|
||||
assertThat(saved.host()).isEqualTo("db.saved");
|
||||
assertThat(saved.username()).isEqualTo("rw2");
|
||||
assertThat(saved.password()).isEqualTo("saved-pw");
|
||||
assertThat(saved.port()).as("unsaved: blank, the product's default").isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void withoutSettingsTheProviderSaysNothingAsBeforeTwo() {
|
||||
assertThat(new PostgresProvider().runningSettings()).isEmpty();
|
||||
assertThat(new PostgresProvider().savedSettings()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void theCompiledClassesLinkNoHostInternals() throws Exception {
|
||||
Path classes = Path.of("target", "classes");
|
||||
|
||||
Reference in new issue
Block a user