Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#40: Read driver version from plugin yaml #44

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/changes/changes_1.0.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ Note: During implementation of #35 and #41 the logging of the version for the dr
* #38: Adapted driver to Metabase version 0.43.0
* #35: Migrated build system to deps.edn and adapted driver to Metabase version 0.43.1
* #41: Removed Exasol JDBC driver from built driver jar

## Bugfixes

* #40: Implemented reading driver version from metabase-plugin.yaml
14 changes: 11 additions & 3 deletions src/metabase/driver/exasol.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns metabase.driver.exasol
(:require [clojure.tools.logging :as log]
(:require [clojure.java.io :as io]
[clojure.tools.logging :as log]
[honeysql.core :as hsql]
[honeysql.format :as hformat]
[java-time :as t]
Expand All @@ -16,14 +17,21 @@
[metabase.driver.sql.util.unprepare :as unprepare]
[metabase.util :as u]
[metabase.util.honeysql-extensions :as hx]
[metabase.util.i18n :refer [trs]]))
[metabase.util.i18n :refer [trs]]
[yaml.core :as yaml]))

(defn get-jdbc-driver-version []
"(unknown)") ; Will be implemented in https://github.com/exasol/metabase-driver/issues/43

(defn get-driver-version
"Reads the driver version from the plugin yaml file on the classpath."
([]
"(unknown)")) ; Will be implemented in https://github.com/exasol/metabase-driver/issues/40
(get-driver-version "metabase-plugin.yaml"))
([resource-name]
(when-let [resource (io/resource resource-name)]
(let [content (slurp resource)
parsed-yaml (yaml/parse-string content)]
(get-in parsed-yaml [:info :version])))))

(defn- log-driver-version []
(log/info (u/format-color 'green (format "Loading Exasol Metabase driver %s, Exasol JDBC driver: %s"
Expand Down
6 changes: 5 additions & 1 deletion test/metabase/driver/exasol_unit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@
(is (not (str/blank? (exasol/get-jdbc-driver-version))))))

(deftest get-driver-version-test
(testing "Reading driver version from non existing resource returns nil"
(is (= nil (exasol/get-driver-version "non-existing-resource.yaml"))))
(testing "Driver version read from existing resource"
(is (not (str/blank? (exasol/get-driver-version))))))
(is (not (str/blank? (exasol/get-driver-version)))))
(testing "Driver version read from existing resource equal to expected version"
(is (= "1.0.1" (exasol/get-driver-version)))))

(deftest humanize-connection-error-message-test
(testing "Driver translates connection error message"
Expand Down