Skip to content

Commit

Permalink
Merge branch 'main' into feat/sentinel-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
WeixinX committed Oct 20, 2024
2 parents 397c2af + 23ad00d commit c6de6d5
Show file tree
Hide file tree
Showing 65 changed files with 2,199 additions and 302 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ jobs:
run: npm install -g markdownlint-cli

- name: lint markdown
run: make lint-markdown
run: make lint-markdown

- name: lint yaml
run: make lint-yaml
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
- name: Unit test
run: make unit-test

- name: Set up services
run: |
make start-service
- name: Build
run: make build-test-so
- name: Integration test
Expand Down Expand Up @@ -211,7 +215,7 @@ jobs:

- name: Set up services
run: |
make start-controller-service
make start-service
- name: Ensure benchmark is runnable
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ site/static/images
site/.hugo_build.lock
site/tmp
# dev files
api/tests/integration/testdata/services/grpc/grpc
controller/**/cache
controller/**/log
!controller/internal/log
Expand Down
1 change: 1 addition & 0 deletions .ignore_words
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fo
te
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ lint-spell: dev-tools
${DEV_TOOLS_IMAGE} \
make lint-spell-local

CODESPELL = codespell --skip 'test-envoy,go.mod,go.sum,*.svg,*.patch,./site/public/**,external,.git,.idea,go.work.sum' --check-filenames --check-hidden --ignore-words ./.ignore_words .
CODESPELL = codespell --skip '.ignore_words,test-envoy,go.mod,go.sum,*.svg,*.patch,./site/public/**,external,.git,.idea,go.work.sum' --check-filenames --check-hidden --ignore-words ./.ignore_words .
.PHONY: lint-spell-local
lint-spell-local:
$(CODESPELL)
Expand Down Expand Up @@ -190,13 +190,23 @@ lint-markdown:
@# ignore markdown under 'external/istio'
markdownlint '{*.md,site/**/*.md}' --disable MD012 MD013 MD029 MD033 MD034 MD036 MD041

# We don’t use if ! command -v yamllint because some environments might have a pre-installed Python version.
# Checking the specific path ensures we're using the Node.js version to avoid conflicts.
.PHONY: lint-yaml
lint-yaml:
YAML_LINT="$$(npm config get prefix)/bin/yamllint"; \
if ! test -x "$${YAML_LINT}"; then \
npm install -g yaml-lint; \
fi; \
"$${YAML_LINT}" "**/*.(yaml|yml)" --ignore="manifests/charts/*/templates/**/*.(yaml|yml)" --ignore="manifests/charts/*/files/**/*.(yaml|yml)"

.PHONY: lint-remain
lint-remain:
grep '>>>>>>' $(shell git ls-files .) | grep -v 'Makefile:' && exit 1 || true
cd tools && go run cmd/linter/main.go

.PHONY: lint
lint: lint-go lint-proto lint-license lint-spell lint-editorconfig lint-cjk lint-remain lint-markdown
lint: lint-go lint-proto lint-license lint-spell lint-editorconfig lint-cjk lint-remain lint-markdown lint-yaml

.PHONY: fmt
fmt: fmt-go fmt-proto fix-spell fix-cjk
Expand Down
9 changes: 9 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ build-test-so:
# The data plane image used in the integration test can be controlled via env var PROXY_IMAGE
.PHONY: integration-test
integration-test:
if ! command -v grpcurl >/dev/null 2>&1; then go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest; fi
test -d /tmp/htnn_coverage && rm -rf /tmp/htnn_coverage || true
$(foreach PKG, $(shell go list ./tests/integration/...), \
go test -tags envoy${ENVOY_API_VERSION} -v ${PKG} || exit 1; \
Expand All @@ -55,3 +56,11 @@ integration-test:
.PHONY: benchmark
benchmark:
go test -tags benchmark,envoy${ENVOY_API_VERSION} -v ./tests/integration/ -run TestBenchmark

.PHONY: start-service
start-service:
cd ./tests/integration/testdata/services && docker compose up -d --build

.PHONY: stop-service
stop-service:
cd ./tests/integration/testdata/services && docker compose down
14 changes: 7 additions & 7 deletions api/pkg/filtermanager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ import (

type DecodeWholeRequestFilter interface {
// DecodeRequest processes the whole request once when WaitAllData is returned from DecodeHeaders
// headers: the request header
// headers: the request headers
// data: the whole request body, nil if the request doesn't have body
// trailers: TODO, just a placeholder
// trailers: the request trailers, nil if the request doesn't have trailers
DecodeRequest(headers RequestHeaderMap, data BufferInstance, trailers RequestTrailerMap) ResultAction
}

type EncodeWholeResponseFilter interface {
// EncodeResponse processes the whole response once when WaitAllData is returned from EncodeHeaders
// headers: the response header
// headers: the response headers
// data: the whole response body, nil if the response doesn't have body
// trailers: TODO, just a placeholder
// trailers: the response trailers, current it's nil because of a bug in Envoy
EncodeResponse(headers ResponseHeaderMap, data BufferInstance, trailers ResponseTrailerMap) ResultAction
}

Expand All @@ -51,7 +51,7 @@ type Filter interface {
// DecodeData might be called multiple times during handling the request body.
// The endStream is true when handling the last piece of the body.
DecodeData(data BufferInstance, endStream bool) ResultAction
// TODO, just a placeholder. DecodeTrailers is not called yet
// DecodeTrailers processes request trailers. It doesn't fully work on Envoy < 1.31.
DecodeTrailers(trailers RequestTrailerMap) ResultAction
DecodeWholeRequestFilter

Expand All @@ -62,12 +62,12 @@ type Filter interface {
// EncodeData might be called multiple times during handling the response body.
// The endStream is true when handling the last piece of the body.
EncodeData(data BufferInstance, endStream bool) ResultAction
// TODO, just a placeholder. EncodeTrailers is not called yet
// EncodeTrailers processes response trailers. It doesn't fully work on Envoy < 1.31.
EncodeTrailers(trailers ResponseTrailerMap) ResultAction
EncodeWholeResponseFilter

// OnLog is called when the HTTP stream is ended on HTTP Connection Manager filter.
// TODO: the trailers here are just placeholders.
// The trailers here are always nil on Envoy < 1.32.
OnLog(reqHeaders RequestHeaderMap, reqTrailers RequestTrailerMap,
respHeaders ResponseHeaderMap, respTrailers ResponseTrailerMap)
}
Expand Down
Loading

0 comments on commit c6de6d5

Please sign in to comment.