Skip to content

Commit

Permalink
Update functions-develop-security.md with Go example (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRayner authored Oct 29, 2024
1 parent 3e50887 commit 39eb995
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions docs/functions-develop-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand All @@ -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
Expand Down Expand Up @@ -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>
````

0 comments on commit 39eb995

Please sign in to comment.