Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat][doc] Update functions-develop-security to include a Go example #903

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
````