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

lhotari pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 39eb995ad4c9 Update functions-develop-security.md with Go example 
(#903)
39eb995ad4c9 is described below

commit 39eb995ad4c96095eee0226767d43d97149795d4
Author: David Rayner <[email protected]>
AuthorDate: Tue Oct 29 07:16:14 2024 +0000

    Update functions-develop-security.md with Go example (#903)
---
 docs/functions-develop-security.md | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/docs/functions-develop-security.md 
b/docs/functions-develop-security.md
index f177d5e97179..a7828c20519e 100644
--- a/docs/functions-develop-security.md
+++ b/docs/functions-develop-security.md
@@ -35,7 +35,7 @@ You can also implement your own `SecretsProviderConfigurator` 
if you want to use
 
 :::note
 
-Currently, only Java and Python runtime support `SecretsProvider`. The Java 
and Python Runtime have the following two providers:
+The Java, Python and Go Runtimes have the following two providers:
 - ClearTextSecretsProvider (default for `DefaultSecretsProviderConfigurator`)
 - EnvironmentBasedSecretsProvider (default for 
`KubernetesSecretsProviderConfigurator`)
 
@@ -48,7 +48,7 @@ Once `SecretsProviderConfigurator` is set, you can get the 
secret using the [`Co
 ````mdx-code-block
 <Tabs groupId="lang-choice"
   defaultValue="Java"
-  
values={[{"label":"Java","value":"Java"},{"label":"Python","value":"Python"}]}>
+  
values={[{"label":"Java","value":"Java"},{"label":"Python","value":"Python"},{"label":"Go","value":"Go"}]}>
 <TabItem value="Java">
 
 ```java
@@ -90,6 +90,26 @@ class GetSecretValueFunction(Function):
             logger.info("The secret {0} has value {1}".format(input, 
secret_value))
 ```
 
+</TabItem>
+<TabItem value="Go">
+
+```go
+func secretLoggerFunc(ctx context.Context, input []byte) {
+    fc, ok := pf.FromContext(ctx)
+    if !ok {
+        logutil.Fatal("Function context is not defined")
+    }
+
+    secretValue := fc.GetSecretValue(string(input))
+
+    if secretValue == nil {
+        logutil.Warnf("No secret with key %s", input)
+    } else {
+        logutil.Infof("The secret %s has value %s", input, secretValue)
+    }
+}
+```
+
 </TabItem>
 </Tabs>
 ````

Reply via email to