Skip to content

Commit

Permalink
Migrate to buf (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Mar 10, 2023
1 parent eb5210d commit 285f184
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 112 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ all:

.PHONY: proto
proto:
docker pull metalstack/builder
docker run -it --rm --user $$(id -u):$$(id -g) -v ${PWD}/api:/work/api metalstack/builder protoc -I api/ api/v1/*.proto --go_out=plugins=grpc:api
make -C proto protoc

.PHONY: dockerimage
dockerimage:
Expand Down
98 changes: 10 additions & 88 deletions api/v1/initializer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions api/v1/initializer.proto

This file was deleted.

107 changes: 107 additions & 0 deletions api/v1/initializer_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions proto/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MAKEFLAGS += --no-print-directory
BUF_VERSION := 1.15.0

_buf:
docker run --rm \
--entrypoint sh \
-v $(PWD)/..:/workspace \
-w /workspace/proto \
bufbuild/buf:$(BUF_VERSION) \
-c "buf $(CMD) && chown -R $(shell id -u):$(shell id -g) /workspace"

.PHONY: protolint
protolint:
@$(MAKE) _buf CMD="format -w v1"
@$(MAKE) _buf CMD="lint -v"

.PHONY: protoc
protoc: protolint
@$(MAKE) _buf CMD="generate -v"
14 changes: 14 additions & 0 deletions proto/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/metal-stack/droptailer/api
plugins:
# generate go structs for protocol buffer definition
- plugin: buf.build/protocolbuffers/go:v1.28.1
out: ../api
opt: paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
out: ../api
opt: paths=source_relative,require_unimplemented_servers=false

7 changes: 7 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- BASIC
21 changes: 21 additions & 0 deletions proto/v1/initializer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

package v1;

option go_package = "./v1";

service InitializerService {
rpc Status(Empty) returns (StatusResponse);
}

message Empty {}

message StatusResponse {
enum InitializerStatus {
CHECKING = 0;
RESTORING = 1;
DONE = 2;
}
InitializerStatus status = 1;
string message = 2;
}

0 comments on commit 285f184

Please sign in to comment.