From bb7a01f76e6a34db6a371e26dd32a5a69c05c533 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 6 Dec 2022 12:38:36 +0200 Subject: [PATCH] Introduce support for the `uri` file in k8s service binding According to https://github.com/servicebinding/spec#workload-projection, `uri` is part of the standard (cherry picked from commit c205494e02bc5d5a7cede08227bde5cf26ea2138) --- .../DatasourceServiceBindingConfigSourceFactory.java | 11 ++++++++--- .../src/test/resources/k8s-sb/fruit-db/database | 1 - .../src/test/resources/k8s-sb/fruit-db/host | 1 - .../src/test/resources/k8s-sb/fruit-db/port | 1 - .../src/test/resources/k8s-sb/fruit-db/uri | 1 + .../kubernetes-with-auto-postgres-binding.properties | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/database delete mode 100644 integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/host delete mode 100644 integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/port create mode 100644 integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/uri diff --git a/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/DatasourceServiceBindingConfigSourceFactory.java b/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/DatasourceServiceBindingConfigSourceFactory.java index 055d10de9d221..26f6f31dd35ef 100644 --- a/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/DatasourceServiceBindingConfigSourceFactory.java +++ b/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/DatasourceServiceBindingConfigSourceFactory.java @@ -47,9 +47,14 @@ private Map getServiceBindingProperties() { log.debugf("Property 'password' was not found for datasource of type %s", serviceBinding.getType()); } - String url = bindingProperties.get("jdbc-url"); - if (url != null) { - properties.put(urlPropertyName, url); + String jdbcURL = bindingProperties.get("jdbc-url"); + if (jdbcURL != null) { + properties.put(urlPropertyName, jdbcURL); + return properties; + } + String uri = bindingProperties.get("uri"); + if (uri != null) { + properties.put(urlPropertyName, uri); return properties; } diff --git a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/database b/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/database deleted file mode 100644 index 39cd31f5ffa44..0000000000000 --- a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/database +++ /dev/null @@ -1 +0,0 @@ -quarkus_test diff --git a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/host b/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/host deleted file mode 100644 index 2fbb50c4a8dc7..0000000000000 --- a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/host +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/port b/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/port deleted file mode 100644 index 7e30bed39582f..0000000000000 --- a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/port +++ /dev/null @@ -1 +0,0 @@ -5431 diff --git a/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/uri b/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/uri new file mode 100644 index 0000000000000..02dca2d9bc469 --- /dev/null +++ b/integration-tests/kubernetes-service-binding-jdbc/src/test/resources/k8s-sb/fruit-db/uri @@ -0,0 +1 @@ +jdbc:postgresql://localhost:5431/quarkus_test diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-auto-postgres-binding.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-auto-postgres-binding.properties index 3f62f1265363d..ee2a4ec049780 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-auto-postgres-binding.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-auto-postgres-binding.properties @@ -1 +1 @@ -quarkus.datasource.db-kind=postgresql \ No newline at end of file +quarkus.datasource.db-kind=postgresql