Skip to content

Commit a295ab7

Browse files
committed
feat: enable vtprotobuf generation
Fixes #39 Build instructions were generated with siderolabs/kres#102 As vtprotobuf is more efficient, this can be used in vtprotobuf-enabled servers and clients. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
1 parent 6f75c64 commit a295ab7

12 files changed

Lines changed: 9850 additions & 61 deletions

.conform.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2022-04-12T21:42:27Z by kres 4975f30.
3+
# Generated on 2022-04-22T12:24:48Z by kres 685be7b.
44

55
---
66
policies:
77
- type: commit
88
spec:
99
dco: true
10-
gpg: false
10+
gpg:
11+
required: true
12+
identity:
13+
gitHubOrganization: cosi-project
1114
spellcheck:
1215
locale: US
1316
maximumOfOneCommit: true

.kres.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ kind: golang.Protobuf
33
spec:
44
experimentalFlags:
55
- --experimental_allow_proto3_optional
6+
vtProtobufEnabled: true
67
specs:
78
- source: https://raw.githubusercontent.com/smira/specification/resource-proto/proto/v1alpha1/resource.proto
89
subdirectory: v1alpha1/

Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2022-04-12T21:42:27Z by kres 4975f30.
5+
# Generated on 2022-04-22T17:30:48Z by kres 685be7b-dirty.
66

77
ARG TOOLCHAIN
88

@@ -37,10 +37,10 @@ ENV GOPATH /go
3737
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.45.2
3838
ARG GOFUMPT_VERSION
3939
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
40-
&& mv /go/bin/gofumpt /bin/gofumpt
40+
&& mv /go/bin/gofumpt /bin/gofumpt
4141
ARG GOIMPORTS_VERSION
4242
RUN go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
43-
&& mv /go/bin/goimports /bin/goimports
43+
&& mv /go/bin/goimports /bin/goimports
4444
ARG PROTOBUF_GO_VERSION
4545
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOBUF_GO_VERSION}
4646
RUN mv /go/bin/protoc-gen-go /bin
@@ -50,6 +50,9 @@ RUN mv /go/bin/protoc-gen-go-grpc /bin
5050
ARG GRPC_GATEWAY_VERSION
5151
RUN go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION}
5252
RUN mv /go/bin/protoc-gen-grpc-gateway /bin
53+
ARG VTPROTOBUF_VERSION
54+
RUN go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v${VTPROTOBUF_VERSION}
55+
RUN mv /go/bin/protoc-gen-go-vtproto /bin
5356

5457
# tools and sources
5558
FROM tools AS base
@@ -66,15 +69,17 @@ RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null
6669
# runs protobuf compiler
6770
FROM tools AS proto-compile
6871
COPY --from=proto-specs / /
69-
RUN protoc -I/api --go_out=paths=source_relative:/api --go-grpc_out=paths=source_relative:/api --experimental_allow_proto3_optional /api/v1alpha1/resource.proto
70-
RUN protoc -I/api --go_out=paths=source_relative:/api --go-grpc_out=paths=source_relative:/api --experimental_allow_proto3_optional /api/v1alpha1/state.proto
71-
RUN protoc -I/api --go_out=paths=source_relative:/api --go-grpc_out=paths=source_relative:/api --experimental_allow_proto3_optional /api/v1alpha1/runtime.proto
72+
RUN protoc -I/api --go_out=paths=source_relative:/api --go-grpc_out=paths=source_relative:/api --go-vtproto_out=paths=source_relative:/api --go-vtproto_opt=features=marshal+unmarshal+size --experimental_allow_proto3_optional /api/v1alpha1/resource.proto /api/v1alpha1/state.proto /api/v1alpha1/runtime.proto
73+
RUN goimports -w -local github.com/cosi-project/runtime /api
74+
RUN gofumpt -w /api
7275

7376
# runs gofumpt
7477
FROM base AS lint-gofumpt
75-
RUN find . -name '*.pb.go' | xargs -r rm
76-
RUN find . -name '*.pb.gw.go' | xargs -r rm
77-
RUN FILES="$(goimports -w -local github.com/cosi-project/runtime . && gofumpt -w .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumports -w -local github.com/cosi-project/runtime .':\n${FILES}"; exit 1)
78+
RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumpt -w .':\n${FILES}"; exit 1)
79+
80+
# runs goimports
81+
FROM base AS lint-goimports
82+
RUN FILES="$(goimports -l -local github.com/cosi-project/runtime .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'goimports -w -local github.com/cosi-project/runtime .':\n${FILES}"; exit 1)
7883

7984
# runs golangci-lint
8085
FROM base AS lint-golangci-lint

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2022-04-12T21:42:27Z by kres 4975f30.
3+
# Generated on 2022-04-22T17:29:34Z by kres 685be7b-dirty.
44

55
# common variables
66

@@ -11,13 +11,13 @@ ARTIFACTS := _out
1111
REGISTRY ?= ghcr.io
1212
USERNAME ?= cosi-project
1313
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
14-
GOFUMPT_VERSION ?= v0.3.0
15-
GOIMPORTS_VERSION ?= v0.1.10
14+
GOFUMPT_VERSION ?= v0.3.1
1615
GO_VERSION ?= 1.18
16+
GOIMPORTS_VERSION ?= v0.1.10
1717
PROTOBUF_GO_VERSION ?= 1.28.0
1818
GRPC_GO_VERSION ?= 1.2.0
1919
GRPC_GATEWAY_VERSION ?= 2.10.0
20-
VTPROTOBUF_VERSION ?= d8520340f57329767fd3b2c9cc0aea3703dd68c9
20+
VTPROTOBUF_VERSION ?= 0.3.0
2121
TESTPKGS ?= ./...
2222
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
2323

@@ -101,11 +101,12 @@ lint-gofumpt: ## Runs gofumpt linter.
101101
fmt: ## Formats the source code
102102
@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) \
103103
bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; \
104-
go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION) && \
105104
go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION) && \
106-
goimports -w -local github.com/cosi-project/runtime . && \
107105
gofumpt -w ."
108106

107+
lint-goimports: ## Runs goimports linter.
108+
@$(MAKE) target-$@
109+
109110
generate: ## Generate .proto definitions.
110111
@$(MAKE) local-$@ DEST=./
111112

@@ -140,7 +141,7 @@ lint-markdown: ## Runs markdownlint.
140141
@$(MAKE) target-$@
141142

142143
.PHONY: lint
143-
lint: lint-golangci-lint lint-gofumpt lint-markdown ## Run all linters for the project.
144+
lint: lint-golangci-lint lint-gofumpt lint-goimports lint-markdown ## Run all linters for the project.
144145

145146
.PHONY: image-runtime
146147
image-runtime: ## Builds image for runtime.

api/v1alpha1/resource.pb.go

Lines changed: 21 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)