Skip to content

Commit 9b4b286

Browse files
authored
Merge pull request #14 from KusionStack/231024-cb-grpc
feat: circuitbreker grpc proto buf transformation
2 parents a1b03f7 + f57f748 commit 9b4b286

File tree

378 files changed

+40714
-10043
lines changed

Some content is hidden

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

378 files changed

+40714
-10043
lines changed

.github/workflows/check.yaml

+11-7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jobs:
3333
run: |
3434
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.5/protoc-3.19.5-linux-x86_64.zip
3535
unzip protoc-3.19.5-linux-x86_64.zip -d protoc3
36+
rm -rf protoc-3.19.5-linux-x86_64.zip
37+
- name: Setup Buf
38+
run: |
39+
GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected]
40+
GO111MODULE=on GOBIN=/usr/local/bin go install ./tools/protoc-gen-golang-deepcopy
3641
- name: Cache Go Dependencies
3742
uses: actions/cache@v2
3843
with:
@@ -42,17 +47,16 @@ jobs:
4247
- name: Run Unit Tests
4348
run: |
4449
export PATH="$PATH:$(pwd)/protoc3/bin"
50+
ls $(pwd)
4551
echo $PATH
4652
make test
47-
rm -rf protoc-3.19.5-linux-x86_64.zip
4853
rm -rf protoc3
4954
git status
50-
# TODO: enable after public
51-
# - name: Publish Unit Test Coverage
52-
# uses: codecov/codecov-action@v3
53-
# with:
54-
# flags: unittests
55-
# file: cover.out
55+
- name: Publish Unit Test Coverage
56+
uses: codecov/codecov-action@v3
57+
with:
58+
flags: unittests
59+
file: cover.out
5660
- name: Check diff
5761
run: '[[ -z $(git status -s) ]] || (printf "Existing modified/untracked files.\nPlease run \"make generate manifests fmt vet\" and push again.\n"; exit 1)'
5862

.github/workflows/release.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
run: |
2929
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.5/protoc-3.19.5-linux-x86_64.zip
3030
unzip protoc-3.19.5-linux-x86_64.zip -d protoc3
31+
rm -rf protoc-3.19.5-linux-x86_64.zip
32+
- name: Setup Buf
33+
run: |
34+
GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected]
35+
GO111MODULE=on GOBIN=/usr/local/bin go install ./tools/protoc-gen-golang-deepcopy
3136
- name: Cache Go Dependencies
3237
uses: actions/cache@v2
3338
with:
@@ -39,7 +44,6 @@ jobs:
3944
export PATH="$PATH:$(pwd)/protoc3/bin"
4045
echo $PATH
4146
make test
42-
rm -rf protoc-3.19.5-linux-x86_64.zip
4347
rm -rf protoc3
4448
git status
4549

.golangci.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
run:
22
skip-files:
33
- ".*_test.go"
4+
- ".*.gen.go"
45
- pkg/utils/http/reverse_proxy.go
56
- pkg/proxy/apiserver/options.go
67
skip-dirs:

.licenserc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ header:
5757
- '.gitignore'
5858
- '.licenserc'
5959
- '**/zz_generated.deepcopy.go'
60+
- '**/*.connect.go'
6061
- '**/*.pb.go'
6162
- '**/*.proto'
63+
- '**/*.gen.go'
6264
comment: never
6365
license-location-threshold: 80

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ generate-client: controller-gen ## Generate code containing DeepCopy, DeepCopyIn
4545
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
4646

4747
generate-protobuf: controller-gen ## Generate protobuf code.
48-
@artifacts/scripts/generate_protobuf.sh
48+
#@artifacts/scripts/generate_protobuf.sh
49+
buf generate --path pkg
4950
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
5051

5152
generate: generate-client generate-protobuf
@@ -54,7 +55,7 @@ fmt: ## Run go fmt against code.
5455
go fmt ./...
5556

5657
vet: ## Run go vet against code.
57-
go vet ./...
58+
go vet -copylocks=false ./...
5859

5960
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
6061
test: fmt vet generate manifests ## Run tests.

artifacts/images/manager.Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ RUN CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -mod=vendor -a
1515
FROM ubuntu:focal
1616
# This is required by daemon connnecting with cri
1717
RUN ln -s /usr/bin/* /usr/sbin/ && apt-get update -y \
18-
&& apt-get install --no-install-recommends -y ca-certificates \
18+
&& apt-get install --no-install-recommends -y \
19+
sudo \
20+
net-tools \
21+
curl \
22+
ca-certificates \
1923
&& apt-get clean && rm -rf /var/log/*log /var/lib/apt/lists/* /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old
2024
WORKDIR /
2125
COPY --from=builder /workspace/ctrlmesh-manager .

artifacts/scripts/generate_client.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ fi
99
set -e
1010
TMP_DIR=$(mktemp -d)
1111

12-
mkdir -p "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg/client
12+
mkdir -p "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg/client
1313

14-
cp -r ./{hack,vendor} "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/
15-
cp -r ./pkg/apis "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg/
16-
cp ./go.mod "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/go.mod
14+
cp -r ./{hack,vendor} "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/
15+
cp -r ./pkg/apis "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg/
16+
cp ./go.mod "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/go.mod
1717

18-
(cd "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh; \
18+
(cd "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh; \
1919
GOPATH=${TMP_DIR} GO111MODULE=on /bin/bash vendor/k8s.io/code-generator/generate-groups.sh all \
20-
github.com/KusionStack/ctrlmesh/pkg/client github.com/KusionStack/ctrlmesh/pkg/apis "ctrlmesh:v1alpha1" -h ./hack/boilerplate.go.txt)
20+
github.com/KusionStack/controller-mesh/pkg/client github.com/KusionStack/controller-mesh/pkg/apis "ctrlmesh:v1alpha1" -h ./hack/boilerplate.go.txt)
2121

2222
rm -rf ./pkg/client/{clientset,informers,listers}
23-
mv "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg/client/* ./pkg/client
23+
mv "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg/client/* ./pkg/client

artifacts/scripts/generate_protobuf.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ fi
1313
set -e
1414
TMP_DIR=$(mktemp -d)
1515
mkdir -p "${TMP_DIR}"/bin
16-
mkdir -p "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg
16+
mkdir -p "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg
1717

18-
cp -r ./{hack,vendor} "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/
19-
cp -r ./pkg/apis "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg/
20-
cp ./go.mod "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/go.mod
18+
cp -r ./{hack,vendor} "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/
19+
cp -r ./pkg/apis "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg/
20+
cp ./go.mod "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/go.mod
2121

22-
(cd "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh; \
23-
GO111MODULE=off GOPATH=${TMP_DIR} go build -o ${TMP_DIR}/bin/protoc-gen-gogo github.com/KusionStack/ctrlmesh/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo; \
22+
(cd "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh; \
23+
GO111MODULE=off GOPATH=${TMP_DIR} go build -o ${TMP_DIR}/bin/protoc-gen-gogo github.com/KusionStack/controller-mesh/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo; \
2424
PATH=${TMP_DIR}/bin:$PATH GOPATH=${TMP_DIR} \
25-
protoc \
26-
--gogo_out=plugins=grpc,paths=source_relative:. pkg/apis/ctrlmesh/proto/ctrlmesh.proto)
25+
protoc --gogo_out=plugins=grpc,paths=source_relative:. pkg/apis/ctrlmesh/proto/ctrlmesh.proto; \
26+
protoc --gogo_out=plugins=grpc,paths=source_relative:. pkg/apis/ctrlmesh/proto/throttling.proto )
2727
# protoc bug in code-generator v0.26.1, can not contains '/' in path.
2828

2929

30-
cp -f "${TMP_DIR}"/src/github.com/KusionStack/ctrlmesh/pkg/apis/ctrlmesh/proto/*.go pkg/apis/ctrlmesh/proto/
30+
cp -f "${TMP_DIR}"/src/github.com/KusionStack/controller-mesh/pkg/apis/ctrlmesh/proto/*.go pkg/apis/ctrlmesh/proto/

buf.gen.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: v1
2+
#managed:
3+
# enabled: true
4+
# go_package_prefix:
5+
# default: github.com/kusionstack/kridge/api/gen
6+
plugins:
7+
# Remote plugins
8+
- plugin: buf.build/protocolbuffers/go
9+
out: .
10+
opt: paths=source_relative
11+
- plugin: buf.build/connectrpc/go
12+
out: .
13+
opt: paths=source_relative
14+
# Local plugins:
15+
# golang-deepcopy: tools/cmd/protoc-gen-golang-deepcopy
16+
- plugin: golang-deepcopy
17+
out: .
18+
opt: paths=source_relative

buf.lock

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v1
3+
deps:
4+
- remote: buf.build
5+
owner: googleapis
6+
repository: googleapis
7+
commit: 28151c0d0a1641bf938a7672c500e01d
8+
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
9+
- remote: buf.build
10+
owner: k8s
11+
repository: api
12+
commit: 8f68e41b943c4de8a5e9c9a921c889a7
13+
digest: shake256:38ab77d24cf737d1204719a0ffc654056c29499f26b1546cc5af9ddb34e33799930d79d1f5a4a04b0f5c149097eabbeed37a5d2abf9552169a7d52011f6a8d6f

buf.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: v1
2+
breaking:
3+
use:
4+
- FILE
5+
deps:
6+
- buf.build/googleapis/googleapis
7+
- buf.build/k8s/api
8+
build:
9+
excludes:
10+
- vendor
11+
- common-protos
12+
lint:
13+
use:
14+
- BASIC
15+
except:
16+
- FIELD_LOWER_SNAKE_CASE
17+
- PACKAGE_DIRECTORY_MATCH
18+
allow_comment_ignores: true

0 commit comments

Comments
 (0)