Skip to content

Commit 78b476d

Browse files
AndyZhang0707kikito
authored andcommitted
chore(version) added Kong open source version 3.7.0 artifacts
1 parent 830f53c commit 78b476d

File tree

428 files changed

+56489
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+56489
-0
lines changed

kong-versions/3.7.0/kong/Makefile

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
OS := $(shell uname | awk '{print tolower($$0)}')
2+
MACHINE := $(shell uname -m)
3+
4+
DEV_ROCKS = "busted 2.2.0" "busted-hjtest 0.0.5" "luacheck 1.1.2" "lua-llthreads2 0.1.6" "ldoc 1.5.0" "luacov 0.15.0"
5+
WIN_SCRIPTS = "bin/busted" "bin/kong" "bin/kong-health"
6+
BUSTED_ARGS ?= -v
7+
TEST_CMD ?= bin/busted $(BUSTED_ARGS)
8+
9+
BUILD_NAME ?= kong-dev
10+
11+
ifeq ($(OS), darwin)
12+
OPENSSL_DIR ?= $(shell brew --prefix)/opt/openssl
13+
GRPCURL_OS ?= osx
14+
YAML_DIR ?= $(shell brew --prefix)/opt/libyaml
15+
EXPAT_DIR ?= $(HOMEBREW_DIR)/opt/expat
16+
else
17+
OPENSSL_DIR ?= /usr
18+
GRPCURL_OS ?= $(OS)
19+
YAML_DIR ?= /usr
20+
EXPAT_DIR ?= $(LIBRARY_PREFIX)
21+
endif
22+
23+
ifeq ($(MACHINE), aarch64)
24+
GRPCURL_MACHINE ?= arm64
25+
H2CLIENT_MACHINE ?= arm64
26+
else
27+
GRPCURL_MACHINE ?= $(MACHINE)
28+
H2CLIENT_MACHINE ?= $(MACHINE)
29+
endif
30+
31+
ifeq ($(MACHINE), aarch64)
32+
BAZELISK_MACHINE ?= arm64
33+
else ifeq ($(MACHINE), x86_64)
34+
BAZELISK_MACHINE ?= amd64
35+
else
36+
BAZELISK_MACHINE ?= $(MACHINE)
37+
endif
38+
39+
.PHONY: install dev \
40+
lint test test-integration test-plugins test-all \
41+
pdk-phase-check functional-tests \
42+
fix-windows release wasm-test-filters
43+
44+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
45+
KONG_SOURCE_LOCATION ?= $(ROOT_DIR)
46+
GRPCURL_VERSION ?= 1.8.5
47+
BAZLISK_VERSION ?= 1.19.0
48+
H2CLIENT_VERSION ?= 0.4.4
49+
BAZEL := $(shell command -v bazel 2> /dev/null)
50+
VENV = /dev/null # backward compatibility when no venv is built
51+
52+
# Use x86_64 grpcurl v1.8.5 for Apple silicon chips
53+
ifeq ($(GRPCURL_OS)_$(MACHINE)_$(GRPCURL_VERSION), osx_arm64_1.8.5)
54+
GRPCURL_MACHINE = x86_64
55+
endif
56+
57+
PACKAGE_TYPE ?= deb
58+
59+
bin/bazel:
60+
@curl -s -S -L \
61+
https://github.com/bazelbuild/bazelisk/releases/download/v$(BAZLISK_VERSION)/bazelisk-$(OS)-$(BAZELISK_MACHINE) -o bin/bazel
62+
@chmod +x bin/bazel
63+
64+
bin/grpcurl:
65+
@curl -s -S -L \
66+
https://github.com/fullstorydev/grpcurl/releases/download/v$(GRPCURL_VERSION)/grpcurl_$(GRPCURL_VERSION)_$(GRPCURL_OS)_$(GRPCURL_MACHINE).tar.gz | tar xz -C bin;
67+
@$(RM) bin/LICENSE
68+
69+
bin/h2client:
70+
@curl -s -S -L \
71+
https://github.com/Kong/h2client/releases/download/v$(H2CLIENT_VERSION)/h2client_$(H2CLIENT_VERSION)_$(OS)_$(H2CLIENT_MACHINE).tar.gz | tar xz -C bin;
72+
@$(RM) bin/README.md
73+
74+
75+
check-bazel: bin/bazel
76+
ifndef BAZEL
77+
$(eval BAZEL := bin/bazel)
78+
endif
79+
80+
wasm-test-filters:
81+
./scripts/build-wasm-test-filters.sh
82+
83+
build-kong: check-bazel
84+
$(BAZEL) build //build:kong --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME)
85+
86+
build-venv: check-bazel
87+
$(eval VENV := bazel-bin/build/$(BUILD_NAME)-venv.sh)
88+
89+
@if [ ! -e bazel-bin/build/$(BUILD_NAME)-venv.sh ]; then \
90+
$(BAZEL) build //build:venv --verbose_failures --action_env=BUILD_NAME=$(BUILD_NAME); \
91+
fi
92+
93+
install-dev-rocks: build-venv
94+
@. $(VENV) ;\
95+
for rock in $(DEV_ROCKS) ; do \
96+
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
97+
echo $$rock already installed, skipping ; \
98+
else \
99+
echo $$rock not found, installing via luarocks... ; \
100+
LIBRARY_PREFIX=$$(pwd)/bazel-bin/build/$(BUILD_NAME)/kong ; \
101+
luarocks install $$rock OPENSSL_DIR=$$LIBRARY_PREFIX CRYPTO_DIR=$$LIBRARY_PREFIX YAML_DIR=$(YAML_DIR) || exit 1; \
102+
fi \
103+
done;
104+
105+
dev: build-venv install-dev-rocks bin/grpcurl bin/h2client wasm-test-filters
106+
107+
build-release: check-bazel
108+
$(BAZEL) clean --expunge
109+
$(BAZEL) build //build:kong --verbose_failures --config release
110+
111+
package/deb: check-bazel build-release
112+
$(BAZEL) build --config release :kong_deb
113+
114+
package/apk: check-bazel build-release
115+
$(BAZEL) build --config release :kong_apk
116+
117+
package/rpm: check-bazel build-release
118+
$(BAZEL) build --config release :kong_el8 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
119+
$(BAZEL) build --config release :kong_el7 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
120+
$(BAZEL) build --config release :kong_aws2 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
121+
$(BAZEL) build --config release :kong_aws2022 --action_env=RPM_SIGNING_KEY_FILE --action_env=NFPM_RPM_PASSPHRASE
122+
123+
functional-tests: dev test
124+
125+
install: dev
126+
@$(VENV) luarocks make
127+
128+
clean: check-bazel
129+
$(BAZEL) clean
130+
$(RM) bin/bazel bin/grpcurl bin/h2client
131+
132+
expunge: check-bazel
133+
$(BAZEL) clean --expunge
134+
$(RM) bin/bazel bin/grpcurl bin/h2client
135+
136+
lint: dev
137+
@$(VENV) luacheck -q .
138+
@!(grep -R -E -I -n -w '#only|#o' spec && echo "#only or #o tag detected") >&2
139+
@!(grep -R -E -I -n -- '---\s+ONLY' t && echo "--- ONLY block detected") >&2
140+
141+
update-copyright: build-venv
142+
bash -c 'OPENSSL_DIR=$(OPENSSL_DIR) EXPAT_DIR=$(EXPAT_DIR) $(VENV) luajit $(KONG_SOURCE_LOCATION)/scripts/update-copyright'
143+
144+
test: dev
145+
@$(VENV) $(TEST_CMD) spec/01-unit
146+
147+
test-integration: dev
148+
@$(VENV) $(TEST_CMD) spec/02-integration
149+
150+
test-plugins: dev
151+
@$(VENV) $(TEST_CMD) spec/03-plugins
152+
153+
test-all: dev
154+
@$(VENV) $(TEST_CMD) spec/
155+
156+
test-custom: dev
157+
ifndef test_spec
158+
$(error test_spec variable needs to be set, i.e. make test-custom test_spec=foo/bar/baz_spec.lua)
159+
endif
160+
@$(VENV) $(TEST_CMD) $(test_spec)
161+
162+
pdk-phase-checks: dev
163+
rm -f t/phase_checks.stats
164+
rm -f t/phase_checks.report
165+
PDK_PHASE_CHECKS_LUACOV=1 prove -I. t/01*/*/00-phase*.t
166+
luacov -c t/phase_checks.luacov
167+
grep "ngx\\." t/phase_checks.report
168+
grep "check_" t/phase_checks.report
169+
170+
fix-windows:
171+
@for script in $(WIN_SCRIPTS) ; do \
172+
echo Converting Windows file $$script ; \
173+
mv $$script $$script.win ; \
174+
tr -d '\015' <$$script.win >$$script ; \
175+
rm $$script.win ; \
176+
chmod 0755 $$script ; \
177+
done;
178+
179+
# the following targets are kept for backwards compatibility
180+
# dev is renamed to dev-legacy
181+
remove:
182+
$(warning 'remove' target is deprecated, please use `make dev` instead)
183+
-@luarocks remove kong
184+
185+
dependencies: bin/grpcurl bin/h2client
186+
$(warning 'dependencies' target is deprecated, this is now not needed when using `make dev`, but are kept for installation that are not built by Bazel)
187+
188+
for rock in $(DEV_ROCKS) ; do \
189+
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
190+
echo $$rock already installed, skipping ; \
191+
else \
192+
echo $$rock not found, installing via luarocks... ; \
193+
luarocks install $$rock OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR) YAML_DIR=$(YAML_DIR) || exit 1; \
194+
fi \
195+
done;
196+
197+
install-legacy:
198+
@luarocks make OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR) YAML_DIR=$(YAML_DIR)
199+
200+
dev-legacy: remove install-legacy dependencies

kong-versions/3.7.0/kong/bin/busted

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env resty
2+
3+
setmetatable(_G, nil)
4+
5+
local pl_path = require("pl.path")
6+
7+
local pl_file = require("pl.file")
8+
9+
local tools_system = require("kong.tools.system")
10+
11+
local cert_path do
12+
local busted_cert_file = pl_path.tmpname()
13+
local busted_cert_content = pl_file.read("spec/fixtures/kong_spec.crt")
14+
15+
local system_cert_path, err = tools_system.get_system_trusted_certs_filepath()
16+
if system_cert_path then
17+
busted_cert_content = busted_cert_content .. "\n" .. pl_file.read(system_cert_path)
18+
end
19+
20+
pl_file.write(busted_cert_file, busted_cert_content)
21+
cert_path = busted_cert_file
22+
end
23+
24+
local DEFAULT_RESTY_FLAGS=string.format(" -c 4096 --http-conf 'lua_ssl_trusted_certificate %s;' ", cert_path)
25+
26+
if not os.getenv("KONG_BUSTED_RESPAWNED") then
27+
-- initial run, so go update the environment
28+
local script = {}
29+
for line in io.popen("set"):lines() do
30+
local ktvar, val = line:match("^KONG_TEST_([^=]*)=(.*)")
31+
if ktvar then
32+
-- reinserted KONG_TEST_xxx as KONG_xxx; append
33+
table.insert(script, "export KONG_" .. ktvar .. "=" ..val)
34+
end
35+
36+
local var = line:match("^(KONG_[^=]*)")
37+
local var_for_spec = line:match("^(KONG_SPEC_[^=]*)")
38+
if var and not var_for_spec then
39+
-- remove existing KONG_xxx and KONG_TEST_xxx variables; prepend
40+
table.insert(script, 1, "unset " .. var)
41+
end
42+
end
43+
-- add cli recursion detection
44+
table.insert(script, "export KONG_BUSTED_RESPAWNED=1")
45+
46+
-- rebuild the invoked commandline, while inserting extra resty-flags
47+
local resty_flags = DEFAULT_RESTY_FLAGS
48+
local cmd = { "exec", "/usr/bin/env", "resty" }
49+
local cmd_prefix_count = #cmd
50+
for i = 0, #arg do
51+
if arg[i]:sub(1, 12) == "RESTY_FLAGS=" then
52+
resty_flags = arg[i]:sub(13, -1)
53+
54+
else
55+
table.insert(cmd, "'" .. arg[i] .. "'")
56+
end
57+
end
58+
59+
-- create shared dict
60+
resty_flags = resty_flags .. require("spec.fixtures.shared_dict")
61+
62+
if resty_flags then
63+
table.insert(cmd, cmd_prefix_count+1, resty_flags)
64+
end
65+
66+
table.insert(script, table.concat(cmd, " "))
67+
68+
-- recurse cli command, with proper variables (un)set for clean testing
69+
local _, _, rc = os.execute(table.concat(script, "; "))
70+
os.exit(rc)
71+
end
72+
73+
pcall(require, "luarocks.loader")
74+
75+
require("kong.globalpatches")({
76+
cli = true,
77+
rbusted = true
78+
})
79+
80+
-- some libraries used in test like spec/helpers
81+
-- calls cosocket in module level, and as LuaJIT's
82+
-- `require` is implemented in C, this throws
83+
-- "attempt to yield across C-call boundary" error
84+
-- the following pure-lua implementation is to bypass
85+
-- this limitation, without need to modify all tests
86+
_G.require = require "spec.require".require
87+
88+
-- Busted command-line runner
89+
require 'busted.runner'({ standalone = false })
90+
91+
-- vim: set ft=lua ts=2 sw=2 sts=2 et :

0 commit comments

Comments
 (0)