[function] pulsar admin exposes secrets for function
### Motivation
Fixes
### Modifications
add the `--secrets` argument into `pulsar-admin functions create/update/localrun` command
@@ -37,6 +37,7 @@ import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -319,6 +320,8 @@ public class CmdFunctions extends CmdBase {
protected Integer maxMessageRetries;
@Parameter(names = "--custom-runtime-options", description = "A string that encodes options to customize the runtime, see docs for configured runtime for details")
protected String customRuntimeOptions;
+ @Parameter(names = "--secrets", description = "The map of secretName to an object that encapsulates how the secret is fetched by the underlying secrets provider")
+ protected String secretsString;
@Parameter(names = "--dead-letter-topic", description = "The topic where messages that are not processed successfully are sent to")
protected String deadLetterTopic;
protected FunctionConfig functionConfig;
@@ -520,6 +523,15 @@ public class CmdFunctions extends CmdBase {
functionConfig.setCustomRuntimeOptions(customRuntimeOptions);
}
+ if (secretsString != null) {
+ Type type = new TypeToken<Map<String, Object>>() {}.getType();
+ Map<String, Object> secretsMap = new Gson().fromJson(secretsString, type);
+ if (secretsMap == null) {
+ secretsMap = Collections.emptyMap();
+ }
+ functionConfig.setSecrets(secretsMap);
+ }
+
// window configs
WindowConfig windowConfig = functionConfig.getWindowConfig();
if (null != windowLengthCount) {
