Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backports/v0.10/2131 #2142

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Dockerfile.codegen

This file was deleted.

21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ 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 ' generate - generate kubebuilder files'
@echo ' protogen - generate code based on .proto files'
@echo ' crds - generate kubebuilder files'
@echo 'Linting and chores:'
@echo ' vendor - tidy and vendor Go modules'
@echo ' clang-format - run code formatter on BPF code'
Expand Down Expand Up @@ -234,7 +234,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 @@ -250,11 +250,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.1 -t "cilium/clang:${DOCKER_IMAGE_TAG}" .
Expand Down Expand Up @@ -290,23 +285,25 @@ tarball-clean:
fetch-testdata:
wget -nc -P testdata/btf 'https://github.com/cilium/tetragon-testdata/raw/main/btf/vmlinux-5.4.104+'

.PHONY: generate codegen protoc-gen-go-tetragon
generate:
.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
# being we need to grab changes first plus pull in whatever gets generated here.
$(MAKE) vendor
$(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 -gcflags=$(GO_GCFLAGS) -ldflags=$(GO_LDFLAGS) -mod=vendor -o bin/$@ ./cmd/protoc-gen-go-tetragon/
$(GO) build -gcflags=$(GO_GCFLAGS) -ldflags=$(GO_LDFLAGS) -mod=vendor -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-docs.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
4 changes: 2 additions & 2 deletions api/v1/tetragon/capabilities.pb.go

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

4 changes: 2 additions & 2 deletions api/v1/tetragon/events.pb.go

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

4 changes: 2 additions & 2 deletions api/v1/tetragon/sensors.pb.go

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

2 changes: 1 addition & 1 deletion api/v1/tetragon/sensors_grpc.pb.go

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

4 changes: 2 additions & 2 deletions api/v1/tetragon/stack.pb.go

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

4 changes: 2 additions & 2 deletions api/v1/tetragon/tetragon.pb.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ 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:
```shell
make generate
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

Expand Down
16 changes: 13 additions & 3 deletions pkg/k8s/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# renovate: datasource=docker
BUILDER_IMAGE=docker.io/library/golang:1.20.5@sha256:fd9306e1c664bd49a11d4a4a04e41303430e069e437d137876e9290a555e06fb
GO ?= go
VERSION=$(shell git describe --tags --always)
GO_GCFLAGS ?= ""
Expand All @@ -10,18 +12,26 @@ GOLANGCILINT_VERSION = $(shell golangci-lint version 2>/dev/null)

all: generate

.PHONY: generate

.PHONY: help
help:
@echo 'Generated files:'
@echo ' generate - genereate kubebuilder files'
@echo ' generate - generate kubebuilder files'

ifeq (1,$(NOOPT))
GO_GCFLAGS = "all=-N -l"
endif

.PHONY: generate
generate:
docker container run --rm \
--volume $(CURDIR)/../..:/src \
--user "$(shell id -u):$(shell id -g)" \
--env GOCACHE=/go/.cache \
$(BUILDER_IMAGE) \
make -C /src/pkg/k8s __do_generate

.PHONY: __do_generate
__do_generate:
./tools/controller-gen crd paths=./apis/... output:dir=apis/cilium.io/client/crds/v1alpha1
# Do two invocations of generate-groups.sh, one with --plural-exceptions, one without
export GOPATH=$$(go env GOPATH); \
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"
"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

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

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

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

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

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

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

Loading