From 72cd5f911baf767b6a5cfd469bd9cb0b2f4cdcf4 Mon Sep 17 00:00:00 2001 From: Gabriel Parreiras Date: Tue, 20 Aug 2024 12:14:41 +0100 Subject: [PATCH] Allow configurable host that the emulator binds to --- cmd/bigquery-emulator/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/bigquery-emulator/main.go b/cmd/bigquery-emulator/main.go index 0effb880f..b5576ff25 100644 --- a/cmd/bigquery-emulator/main.go +++ b/cmd/bigquery-emulator/main.go @@ -17,6 +17,7 @@ import ( type option struct { Project string `description:"specify the project name" long:"project"` Dataset string `description:"specify the dataset name" long:"dataset"` + Host string `description:"specify the host" long:"host" default:"0.0.0.0"` HTTPPort uint16 `description:"specify the http port number. this port used by bigquery api" long:"port" default:"9050"` GRPCPort uint16 `description:"specify the grpc port number. this port used by bigquery storage api" long:"grpc-port" default:"9060"` LogLevel server.LogLevel `description:"specify the log level (debug/info/warn/error)" long:"log-level" default:"error"` @@ -125,8 +126,8 @@ func runServer(args []string, opt option) error { done := make(chan error) go func() { - httpAddr := fmt.Sprintf("0.0.0.0:%d", opt.HTTPPort) - grpcAddr := fmt.Sprintf("0.0.0.0:%d", opt.GRPCPort) + httpAddr := fmt.Sprintf("%s:%d", opt.Host, opt.HTTPPort) + grpcAddr := fmt.Sprintf("%s:%d", opt.Host, opt.GRPCPort) fmt.Fprintf(os.Stdout, "[bigquery-emulator] REST server listening at %s\n", httpAddr) fmt.Fprintf(os.Stdout, "[bigquery-emulator] gRPC server listening at %s\n", grpcAddr) done <- bqServer.Serve(ctx, httpAddr, grpcAddr)