Skip to content

Commit

Permalink
kube-codegen: update tool to generate client-go libs
Browse files Browse the repository at this point in the history
generate-internal-groups.sh and generate-groups.sh were deprecated and
then removed, replaced by kube::codegen::gen_client and
kube::codegen::gen_helpers.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
  • Loading branch information
mtardy committed Aug 26, 2024
1 parent 1aee57e commit f6e5641
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
21 changes: 1 addition & 20 deletions pkg/k8s/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,7 @@ generate:
.PHONY: __do_generate
__do_generate:
./tools/controller-gen crd paths=./apis/... output:dir=apis/cilium.io/client/crds/v1alpha1
chmod +x vendor/k8s.io/code-generator/generate-internal-groups.sh
# Do two invocations of generate-groups.sh, one with --plural-exceptions, one without
export GOPATH=$$(go env GOPATH); \
bash vendor/k8s.io/code-generator/generate-groups.sh deepcopy,defaulter \
github.com/cilium/tetragon/pkg/k8s/client \
github.com/cilium/tetragon/pkg/k8s/apis \
cilium.io:v1alpha1 \
--go-header-file hack/custom-boilerplate.go.txt \
-o . \
--trim-path-prefix github.com/cilium/tetragon/pkg/k8s \
; \
bash vendor/k8s.io/code-generator/generate-groups.sh lister,informer,client \
github.com/cilium/tetragon/pkg/k8s/client \
github.com/cilium/tetragon/pkg/k8s/apis \
cilium.io:v1alpha1 \
--go-header-file hack/custom-boilerplate.go.txt \
-o . \
--trim-path-prefix github.com/cilium/tetragon/pkg/k8s \
--plural-exceptions TracingPolicyNamespaced:TracingPoliciesNamespaced \
--plural-exceptions PodInfo:PodInfo \
./tools/k8s-code-gen.sh

.PHONY: vendor
vendor:
Expand Down
24 changes: 24 additions & 0 deletions pkg/k8s/tools/k8s-code-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

K8S_PKG="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/.."
CODEGEN_PKG=$K8S_PKG/vendor/k8s.io/code-generator

source "${CODEGEN_PKG}/kube_codegen.sh"

PLURAL_EXCEPTIONS="TracingPolicyNamespaced:TracingPoliciesNamespaced,PodInfo:PodInfo"

kube::codegen::gen_client \
--with-watch \
--output-dir "${K8S_PKG}/client" \
--output-pkg "github.com/cilium/tetragon/pkg/k8s/client" \
--plural-exceptions ${PLURAL_EXCEPTIONS} \
--boilerplate "${K8S_PKG}/hack/custom-boilerplate.go.txt" \
"${K8S_PKG}/apis"

kube::codegen::gen_helpers \
--boilerplate "${K8S_PKG}/hack/custom-boilerplate.go.txt" \
"${K8S_PKG}/apis"

0 comments on commit f6e5641

Please sign in to comment.