@@ -4,34 +4,15 @@ set -o errexit
4
4
set -o nounset
5
5
6
6
7
- SCRIPT_ROOT =$( git rev-parse --show-toplevel)
7
+ PROJECT_ROOT =$( git rev-parse --show-toplevel)
8
8
9
9
# Grab code-generator pkg
10
10
CODEGEN_PKG=$( go list -m -f ' {{.Dir}}' ' k8s.io/code-generator' )
11
11
echo " >> Using ${CODEGEN_PKG} "
12
12
13
- # code-generator does work with go.mod but makes assumptions about
14
- # the project living in `$GOPATH/src`. To work around this and support
15
- # any location; create a temporary directory, use this as an output
16
- # base, and copy everything back once generated.
17
- TEMP_DIR=$( mktemp -d)
18
- cleanup () {
19
- echo " >> Removing ${TEMP_DIR} "
20
- rm -rf " ${TEMP_DIR} "
21
- }
22
- trap " cleanup" EXIT SIGINT
23
13
24
- echo " >> Temporary output directory ${TEMP_DIR} "
14
+ source " ${CODEGEN_PKG} /kube_codegen.sh "
25
15
26
- # Ensure we can execute.
27
- chmod +x " ${CODEGEN_PKG} /generate-groups.sh"
28
- chmod +x " ${CODEGEN_PKG} /generate-internal-groups.sh"
29
-
30
- GOPATH=$( go env GOPATH) " ${CODEGEN_PKG} /generate-groups.sh" deepcopy,defaulter \
31
- _ github.com/weaveworks/eksctl/pkg/apis \
32
- eksctl.io:v1alpha5 \
33
- --go-header-file <( printf " /*\n%s\n*/\n" " $( cat LICENSE) " ) \
34
- --output-base " ${TEMP_DIR} "
35
-
36
- # Copy everything back.
37
- cp -r " ${TEMP_DIR} /github.com/weaveworks/eksctl/." " ${SCRIPT_ROOT} /"
16
+ kube::codegen::gen_helpers \
17
+ --boilerplate <( printf " /*\n%s\n*/\n" " $( cat LICENSE) " ) \
18
+ " ${PROJECT_ROOT} /pkg/apis"
0 commit comments