From 12259401181b75afac7c4f645b0955433542e3a1 Mon Sep 17 00:00:00 2001
From: Ido David <36866853+ido-namely@users.noreply.github.com>
Date: Fri, 26 Aug 2022 12:28:44 -0400
Subject: [PATCH] Generate gateway files according to source-relative flag
 (#327)

* generate gateway files according to source-relative flag

* restore paralleism
---
 all/entrypoint.sh    |  2 +-
 all/test/all_test.go | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/all/entrypoint.sh b/all/entrypoint.sh
index 9a9545a9..1f30e4dc 100755
--- a/all/entrypoint.sh
+++ b/all/entrypoint.sh
@@ -484,7 +484,7 @@ if [ $GEN_GATEWAY = true ]; then
     mkdir -p ${GATEWAY_DIR}
 
     protoc $PROTO_INCLUDE \
-        --grpc-gateway_out=logtostderr=true:$GATEWAY_DIR ${PROTO_FILES[@]} \
+        --grpc-gateway_out=${GO_SOURCE_RELATIVE}logtostderr=true:$GATEWAY_DIR ${PROTO_FILES[@]} \
         --grpc-gateway_opt generate_unbound_methods=$GENERATE_UNBOUND_METHODS
 
     if [[ $OPENAPI_JSON == true ]]; then
diff --git a/all/test/all_test.go b/all/test/all_test.go
index 68a244a6..728a0094 100644
--- a/all/test/all_test.go
+++ b/all/test/all_test.go
@@ -338,6 +338,21 @@ func (s *TestSuite) TestAllCases() {
 			},
 			extraArgs: []string{"--with-gateway"},
 		},
+		"go with gateway and source_relative": {
+			lang:              "go",
+			protofileName:     "all/test/test.proto",
+			expectedOutputDir: "gen/pb-go",
+			fileExpectations: []FileExpectation{
+				{fileName: "all/test/test.pb.go"},
+				{fileName: "/all/test/test.pb.gw.go", assert: func(filePath, expectedValue string) {
+					fileText := s.readFile(filePath)
+					s.Assert().False(strings.Contains(fileText, expectedValue), "contains \"%s\"", expectedValue)
+				}, expectedValue: "UnboundUnary",
+				},
+				{fileName: "/all/test/test.swagger.json"},
+			},
+			extraArgs: []string{"--with-gateway", "--go-source-relative"},
+		},
 		"go with gateway and json": {
 			lang:              "go",
 			protofileName:     "all/test/test.proto",