This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new c2d52f1 [Issue 9867][scripts] Fixes issue (#9884)
c2d52f1 is described below
commit c2d52f1bbe84f6f111a54dbb7b59eb48e8b4648c
Author: Fernando Miguélez Palomo <[email protected]>
AuthorDate: Tue Mar 23 05:00:44 2021 +0100
[Issue 9867][scripts] Fixes issue (#9884)
Fixes #9867
### Motivation
As described in the issue the script to modify configuration yaml file
(used by functions worker) did not work with array type variables.
This fix allows specifying same values for array properties like
`authenticationProviders` in environment variables (with `PF_` prefix) as the
ones used by `apply-config-from-env.py` for conf files, i.e. a comma separated
list of values.
E.g. You can define environment variable `PF_authenticationProviders`
taking value
`org.apache.pulsar.broker.authentication.AuthenticationProviderTls,org.apache.pulsar.broker.authentication.AuthenticationProviderAthenz`
to specify two values or
`org.apache.pulsar.broker.authentication.AuthenticationProviderTls` to specify
only one. In both cases value will be correctly set in final yaml file as an
array:
```yaml
authenticationProviders:
- org.apache.pulsar.broker.authentication.AuthenticationProviderTls
- org.apache.pulsar.broker.authentication.AuthenticationProviderAthenz
```
### Modifications
We have just added a check on the variable names that have type
`Set<String>` in `WorkerConfig` the same way it is done for `int` variables.
We then split the value using ",", which already produces an array type.
---
docker/pulsar/scripts/gen-yml-from-env.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/docker/pulsar/scripts/gen-yml-from-env.py
b/docker/pulsar/scripts/gen-yml-from-env.py
index 1aa16b47..8aee68b 100755
--- a/docker/pulsar/scripts/gen-yml-from-env.py
+++ b/docker/pulsar/scripts/gen-yml-from-env.py
@@ -37,6 +37,19 @@ INT_KEYS = [
'instanceLivenessCheckFreqMs'
]
+SET_KEYS = [
+ 'brokerInterceptors',
+ 'messagingProtocols',
+ 'tlsProtocols',
+ 'tlsCiphers',
+ 'authenticationProviders',
+ 'superUserRoles',
+ 'proxyRoles',
+ 'schemaRegistryCompatibilityCheckers',
+ 'brokerClientTlsCiphers',
+ 'brokerClientTlsProtocols'
+]
+
PF_ENV_PREFIX = 'PF_'
if len(sys.argv) < 2:
@@ -66,6 +79,8 @@ for conf_filename in conf_files:
if i == (len(key_parts) - 1):
if key_part in INT_KEYS:
conf_to_modify[key_part] = int(v)
+ elif key_part in SET_KEYS:
+ conf_to_modify[key_part] = v.split(',')
else:
conf_to_modify[key_part] = v
modified = True