You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/11/25 02:32:38 UTC

[pulsar] branch master updated: [function] pulsar admin exposes secrets for function (#12950)

This is an automated email from the ASF dual-hosted git repository.

penghui 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 9c0cee9  [function] pulsar admin exposes secrets for function (#12950)
9c0cee9 is described below

commit 9c0cee959e0f215a9a33adca98948f3a5fdf2dfa
Author: Neng Lu <nl...@streamnative.io>
AuthorDate: Wed Nov 24 18:31:45 2021 -0800

    [function] pulsar admin exposes secrets for function (#12950)
    
    ### Motivation
    
    Fixes #12834
    
    ### Modifications
    
    add the `--secrets` argument into `pulsar-admin functions create/update/localrun` command
---
 .../main/java/org/apache/pulsar/admin/cli/CmdFunctions.java  | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
index 0664ca8..2efef99 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
@@ -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) {