From 154bdf9d2ee19e584fdb491fd5cb874832bb00c0 Mon Sep 17 00:00:00 2001 From: Marek Kopecky Date: Tue, 10 Sep 2024 09:02:42 +0200 Subject: [PATCH] Introduce server version detection in AddDatasource offline command --- .../creaper/commands/datasources/AddDataSource.java | 2 ++ .../commands/datasources/AddDataSource.groovy | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/commands/src/main/java/org/wildfly/extras/creaper/commands/datasources/AddDataSource.java b/commands/src/main/java/org/wildfly/extras/creaper/commands/datasources/AddDataSource.java index f752b1e7..c04562d0 100644 --- a/commands/src/main/java/org/wildfly/extras/creaper/commands/datasources/AddDataSource.java +++ b/commands/src/main/java/org/wildfly/extras/creaper/commands/datasources/AddDataSource.java @@ -295,6 +295,8 @@ public final void apply(OfflineCommandContext ctx) throws CommandFailedException .parameter("enableAfterCreation", enableAfterCreation) .parameter("replaceExisting", replaceExisting) + .parameter("serverVersion", ctx.version) + .build(); ctx.client.apply(transform); diff --git a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy index f8306ba9..ef8c9ed3 100644 --- a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy +++ b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy @@ -1,3 +1,5 @@ +import org.wildfly.extras.creaper.core.ServerVersion + // attributes of datasourceAttrs = ['pool-name': poolName] if (nn(jta)) datasourceAttrs['jta'] = jta @@ -45,9 +47,15 @@ def dsDefinition = { } if (nn(userName, password, securityDomain)) { securityAttrs = [:] - if (nn(userName)) securityAttrs['user-name'] = userName - if (nn(password)) securityAttrs['password'] = password + if (serverVersion.greaterThanOrEqualTo(ServerVersion.VERSION_23_0_0)) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) securityAttrs['user-name'] = userName + if (nn(password)) securityAttrs['password'] = password + } security(securityAttrs) { + if (serverVersion.lessThan(ServerVersion.VERSION_23_0_0)) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) 'user-name'(userName) + if (nn(password)) 'password'(password) + } if (nn(securityDomain)) 'security-domain'(securityDomain) } }