diff --git a/Makefile b/Makefile index 6f8a9224414b..bbb90272c622 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 diff --git a/api/v1/models/hubble_status.go b/api/v1/models/hubble_status.go index 226c5f529ea1..9d6659016120 100644 --- a/api/v1/models/hubble_status.go +++ b/api/v1/models/hubble_status.go @@ -17,6 +17,7 @@ import ( // HubbleStatus Status of the Hubble server // swagger:model HubbleStatus +// +k8s:deepcopy-gen=true type HubbleStatus struct { // metrics @@ -250,6 +251,7 @@ func (m *HubbleStatusMetrics) UnmarshalBinary(b []byte) error { // HubbleStatusObserver Status of the Hubble observer // swagger:model HubbleStatusObserver +// +k8s:deepcopy-gen=true type HubbleStatusObserver struct { // Current number of flows this Hubble observer stores diff --git a/api/v1/models/zz_generated.deepcopy.go b/api/v1/models/zz_generated.deepcopy.go index 136fd1b2aaa1..f870bc213d9b 100644 --- a/api/v1/models/zz_generated.deepcopy.go +++ b/api/v1/models/zz_generated.deepcopy.go @@ -126,6 +126,49 @@ func (in *ControllerStatusStatus) DeepCopy() *ControllerStatusStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HubbleStatus) DeepCopyInto(out *HubbleStatus) { + *out = *in + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = new(HubbleStatusMetrics) + **out = **in + } + if in.Observer != nil { + in, out := &in.Observer, &out.Observer + *out = new(HubbleStatusObserver) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HubbleStatus. +func (in *HubbleStatus) DeepCopy() *HubbleStatus { + if in == nil { + return nil + } + out := new(HubbleStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HubbleStatusObserver) DeepCopyInto(out *HubbleStatusObserver) { + *out = *in + in.Uptime.DeepCopyInto(&out.Uptime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HubbleStatusObserver. +func (in *HubbleStatusObserver) DeepCopy() *HubbleStatusObserver { + if in == nil { + return nil + } + out := new(HubbleStatusObserver) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPAMStatus) DeepCopyInto(out *IPAMStatus) { *out = *in @@ -493,6 +536,11 @@ func (in *StatusResponse) DeepCopyInto(out *StatusResponse) { } } } + if in.Hubble != nil { + in, out := &in.Hubble, &out.Hubble + *out = new(HubbleStatus) + (*in).DeepCopyInto(*out) + } if in.Ipam != nil { in, out := &in.Ipam, &out.Ipam *out = new(IPAMStatus) diff --git a/contrib/scripts/check-k8s-code-gen.sh b/contrib/scripts/check-k8s-code-gen.sh new file mode 100755 index 000000000000..47eab81c02d3 --- /dev/null +++ b/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 diff --git a/pkg/azure/types/zz_generated.deepcopy.go b/pkg/azure/types/zz_generated.deepcopy.go index a01dd2c9a05e..20a1e249ebe5 100644 --- a/pkg/azure/types/zz_generated.deepcopy.go +++ b/pkg/azure/types/zz_generated.deepcopy.go @@ -39,6 +39,22 @@ func (in *AzureInterface) DeepCopy() *AzureInterface { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureSpec) DeepCopyInto(out *AzureSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureSpec. +func (in *AzureSpec) DeepCopy() *AzureSpec { + if in == nil { + return nil + } + out := new(AzureSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AzureStatus) DeepCopyInto(out *AzureStatus) { *out = *in diff --git a/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go index 3699f3d42681..b66003cd3607 100644 --- a/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go +++ b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go @@ -535,6 +535,7 @@ func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { out.HealthAddressing = in.HealthAddressing out.Encryption = in.Encryption in.ENI.DeepCopyInto(&out.ENI) + out.Azure = in.Azure in.IPAM.DeepCopyInto(&out.IPAM) return } diff --git a/test/provision/compile.sh b/test/provision/compile.sh index 0d94e6fbe482..5d4ef28e1b8c 100755 --- a/test/provision/compile.sh +++ b/test/provision/compile.sh @@ -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/