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

Add deepcopy generator checker #11165

Merged
merged 4 commits into from Apr 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 35 additions & 26 deletions Makefile
Expand Up @@ -32,6 +32,7 @@ BENCHFLAGS ?= $(BENCHFLAGS_EVAL)
LOGLEVEL ?= "error"
SKIP_VET ?= "false"
SKIP_KVSTORES ?= "false"
SKIP_K8S_CODE_GEN_CHECK ?= "true"

JOB_BASE_NAME ?= cilium_test

Expand Down Expand Up @@ -312,35 +313,39 @@ generate-health-api: api/v1/health/openapi.yaml
-t api/v1 -t api/v1/health/ -f api/v1/health/openapi.yaml

generate-k8s-api:
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"\
aws:types\
azure:types\
ipam:types\
k8s:types\
maps:ctmap\
maps:encrypt\
maps:eppolicymap\
maps:eventsmap\
maps:fragmap\
maps:ipcache\
maps:lbmap\
maps:lxcmap\
maps:metricsmap\
maps:nat\
maps:neighborsmap\
maps:policymap\
maps:signalmap\
maps:sockmap\
maps:tunnel\
node:types\
policy:api\
service:store\
")
$(call generate_k8s_api_all,github.com/cilium/cilium/pkg/k8s/apis,"cilium.io:v2")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg/aws,"eni:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"aws:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"azure:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"ipam:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"policy:api")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium,"pkg:loadbalancer")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium,"pkg:k8s")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/api,"v1:models")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"k8s:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:policymap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:ipcache")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:lxcmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:tunnel")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:encrypt")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:metricsmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:nat")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:lbmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:eppolicymap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:sockmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:ctmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:eventsmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:signalmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:neighborsmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"maps:fragmap")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"service:store")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium/pkg,"node:types")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium,"pkg:tuple")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium,"pkg:bpf")
$(call generate_k8s_api_deepcopy,github.com/cilium/cilium,"\
pkg:bpf\
pkg:k8s\
pkg:loadbalancer\
pkg:tuple\
")

vps:
VBoxManage list runningvms
Expand Down Expand Up @@ -420,6 +425,10 @@ microk8s: check-microk8s
@echo " microk8s.kubectl -n kube-system delete pod -l k8s-app=cilium"

precheck: ineffassign logging-subsys-field
ifeq ($(SKIP_K8S_CODE_GEN_CHECK),"false")
@$(ECHO_CHECK) contrib/scripts/check-k8s-code-gen.sh
$(QUIET) contrib/scripts/check-k8s-code-gen.sh
endif
@$(ECHO_CHECK) contrib/scripts/check-fmt.sh
$(QUIET) contrib/scripts/check-fmt.sh
@$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh
Expand Down
2 changes: 2 additions & 0 deletions api/v1/models/hubble_status.go

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

48 changes: 48 additions & 0 deletions api/v1/models/zz_generated.deepcopy.go

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

22 changes: 22 additions & 0 deletions contrib/scripts/check-k8s-code-gen.sh
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e
set -o pipefail

# Delete all zz_generated.deepcopy.go files
find . -not -path "./vendor/*" -iname "*zz_generated.deepcopy.go" -exec rm {} \;

# Generate all files
make generate-k8s-api

# Check for diff
diff="$(git diff)"

if [ -n "$diff" ]; then
echo "Ungenerated deepcopy source code:"
echo "$diff"
echo "Please run make generate-k8s-api and submit your changes"
exit 1
fi

exit 0
16 changes: 16 additions & 0 deletions pkg/azure/types/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion test/provision/compile.sh
Expand Up @@ -72,7 +72,7 @@ then
fi
else
echo "compiling cilium..."
sudo -u vagrant -H -E make LOCKDEBUG=1 SKIP_DOCS=true
sudo -u vagrant -H -E make LOCKDEBUG=1 SKIP_K8S_CODE_GEN_CHECK=false SKIP_DOCS=true
echo "installing cilium..."
make install
mkdir -p /etc/sysconfig/
Expand Down