diff --git a/cmd/zrok/main.go b/cmd/zrok/main.go index d6bfce27..34e20235 100644 --- a/cmd/zrok/main.go +++ b/cmd/zrok/main.go @@ -19,6 +19,7 @@ func init() { adminCmd.AddCommand(adminDeleteCmd) adminCmd.AddCommand(adminListCmd) adminCmd.AddCommand(adminUpdateCmd) + testCmd.AddCommand(loopCmd) rootCmd.AddCommand(adminCmd) rootCmd.AddCommand(configCmd) rootCmd.AddCommand(shareCmd) @@ -72,6 +73,12 @@ var configCmd = &cobra.Command{ Short: "Configure your zrok environment", } +var loopCmd = &cobra.Command{ + Use: "loopback", + Aliases: []string{"loop"}, + Short: "Loopback testing utilities", +} + var shareCmd = &cobra.Command{ Use: "share", Short: "Create backend access for shares", diff --git a/cmd/zrok/loop.go b/cmd/zrok/testLoopPublic.go similarity index 93% rename from cmd/zrok/loop.go rename to cmd/zrok/testLoopPublic.go index 66e2f0e9..da96c138 100644 --- a/cmd/zrok/loop.go +++ b/cmd/zrok/testLoopPublic.go @@ -28,10 +28,10 @@ import ( ) func init() { - testCmd.AddCommand(newLoopCmd().cmd) + loopCmd.AddCommand(newTestLoopPublicCommand().cmd) } -type loopCmd struct { +type testLoopPublicCommand struct { cmd *cobra.Command loopers int iterations int @@ -46,13 +46,13 @@ type loopCmd struct { frontendSelection []string } -func newLoopCmd() *loopCmd { +func newTestLoopPublicCommand() *testLoopPublicCommand { cmd := &cobra.Command{ - Use: "loop", - Short: "Start a loop agent", + Use: "public", + Short: "Start a loop agent testing public proxy shares", Args: cobra.ExactArgs(0), } - r := &loopCmd{cmd: cmd} + r := &testLoopPublicCommand{cmd: cmd} cmd.Run = r.run cmd.Flags().IntVarP(&r.loopers, "loopers", "l", 1, "Number of current loopers to start") cmd.Flags().IntVarP(&r.iterations, "iterations", "i", 1, "Number of iterations per looper") @@ -68,10 +68,10 @@ func newLoopCmd() *loopCmd { return r } -func (r *loopCmd) run(_ *cobra.Command, _ []string) { +func (cmd *testLoopPublicCommand) run(_ *cobra.Command, _ []string) { var loopers []*looper - for i := 0; i < r.loopers; i++ { - l := newLooper(i, r) + for i := 0; i < cmd.loopers; i++ { + l := newLooper(i, cmd) loopers = append(loopers, l) go l.run() } @@ -105,7 +105,7 @@ func (r *loopCmd) run(_ *cobra.Command, _ []string) { type looper struct { id int - cmd *loopCmd + cmd *testLoopPublicCommand env *zrokdir.Environment done chan struct{} listener edge.Listener @@ -122,7 +122,7 @@ type looper struct { stop bool } -func newLooper(id int, cmd *loopCmd) *looper { +func newLooper(id int, cmd *testLoopPublicCommand) *looper { return &looper{ id: id, cmd: cmd,