Skip to content

Commit

Permalink
api: build using buf
Browse files Browse the repository at this point in the history
Signed-off-by: William Findlay <william.findlay@isovalent.com>
  • Loading branch information
will-isovalent committed Feb 5, 2025
1 parent 1671faa commit a36079d
Show file tree
Hide file tree
Showing 25 changed files with 5,338 additions and 4,661 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

include Makefile.defs

GO ?= go
INSTALL = $(QUIET)install
BINDIR ?= /usr/local/bin
CONTAINER_ENGINE ?= docker
DOCKER_IMAGE_TAG ?= latest
LOCAL_CLANG ?= 0
LOCAL_CLANG_FORMAT ?= 0
Expand Down Expand Up @@ -204,6 +202,12 @@ image-clang:
@echo "Push like this when ready:"
@echo "${CONTAINER_ENGINE} push cilium/clang:$(DOCKER_IMAGE_TAG)"

.PHONY: image-builder
image-builder:
$(CONTAINER_ENGINE) build -t cilium/tetragon-builder:$(DOCKER_IMAGE_TAG) -f images/builder/Dockerfile .
@echo "Push like this when ready:"
@echo "${CONTAINER_ENGINE} push cilium/tetragon-builder:$(DOCKER_IMAGE_TAG)"

.PHONY: images
images: image image-operator ## Convenience alias for image and image-operator.

Expand Down Expand Up @@ -379,11 +383,11 @@ kind-down: ## Delete a kind cluster for Tetragon development.

.PHONY: codegen protogen
codegen: | protogen
protogen: protoc-gen-go-tetragon ## Generate code based on .proto files.
protogen: image-builder protoc-gen-go-tetragon ## Generate code based on .proto files.
# Need to call vendor twice here, once before and once after codegen the reason
# being we need to grab changes first plus pull in whatever gets generated here.
$(MAKE) -C api vendor
$(MAKE) -C api
$(MAKE) -C api BUILDER_IMAGE=cilium/tetragon-builder:latest
$(GO) mod tidy
$(GO) mod vendor
$(GO) mod verify
Expand Down
8 changes: 8 additions & 0 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ endef
define print_help_option
@printf " \033[35m%-22s\033[0m %s\n" $(1) '$(2)'
endef

GO ?= go
CONTAINER_ENGINE ?= docker

BUF ?= buf
BUF_BREAKING_AGAINST_BRANCH ?= origin/main
# renovate: datasource=docker
BUILDER_IMAGE=quay.io/cilium/cilium-builder@sha256:a2036a3f6420647e6702695dabd2ffa4d2832db45157042d0255bdc707b8e1f2
27 changes: 16 additions & 11 deletions api/Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# Copyright 2017-2020 Authors of Cilium
# SPDX-License-Identifier: Apache-2.0

# renovate: datasource=docker
BUILDER_IMAGE=quay.io/cilium/cilium-builder@sha256:a2036a3f6420647e6702695dabd2ffa4d2832db45157042d0255bdc707b8e1f2
GO ?= go
include ../Makefile.defs

.PHONY: all
all: proto

.PHONY: proto
proto: v1
.PHONY: proto-local
proto-local: check-breaking
# $(BUF) format -w
# $(BUF) lint
$(BUF) generate

.PHONY: check-breaking
check-breaking:
# $(BUF) breaking --against "$(CURDIR)/.git#branch=$(BUF_BREAKING_AGAINST_BRANCH)"

.PHONY: v1
v1:
docker container run --rm \
.PHONY: proto
proto:
$(CONTAINER_ENGINE) container run --rm \
--volume $(CURDIR)/..:/src \
--workdir /src/api \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
make -C /src/api/v1 -f Makefile.protoc
./export-doc.sh ../docs/content/en/docs/reference/grpc-api.md
make -C /src/api proto-local BUF_BREAKING_AGAINST_BRANCH=$(BUF_BREAKING_AGAINST_BRANCH)

.PHONY: vendor
vendor:
$(GO) mod tidy
$(GO) mod vendor
$(GO) mod verify
$(GO) mod verify
17 changes: 17 additions & 0 deletions api/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v2
plugins:
- local: protoc-gen-go
out: .
opt:
- paths=source_relative
- local: protoc-gen-go-json
out: .
opt:
- paths=source_relative
- orig_name=true
- local: protoc-gen-doc
out: .
opt:
- markdown
- README.md
- source_relative
20 changes: 20 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: v2

modules:
- path: .
excludes:
- vendor

lint:
use:
# See full list here: https://buf.build/docs/lint/rules/
- COMMENTS
- STANDARD
disallow_comment_ignores: true

breaking:
use:
- FILE
# Ignores packages with a last component that's one of the unstable forms
# (e.g. foo.bar.v1alpha foo.bar.v1beta)
ignore_unstable_packages: true
67 changes: 0 additions & 67 deletions api/v1/Makefile.protoc

This file was deleted.

Loading

0 comments on commit a36079d

Please sign in to comment.