-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(*) Bundling proto files inside the luarock #8918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ local protoc = require "protoc" | |||||||
local pb = require "pb" | ||||||||
local pl_path = require "pl.path" | ||||||||
local date = require "date" | ||||||||
local loader = require("luarocks.loader") | ||||||||
kikito marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
local bpack = lpack.pack | ||||||||
local bunpack = lpack.unpack | ||||||||
|
@@ -65,9 +66,15 @@ end | |||||||
|
||||||||
function _M.new() | ||||||||
local protoc_instance = protoc.new() | ||||||||
-- Look for the kong/init.lua file because the 'include' folder is a sibling of that. | ||||||||
-- Currently there is not a luarock function to 'give me the root of a luarock', onl | ||||||||
-- 'give me the path to a module in a luarock'. | ||||||||
local kong_init_file, _, _ = loader.which("kong") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||
local kong_include_dir = kong_init_file:gsub("init%.lua$", "include") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overprotective code is not my cup of tea, but this worries me. Two concerns:
My first impulse would be moving this logic to a function in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's go with the assert then.
Suggested change
|
||||||||
assert(kong_include_dir) | ||||||||
-- order by priority | ||||||||
for _, v in ipairs { | ||||||||
"/usr/local/kong/include", | ||||||||
kong_include_dir, | ||||||||
"/usr/local/opt/protobuf/include/", -- homebrew | ||||||||
"/usr/include", | ||||||||
"kong/include", | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,4 +42,22 @@ describe("grpc tools", function() | |||||||||||||||||||||||||||
"Added.Final", | ||||||||||||||||||||||||||||
}, methods) | ||||||||||||||||||||||||||||
end) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
it("includes kong/include in the load path", function() | ||||||||||||||||||||||||||||
local grpc_tools_instance = grpc_tools.new() | ||||||||||||||||||||||||||||
assert.matches("kong/include$", grpc_tools_instance.protoc_instance.paths[3]) | ||||||||||||||||||||||||||||
end) | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test to load the .proto file with pure luarocks loader.
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
-- duplicates how we load .proto files so we have a finer grain test pointing out if that breaks | ||||||||||||||||||||||||||||
it("loads .proto files with luarocks loader", function() | ||||||||||||||||||||||||||||
local loader = require "luarocks.loader" | ||||||||||||||||||||||||||||
local kong_init_file, _, _ = loader.which("kong") | ||||||||||||||||||||||||||||
local kong_include_dir = kong_init_file:gsub("init%.lua$", "include") | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
local protoc = require "protoc" | ||||||||||||||||||||||||||||
local p = protoc.new() | ||||||||||||||||||||||||||||
p.include_imports = true | ||||||||||||||||||||||||||||
p:addpath(kong_include_dir) | ||||||||||||||||||||||||||||
assert(p:loadfile("opentelemetry/proto/collector/trace/v1/trace_service.proto")) | ||||||||||||||||||||||||||||
end) | ||||||||||||||||||||||||||||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on Kong/kong-build-tools#484