Skip to content

Commit 25897bd

Browse files
mdelapenyaclaude
andauthored
chore(openfga): use Run function (#3421)
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 3697410 commit 25897bd

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

modules/openfga/openfga.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
4949

5050
// Run creates an instance of the OpenFGA container type
5151
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*OpenFGAContainer, error) {
52-
req := testcontainers.ContainerRequest{
53-
Image: img,
54-
Cmd: []string{"run"},
55-
ExposedPorts: []string{"3000/tcp", "8080/tcp", "8081/tcp"},
56-
WaitingFor: wait.ForAll(
52+
moduleOpts := []testcontainers.ContainerCustomizer{
53+
testcontainers.WithCmd("run"),
54+
testcontainers.WithExposedPorts("3000/tcp", "8080/tcp", "8081/tcp"),
55+
testcontainers.WithWaitStrategy(wait.ForAll(
5756
wait.ForHTTP("/healthz").WithPort("8080/tcp").WithResponseMatcher(func(r io.Reader) bool {
5857
bs, err := io.ReadAll(r)
5958
if err != nil {
@@ -65,28 +64,19 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
6564
wait.ForHTTP("/playground").WithPort("3000/tcp").WithStatusCodeMatcher(func(status int) bool {
6665
return status == http.StatusOK
6766
}),
68-
),
67+
)),
6968
}
7069

71-
genericContainerReq := testcontainers.GenericContainerRequest{
72-
ContainerRequest: req,
73-
Started: true,
74-
}
75-
76-
for _, opt := range opts {
77-
if err := opt.Customize(&genericContainerReq); err != nil {
78-
return nil, fmt.Errorf("customize: %w", err)
79-
}
80-
}
70+
moduleOpts = append(moduleOpts, opts...)
8171

82-
container, err := testcontainers.GenericContainer(ctx, genericContainerReq)
72+
ctr, err := testcontainers.Run(ctx, img, moduleOpts...)
8373
var c *OpenFGAContainer
84-
if container != nil {
85-
c = &OpenFGAContainer{Container: container}
74+
if ctr != nil {
75+
c = &OpenFGAContainer{Container: ctr}
8676
}
8777

8878
if err != nil {
89-
return c, fmt.Errorf("generic container: %w", err)
79+
return c, fmt.Errorf("run openfga: %w", err)
9080
}
9181

9282
return c, nil

0 commit comments

Comments
 (0)