This is an automated email from the ASF dual-hosted git repository.
mmarshall pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 67b1fe86e01 [fix][fn] TLS args admin download command use zero arity
(#20513)
67b1fe86e01 is described below
commit 67b1fe86e016f9fa92d9fbfbd911f0a0d3e5e6b2
Author: Michael Marshall <[email protected]>
AuthorDate: Tue Jun 6 21:46:46 2023 -0500
[fix][fn] TLS args admin download command use zero arity (#20513)
### Motivation
#20482 broke the function download command with this error:
```
Expected a command, got false
Usage: pulsar-admin [options] [command] [command options]
Options:
--admin-url
Admin Service URL to which to connect.
Default: http://localhost:8080/
```
The problem is that the TLS args for hostname verification and for insecure
TLS are zero arity, and therefore, we should not add the `false` or the `true`
arguments.
### Modifications
* Correct the changes made to the TLS args passed to the `pulsar-admin` CLI
tool
### Documentation
- [x] `doc-not-needed`
(cherry picked from commit 50b9a93e42e412d9f17b1637287d1a4c7c7ab148)
---
.../functions/runtime/kubernetes/KubernetesRuntime.java | 11 ++++++-----
.../functions/runtime/kubernetes/KubernetesRuntimeTest.java | 4 +---
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git
a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
index 7779422965b..36c5a17ee65 100644
---
a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
+++
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
@@ -885,11 +885,12 @@ public class KubernetesRuntime implements Runtime {
"--auth-params",
authConfig.getClientAuthenticationParameters()));
}
- cmd.addAll(Arrays.asList(
- "--tls-allow-insecure",
-
Boolean.toString(authConfig.isTlsAllowInsecureConnection()),
- "--tls-enable-hostname-verification",
-
Boolean.toString(authConfig.isTlsHostnameVerificationEnable())));
+ if (authConfig.isTlsAllowInsecureConnection()) {
+ cmd.add("--tls-allow-insecure");
+ }
+ if (authConfig.isTlsHostnameVerificationEnable()) {
+ cmd.add("--tls-enable-hostname-verification");
+ }
if (isNotBlank(authConfig.getTlsTrustCertsFilePath())) {
cmd.addAll(Arrays.asList(
"--tls-trust-cert-path",
diff --git
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
index 2cbbeb8a00b..31f82adfe8c 100644
---
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
+++
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
@@ -852,7 +852,6 @@ public class KubernetesRuntimeTest {
V1StatefulSet spec = container.createStatefulSet();
String expectedDownloadCommand = "pulsar-admin --admin-url " +
pulsarAdminUrl
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\":
\"authParamValue1\"}"
- + " --tls-allow-insecure false
--tls-enable-hostname-verification false"
+ " functions download "
+ "--tenant " + TEST_TENANT
+ " --namespace " + TEST_NAMESPACE
@@ -879,7 +878,6 @@ public class KubernetesRuntimeTest {
V1StatefulSet spec = container.createStatefulSet();
String expectedDownloadCommand = "pulsar-admin --admin-url " +
pulsarAdminUrl
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\":
\"authParamValue1\"}"
- + " --tls-allow-insecure false
--tls-enable-hostname-verification false"
+ " functions download "
+ "--tenant " + TEST_TENANT
+ " --namespace " + TEST_NAMESPACE
@@ -909,7 +907,7 @@ public class KubernetesRuntimeTest {
V1StatefulSet spec = container.createStatefulSet();
String expectedDownloadCommand = "pulsar-admin --admin-url " +
pulsarAdminUrl
+ " --auth-plugin com.MyAuth --auth-params {\"authParam1\":
\"authParamValue1\"}"
- + " --tls-allow-insecure false
--tls-enable-hostname-verification true"
+ + " --tls-enable-hostname-verification"
+ " --tls-trust-cert-path /my/ca.pem"
+ " functions download "
+ "--tenant " + TEST_TENANT