Skip to content

Commit

Permalink
makefile: rename codegen to protogen
Browse files Browse the repository at this point in the history
[upstream commit: 6df735d]

Now that we have renamed the generate target to crds, it makes sense to also rename to
codegen target to make it more clear that it specifically refers to protobuf codegen. Just
as with make generate, we keep the old codegen target around to use as an alias for
backward compatbility. We also remove the original protogen dockerfile as it is no longer
needed. Instead, we can simply use the base cilium-builder image.

Signed-off-by: William Findlay <[email protected]>
  • Loading branch information
willfindlay committed Feb 22, 2024
1 parent e8f766c commit 99f23a7
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 34 deletions.
4 changes: 0 additions & 4 deletions Dockerfile.codegen

This file was deleted.

16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ help:
@echo ' tarball - build Tetragon compressed tarball'
@echo ' tarball-release - build Tetragon release tarball'
@echo ' Generated files:'
@echo ' codegen - generate code based on .proto files'
@echo ' protogen - generate code based on .proto files'
@echo ' crds - generate kubebuilder files'
@echo ' generate-flags - generate Tetragon daemon flags for documentation'
@echo ' Linting and chores:'
Expand Down Expand Up @@ -282,7 +282,7 @@ update-copyright:
lint:
golint -set_exit_status $$(go list ./...)

.PHONY: image image-operator image-test image-codegen
.PHONY: image image-operator image-test
image:
$(CONTAINER_ENGINE) build -t "cilium/tetragon:${DOCKER_IMAGE_TAG}" --target release --build-arg TETRAGON_VERSION=$(VERSION) .
$(QUIET)@echo "Push like this when ready:"
Expand All @@ -298,11 +298,6 @@ image-test: image-clang
$(QUIET)@echo "Push like this when ready:"
$(QUIET)@echo "${CONTAINER_ENGINE} push cilium/tetragon-test:$(DOCKER_IMAGE_TAG)"

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

.PHONY: image-clang
image-clang:
$(CONTAINER_ENGINE) build -f Dockerfile.clang --build-arg VERSION=1:15.0.7-0ubuntu0.22.04.2 -t "cilium/clang:${DOCKER_IMAGE_TAG}" .
Expand Down Expand Up @@ -334,7 +329,7 @@ tarball-clean:
fetch-testdata:
wget -nc -P testdata/btf 'https://github.com/cilium/tetragon-testdata/raw/main/btf/vmlinux-5.4.104+'

.PHONY: crdgen generate codegen protoc-gen-go-tetragon
.PHONY: crdgen generate protogen codegen protoc-gen-go-tetragon
generate: | crds
crds:
# Need to call vendor twice here, once before and once after generate, the reason
Expand All @@ -343,15 +338,16 @@ crds:
$(MAKE) -C pkg/k8s/
$(MAKE) vendor

codegen: image-codegen
codegen: | protogen
protogen: protoc-gen-go-tetragon
# 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) vendor
$(MAKE) -C api
$(MAKE) vendor

protoc-gen-go-tetragon:
$(GO_BUILD) -o bin/$@ ./cmd/protoc-gen-go-tetragon/
$(GO_BUILD) -o bin/$@ ./tools/protoc-gen-go-tetragon/

.PHONY: check
ifneq (,$(findstring $(GOLANGCILINT_WANT_VERSION),$(GOLANGCILINT_VERSION)))
Expand Down
7 changes: 4 additions & 3 deletions api/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# 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
BUILDER_IMAGE=cilium/tetragon-codegen:latest

.PHONY: all
all: proto
Expand All @@ -13,10 +14,10 @@ proto: v1
.PHONY: v1
v1:
docker container run --rm \
--volume $(CURDIR)/v1:/src \
--volume $(CURDIR)/..:/src \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
make -C /src -f Makefile.protoc
make -C /src/api/v1 -f Makefile.protoc
./export-doc.sh ../docs/content/en/docs/reference/grpc-api.md

.PHONY: vendor
Expand Down
2 changes: 1 addition & 1 deletion api/v1/Makefile.protoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TETRAGON_PROTOC_PLUGINS := \
--plugin=$(GOPATH)/bin/protoc-gen-go \
--plugin=$(GOPATH)/bin/protoc-gen-go-grpc \
--plugin=$(GOPATH)/bin/protoc-gen-go-json \
--plugin=$(GOPATH)/bin/protoc-gen-go-tetragon \
--plugin=../../bin/protoc-gen-go-tetragon \

.PHONY: all
all: protobuf codegen
Expand Down
19 changes: 16 additions & 3 deletions docs/content/en/docs/contribution-guide/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ you will be required to re-run code generation before your PR can be accepted.
To run codegen from protoc, run the following command from the root of the
repository:
```shell
make codegen
make protogen
```

And to run k8s CRD generation, run the following command from the root of the repository:
Expand All @@ -75,9 +75,22 @@ make crds

Finally, should you wish to modify any of the resulting codegen files (ending
in` .pb.go`), do not modify them directly. Instead, you can edit the files in
`cmd/protoc-gen-go-tetragon` and then re-run `make codegen`.
`cmd/protoc-gen-go-tetragon` and then re-run `make protogen`.

### Building and running a Docker image
## Running vendor

Tetragon uses multiple modules to separate the main module, from `api` from
`pkg/k8s`. Depending on your changes you might need to vendor those changes,
you can use:

```shell
make vendor
```

Note that the `make protogen` and `make crds` commands already vendor
changes automatically.

## Building and running a Docker image

The base kernel should support [BTF](https://github.com/cilium/tetragon#btf-requirement)
or a BTF file should be bind mounted on top of `/var/lib/tetragon/btf` inside
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package eventchecker
import (
"fmt"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"github.com/jpillora/longestcommon"
"google.golang.org/protobuf/compiler/protogen"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package eventchecker
import (
"fmt"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"path/filepath"
"strings"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/imports"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/imports"
"github.com/iancoleman/strcase"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/reflect/protoreflect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package eventchecker

import (
"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"github.com/iancoleman/strcase"
"google.golang.org/protobuf/compiler/protogen"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package generate
import (
"fmt"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/eventchecker"
"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/helpers"
"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/types"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/eventchecker"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/helpers"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/types"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package main

import (
"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/generate"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/generate"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package types
import (
"path/filepath"

"github.com/cilium/tetragon/cmd/protoc-gen-go-tetragon/common"
"github.com/cilium/tetragon/tools/protoc-gen-go-tetragon/common"
"google.golang.org/protobuf/compiler/protogen"
)

Expand Down

0 comments on commit 99f23a7

Please sign in to comment.