Skip to content

Commit a8bbb28

Browse files
authored
Make playground module non internal (#150)
1 parent 456e71a commit a8bbb28

26 files changed

+41
-41
lines changed

main.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"strings"
1313
"time"
1414

15-
"github.com/flashbots/builder-playground/internal"
15+
"github.com/flashbots/builder-playground/playground"
1616
"github.com/spf13/cobra"
1717
)
1818

@@ -27,7 +27,7 @@ var logLevelFlag string
2727
var bindExternal bool
2828
var withPrometheus bool
2929
var networkName string
30-
var labels internal.MapStringFlag
30+
var labels playground.MapStringFlag
3131
var disableLogs bool
3232

3333
var rootCmd = &cobra.Command{
@@ -59,23 +59,23 @@ var artifactsCmd = &cobra.Command{
5959
return fmt.Errorf("please specify a service name")
6060
}
6161
serviceName := args[0]
62-
component := internal.FindComponent(serviceName)
62+
component := playground.FindComponent(serviceName)
6363
if component == nil {
6464
return fmt.Errorf("service %s not found", serviceName)
6565
}
66-
releaseService, ok := component.(internal.ReleaseService)
66+
releaseService, ok := component.(playground.ReleaseService)
6767
if !ok {
6868
return fmt.Errorf("service %s is not a release service", serviceName)
6969
}
7070
output := outputFlag
7171
if output == "" {
72-
homeDir, err := internal.GetHomeDir()
72+
homeDir, err := playground.GetHomeDir()
7373
if err != nil {
7474
return fmt.Errorf("failed to get home directory: %w", err)
7575
}
7676
output = homeDir
7777
}
78-
location, err := internal.DownloadRelease(output, releaseService.ReleaseArtifact())
78+
location, err := playground.DownloadRelease(output, releaseService.ReleaseArtifact())
7979
if err != nil {
8080
return fmt.Errorf("failed to download release: %w", err)
8181
}
@@ -92,18 +92,18 @@ var artifactsAllCmd = &cobra.Command{
9292

9393
output := outputFlag
9494
if output == "" {
95-
homeDir, err := internal.GetHomeDir()
95+
homeDir, err := playground.GetHomeDir()
9696
if err != nil {
9797
return fmt.Errorf("failed to get home directory: %w", err)
9898
}
9999
output = homeDir
100100
}
101-
for _, component := range internal.Components {
102-
releaseService, ok := component.(internal.ReleaseService)
101+
for _, component := range playground.Components {
102+
releaseService, ok := component.(playground.ReleaseService)
103103
if !ok {
104104
continue
105105
}
106-
location, err := internal.DownloadRelease(output, releaseService.ReleaseArtifact())
106+
location, err := playground.DownloadRelease(output, releaseService.ReleaseArtifact())
107107
if err != nil {
108108
return fmt.Errorf("failed to download release: %w", err)
109109
}
@@ -138,17 +138,17 @@ var inspectCmd = &cobra.Command{
138138
cancel()
139139
}()
140140

141-
if err := internal.Inspect(ctx, serviceName, connectionName); err != nil {
141+
if err := playground.Inspect(ctx, serviceName, connectionName); err != nil {
142142
return fmt.Errorf("failed to inspect connection: %w", err)
143143
}
144144
return nil
145145
},
146146
}
147147

148-
var recipes = []internal.Recipe{
149-
&internal.L1Recipe{},
150-
&internal.OpRecipe{},
151-
&internal.BuilderNetRecipe{},
148+
var recipes = []playground.Recipe{
149+
&playground.L1Recipe{},
150+
&playground.OpRecipe{},
151+
&playground.BuilderNetRecipe{},
152152
}
153153

154154
func main() {
@@ -168,7 +168,7 @@ func main() {
168168
recipeCmd.Flags().StringArrayVar(&withOverrides, "override", []string{}, "override a service's config")
169169
recipeCmd.Flags().BoolVar(&dryRun, "dry-run", false, "dry run the recipe")
170170
recipeCmd.Flags().BoolVar(&dryRun, "mise-en-place", false, "mise en place mode")
171-
recipeCmd.Flags().Uint64Var(&genesisDelayFlag, "genesis-delay", internal.MinimumGenesisDelay, "")
171+
recipeCmd.Flags().Uint64Var(&genesisDelayFlag, "genesis-delay", playground.MinimumGenesisDelay, "")
172172
recipeCmd.Flags().BoolVar(&interactive, "interactive", false, "interactive mode")
173173
recipeCmd.Flags().DurationVar(&timeout, "timeout", 0, "") // Used for CI
174174
recipeCmd.Flags().StringVar(&logLevelFlag, "log-level", "info", "log level")
@@ -196,8 +196,8 @@ func main() {
196196
}
197197
}
198198

199-
func runIt(recipe internal.Recipe) error {
200-
var logLevel internal.LogLevel
199+
func runIt(recipe playground.Recipe) error {
200+
var logLevel playground.LogLevel
201201
if err := logLevel.Unmarshal(logLevelFlag); err != nil {
202202
return fmt.Errorf("failed to parse log level: %w", err)
203203
}
@@ -222,7 +222,7 @@ func runIt(recipe internal.Recipe) error {
222222
return err
223223
}
224224

225-
svcManager := recipe.Apply(&internal.ExContext{LogLevel: logLevel}, artifacts)
225+
svcManager := recipe.Apply(&playground.ExContext{LogLevel: logLevel}, artifacts)
226226
if err := svcManager.Validate(); err != nil {
227227
return fmt.Errorf("failed to validate manifest: %w", err)
228228
}
@@ -239,7 +239,7 @@ func runIt(recipe internal.Recipe) error {
239239
}
240240

241241
if withPrometheus {
242-
if err := internal.CreatePrometheusServices(svcManager, artifacts.Out); err != nil {
242+
if err := playground.CreatePrometheusServices(svcManager, artifacts.Out); err != nil {
243243
return fmt.Errorf("failed to create prometheus services: %w", err)
244244
}
245245
}
@@ -255,7 +255,7 @@ func runIt(recipe internal.Recipe) error {
255255
}
256256
}
257257

258-
dockerRunner, err := internal.NewLocalRunner(artifacts.Out, svcManager, overrides, interactive, !bindExternal, networkName, labels, !disableLogs)
258+
dockerRunner, err := playground.NewLocalRunner(artifacts.Out, svcManager, overrides, interactive, !bindExternal, networkName, labels, !disableLogs)
259259
if err != nil {
260260
return fmt.Errorf("failed to create docker runner: %w", err)
261261
}
@@ -286,7 +286,7 @@ func runIt(recipe internal.Recipe) error {
286286
portsStr := []string{}
287287
for _, p := range ports {
288288
protocol := ""
289-
if p.Protocol == internal.ProtocolUDP {
289+
if p.Protocol == playground.ProtocolUDP {
290290
protocol = "/udp"
291291
}
292292
portsStr = append(portsStr, fmt.Sprintf("%s: %d/%d%s", p.Name, p.Port, p.HostPort, protocol))
@@ -300,7 +300,7 @@ func runIt(recipe internal.Recipe) error {
300300
return fmt.Errorf("failed to wait for service readiness: %w", err)
301301
}
302302

303-
if err := internal.CompleteReady(dockerRunner.Instances()); err != nil {
303+
if err := playground.CompleteReady(dockerRunner.Instances()); err != nil {
304304
dockerRunner.Stop()
305305
return fmt.Errorf("failed to complete ready: %w", err)
306306
}
@@ -317,7 +317,7 @@ func runIt(recipe internal.Recipe) error {
317317
watchdogErr := make(chan error, 1)
318318
if watchdog {
319319
go func() {
320-
if err := internal.RunWatchdog(artifacts.Out, dockerRunner.Instances()); err != nil {
320+
if err := playground.RunWatchdog(artifacts.Out, dockerRunner.Instances()); err != nil {
321321
watchdogErr <- fmt.Errorf("watchdog failed: %w", err)
322322
}
323323
}()

internal/artifacts.go renamed to playground/artifacts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"bytes"

internal/artifacts_test.go renamed to playground/artifacts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"os"

internal/catalog.go renamed to playground/catalog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
var Components = []ServiceGen{}
44

internal/components.go renamed to playground/components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"context"
File renamed without changes.

internal/genesis_op.go renamed to playground/genesis_op.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"encoding/json"

internal/genesis_op_test.go renamed to playground/genesis_op_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"encoding/json"

internal/inspect.go renamed to playground/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"context"

internal/local_runner.go renamed to playground/local_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"bytes"

internal/manifest.go renamed to playground/manifest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"fmt"

internal/manifest_test.go renamed to playground/manifest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"testing"

internal/recipe_buildernet.go renamed to playground/recipe_buildernet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"fmt"

internal/recipe_l1.go renamed to playground/recipe_l1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"fmt"

internal/recipe_opstack.go renamed to playground/recipe_opstack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
flag "github.com/spf13/pflag"

internal/releases.go renamed to playground/releases.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"archive/tar"

internal/utils.go renamed to playground/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"fmt"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

internal/watchdog.go renamed to playground/watchdog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"context"

internal/watchers.go renamed to playground/watchers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package playground
22

33
import (
44
"context"

0 commit comments

Comments
 (0)