Since testcontainers-go :material-tag: v0.30.0
The Testcontainers module for OpenFGA.
Please run the following command to add the OpenFGA module to your Go dependencies:
go get github.com/testcontainers/testcontainers-go/modules/openfga
Creating a OpenFGA container inside_block:runOpenFGAContainer
The OpenFGA module exposes one entrypoint function to create the OpenFGA container, and this function receives two parameters:
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*OpenFGAContainer, error)
context.Context
, the Go context.testcontainers.ContainerCustomizer
, a variadic argument for passing options.
When starting the OpenFGA container, you can pass options in a variadic way to configure it.
If you need to set a different OpenFGA Docker image, you can use testcontainers.WithImage
with a valid Docker image
for OpenFGA. E.g. testcontainers.WithImage("openfga/openfga:v1.5.0")
.
{% include "../features/common_functional_options.md" %}
The OpenFGA container exposes the following methods:
This method returns the HTTP endpoint to connect to the OpenFGA container, using the 8080
port.
Get HTTP endpoint inside_block:httpEndpoint
This method returns the gRPC endpoint to connect to the OpenFGA container, using the 8081
port.
In case you want to interact with the openfga playground, please use the PlaygroundEndpoint
method, using the 3000
port.
Get Playground endpoint inside_block:playgroundEndpoint
The following example shows how to write an OpenFGA model using the OpenFGA container.
Get Playground endpoint inside_block:openFGAwriteModel