-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.sh
78 lines (64 loc) · 2.15 KB
/
codegen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
set -o errexit
set -o pipefail
SCRIPT_DIR=$(dirname $(realpath "${BASH_SOURCE[0]}"))
ROOT_DIR=$(pwd)
CODEGEN_PKG=$(go env GOPATH)/pkg/mod/k8s.io/[email protected]
API_PKG_PATH="github.com/nod-ai/topology-aware-scheduler"
echo "Cleaning up previously generated code..."
rm -rf pkg/generated/*
# Create a temporary build directory with proper permissions
TEMP_DIR=$(mktemp -d)
chmod 755 "${TEMP_DIR}"
echo "Using temp directory: ${TEMP_DIR}"
# Create the full directory structure in temp
mkdir -p "${TEMP_DIR}/src/${API_PKG_PATH}"
cp -r "${ROOT_DIR}"/* "${TEMP_DIR}/src/${API_PKG_PATH}/"
# Set permissions recursively
chmod -R 755 "${TEMP_DIR}"
# Run the generator from the temp directory
cd "${TEMP_DIR}/src/${API_PKG_PATH}"
echo "Running code generator..."
# Generate deepcopy
${CODEGEN_PKG}/generate-groups.sh \
"deepcopy" \
${API_PKG_PATH}/pkg/generated \
${API_PKG_PATH}/pkg/apis \
"topology:v1alpha1" \
--output-base "${TEMP_DIR}/src" \
--go-header-file "${PWD}/boilerplate.go.txt"
# Generate client
${CODEGEN_PKG}/generate-groups.sh \
"client" \
${API_PKG_PATH}/pkg/generated \
${API_PKG_PATH}/pkg/apis \
"topology:v1alpha1" \
--output-base "${TEMP_DIR}/src" \
--go-header-file "${PWD}/boilerplate.go.txt"
# Generate informers
${CODEGEN_PKG}/generate-groups.sh \
"informer" \
${API_PKG_PATH}/pkg/generated \
${API_PKG_PATH}/pkg/apis \
"topology:v1alpha1" \
--output-base "${TEMP_DIR}/src" \
--go-header-file "${PWD}/boilerplate.go.txt"
# Generate listers
${CODEGEN_PKG}/generate-groups.sh \
"lister" \
${API_PKG_PATH}/pkg/generated \
${API_PKG_PATH}/pkg/apis \
"topology:v1alpha1" \
--output-base "${TEMP_DIR}/src" \
--go-header-file "${PWD}/boilerplate.go.txt"
# Copy the generated files back
if [ -d "${TEMP_DIR}/src/${API_PKG_PATH}/pkg/generated" ]; then
mkdir -p "${ROOT_DIR}/pkg/generated"
cp -r "${TEMP_DIR}/src/${API_PKG_PATH}/pkg/generated"/* "${ROOT_DIR}/pkg/generated/"
fi
# Cleanup with sudo if needed
if [ -d "${TEMP_DIR}" ]; then
sudo rm -rf "${TEMP_DIR}"
fi
echo "Code generation complete!"
ls -la pkg/generated/