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

docs: mention ID property of sdk.Options and its benefits #5876

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/content/integration.md
Expand Up @@ -236,6 +236,7 @@ func main() {

// create an instance of the OPA object
opa, err := sdk.New(ctx, sdk.Options{
ID: "opa-test-1",
Config: bytes.NewReader(config),
})
if err != nil {
Expand All @@ -256,6 +257,10 @@ func main() {
If you executed this code, the output (i.e. [Decision Log](https://www.openpolicyagent.org/docs/latest/management-decision-logs/) event)
would be logged to the console by default.

Setting an `ID` in `sdk.Options` is optional, but recommended. If you do not set an `ID`, a random one will be created
for the system. While this is fine for testing, it makes it difficult to monitor the system over time, as a new ID will
be created each time the SDK is initialized, such as when the process is restarted.

### Integrating with the Go API

Use the low-level
Expand Down
4 changes: 3 additions & 1 deletion sdk/options.go
Expand Up @@ -39,7 +39,9 @@ type Options struct {
// registered with the OPA SDK instance.
Plugins map[string]plugins.Factory

// When calling the sdk the user can specify an opa id so that repeat calls to the sdk don't have a unique opa id
// ID provides an option to set a static ID for the OPA system, avoiding
// the need to generate a random one at initialization. Setting a static ID
// is recommended, as it makes it easier to track the system over time.
ID string

config []byte
Expand Down