Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
Signed-off-by: André Martins <[email protected]>
  • Loading branch information
aanm committed Jun 19, 2024
1 parent 25fc62d commit f5f158e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 39 deletions.
39 changes: 1 addition & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,45 +230,8 @@ include Makefile.kind

-include Makefile.docker

##@ API targets
CRD_OPTIONS ?= "crd:crdVersions=v1"
CRD_PATHS := "$(PWD)/pkg/k8s/apis/cilium.io/v2;\
$(PWD)/pkg/k8s/apis/cilium.io/v2alpha1;"
CRDS_CILIUM_PATHS := $(PWD)/pkg/k8s/apis/cilium.io/client/crds/v2\
$(PWD)/pkg/k8s/apis/cilium.io/client/crds/v2alpha1
CRDS_CILIUM_V2 := ciliumnetworkpolicies \
ciliumclusterwidenetworkpolicies \
ciliumendpoints \
ciliumidentities \
ciliumnodes \
ciliumexternalworkloads \
ciliumlocalredirectpolicies \
ciliumegressgatewaypolicies \
ciliumenvoyconfigs \
ciliumclusterwideenvoyconfigs \
ciliumnodeconfigs
CRDS_CILIUM_V2ALPHA1 := ciliumendpointslices \
ciliumbgppeeringpolicies \
ciliumbgpclusterconfigs \
ciliumbgppeerconfigs \
ciliumbgpadvertisements \
ciliumbgpnodeconfigs \
ciliumbgpnodeconfigoverrides \
ciliumloadbalancerippools \
ciliumcidrgroups \
ciliuml2announcementpolicies \
ciliumpodippools

manifests: ## Generate K8s manifests e.g. CRD, RBAC etc.
$(eval TMPDIR := $(shell mktemp -d -t cilium.tmpXXXXXXXX))
$(QUIET)$(GO) run sigs.k8s.io/controller-tools/cmd/controller-gen $(CRD_OPTIONS) paths=$(CRD_PATHS) output:crd:artifacts:config="$(TMPDIR)"
$(QUIET)$(GO) run ./tools/crdcheck "$(TMPDIR)"
$(QUIET) # Clean up old CRD state and start with a blank state.
for path in $(CRDS_CILIUM_PATHS); do rm -rf $${path} && mkdir $${path}; done

for file in $(CRDS_CILIUM_V2); do mv ${TMPDIR}/cilium.io_$${file}.yaml ./pkg/k8s/apis/cilium.io/client/crds/v2/$${file}.yaml; done
for file in $(CRDS_CILIUM_V2ALPHA1); do mv ${TMPDIR}/cilium.io_$${file}.yaml ./pkg/k8s/apis/cilium.io/client/crds/v2alpha1/$${file}.yaml; done
rm -rf $(TMPDIR)
contrib/scripts/k8s-manifests-gen.sh

generate-api: api/v1/openapi.yaml ## Generate cilium-agent client, model and server code from openapi spec.
@$(ECHO_GEN)api/v1/openapi.yaml
Expand Down
62 changes: 62 additions & 0 deletions contrib/scripts/k8s-manifests-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

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

SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"

##@ API targets
# Set CRD_OPTIONS if not already set
CRD_OPTIONS="${CRD_OPTIONS:-"crd:crdVersions=v1"}"

# Set CRD_PATHS using the current working directory
CRD_PATHS="${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/v2;${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/v2alpha1;"

# Set CRDS_CILIUM_PATHS using the current working directory
CRDS_CILIUM_PATHS="${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/client/crds/v2 ${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/client/crds/v2alpha1"

# Set CRDS_CILIUM_V2 with the list of CRDs for v2
CRDS_CILIUM_V2="ciliumnetworkpolicies \
ciliumclusterwidenetworkpolicies \
ciliumendpoints \
ciliumidentities \
ciliumnodes \
ciliumexternalworkloads \
ciliumlocalredirectpolicies \
ciliumegressgatewaypolicies \
ciliumenvoyconfigs \
ciliumclusterwideenvoyconfigs \
ciliumnodeconfigs"

# Set CRDS_CILIUM_V2ALPHA1 with the list of CRDs for v2alpha1
CRDS_CILIUM_V2ALPHA1="ciliumendpointslices \
ciliumbgppeeringpolicies \
ciliumbgpclusterconfigs \
ciliumbgppeerconfigs \
ciliumbgpadvertisements \
ciliumbgpnodeconfigs \
ciliumbgpnodeconfigoverrides \
ciliumloadbalancerippools \
ciliumcidrgroups \
ciliuml2announcementpolicies \
ciliumpodippools"

TMPDIR=$(mktemp -d -t cilium.tmpXXXXXXXX)
go run sigs.k8s.io/controller-tools/cmd/controller-gen ${CRD_OPTIONS} paths="${CRD_PATHS}" output:crd:artifacts:config="${TMPDIR}"
go run ${SCRIPT_ROOT}/../../tools/crdcheck "${TMPDIR}"

# Clean up old CRD state and start with a blank state.
for path in ${CRDS_CILIUM_PATHS}; do
rm -rf "${path}" && mkdir "${path}"
done

for file in ${CRDS_CILIUM_V2}; do
mv "${TMPDIR}/cilium.io_${file}.yaml" "${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/client/crds/v2/${file}.yaml";
done

for file in ${CRDS_CILIUM_V2ALPHA1}; do
mv "${TMPDIR}/cilium.io_${file}.yaml" "${SCRIPT_ROOT}/../../pkg/k8s/apis/cilium.io/client/crds/v2alpha1/${file}.yaml";
done

rm -rf "${TMPDIR}"
1 change: 0 additions & 1 deletion pkg/k8s/apis/cilium.io/client/crds/v2/ciliumendpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
# Test to check if this file is regenerated
name: ciliumendpoints.cilium.io
spec:
group: cilium.io
Expand Down

0 comments on commit f5f158e

Please sign in to comment.