Skip to content

Commit

Permalink
fix(proto) move all proto files to /usr/local/kong/include (#8914)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayocream authored Jun 7, 2022
1 parent 0be32e8 commit 1b37fa7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
File renamed without changes.
6 changes: 0 additions & 6 deletions kong/plugins/opentelemetry/proto.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
local grpc = require "kong.tools.grpc"
local pl_path = require "pl.path"

local abspath = pl_path.abspath
local splitpath = pl_path.splitpath

local proto_fpath = "opentelemetry/proto/collector/trace/v1/trace_service.proto"

local function load_proto()
local grpc_util = grpc.new()
local protoc_instance = grpc_util.protoc_instance

local dir = splitpath(abspath(proto_fpath))
protoc_instance:addpath(dir)
protoc_instance:loadfile(proto_fpath)
end

Expand Down
21 changes: 8 additions & 13 deletions kong/runloop/plugin_servers/pb_rpc.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
local kong_global = require "kong.global"
local cjson = require "cjson.safe"
local protoc = require "protoc"
local grpc_tools = require "kong.tools.grpc"
local pb = require "pb"
local lpack = require "lua_pack"

local ngx = ngx
local kong = kong


local cjson_encode = cjson.encode
local t_unpack = table.unpack -- luacheck: ignore table
local st_pack = lpack.pack
local st_unpack = lpack.unpack

local proto_fname = "kong/pluginsocket.proto"

local Rpc = {}
Rpc.__index = Rpc

Expand Down Expand Up @@ -191,16 +191,11 @@ local function index_table(table, field)
end

local function load_service()
local p = protoc.new()
p:addpath("/usr/include")
p:addpath("/usr/local/opt/protobuf/include")
p:addpath("/usr/local/kong/lib")
p:addpath("kong")
p:addpath("spec/fixtures/grpc")
p.include_imports = true

p:loadfile("pluginsocket.proto")
local parsed = p:parsefile("pluginsocket.proto")
local p = grpc_tools.new()
local protoc_instance = p.protoc_instance

protoc_instance:loadfile(proto_fname)
local parsed = protoc_instance:parsefile(proto_fname)

local service = {}
for i, s in ipairs(parsed.service) do
Expand Down
6 changes: 3 additions & 3 deletions kong/tools/grpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ end

function _M.new()
local protoc_instance = protoc.new()
-- order by priority
for _, v in ipairs {
"/usr/local/kong/include",
"/usr/local/opt/protobuf/include/", -- homebrew
"/usr/include",
"/usr/local/opt/protobuf/include/",
"/usr/local/kong/lib/",
"kong",
"kong/include",
"spec/fixtures/grpc",
} do
Expand Down
3 changes: 0 additions & 3 deletions kong/tools/wrpc/proto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ local _MT = { __index = _M, }

local wrpc_proto_name = "wrpc.wrpc"

local default_proto_path = { "kong/include/", "/usr/include/", }

local function parse_annotation(annotation)
local parsed = {}
for kv_pair in annotation:gmatch("[^;]+=[^;]+") do
Expand Down Expand Up @@ -81,7 +79,6 @@ function _M.new()
name_to_mthd = {},
}, _MT)

proto_instance:addpath(default_proto_path)
proto_instance:import(wrpc_proto_name)
return proto_instance
end
Expand Down

0 comments on commit 1b37fa7

Please sign in to comment.