Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit b22351f

Browse files
committed
Fixing the code generation scripts
1 parent 0cf4ade commit b22351f

File tree

5 files changed

+46
-39
lines changed

5 files changed

+46
-39
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ test:
3737
unit:
3838
codegen:
3939
$(shell ./hack/update-codegen.sh)
40+
$(shell ./hack/update-crd.sh)
4041

4142
include release-tools/build.make

hack/boilerplate.go.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Kubernetes Authors.
2+
Copyright 2022 The Kubernetes Authors.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

hack/tools.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//go:build tools
2+
// +build tools
3+
4+
/*
5+
Copyright 2022 The Kubernetes Authors.
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// This package imports things required by build scripts, to force `go mod` to see them as dependencies
18+
package tools
19+
20+
import (
21+
_ "k8s.io/code-generator"
22+
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
23+
)

hack/update-codegen.sh

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,11 @@
11
#!/bin/bash
22

3-
SCRIPT_ROOT=$(dirname $0)
4-
5-
deepcopy-gen --input-dirs sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1 \
6-
--go-header-file hack/boilerplate.go.txt \
7-
--output-base $GOPATH/src \
8-
--output-file-base zz_generated.deepcopy \
9-
--output-package sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1
10-
11-
openapi-gen --input-dirs sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1 \
12-
--go-header-file hack/boilerplate.go.txt \
13-
--output-base $GOPATH/src \
14-
--output-package sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1
15-
16-
defaulter-gen --input-dirs sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1 \
17-
--go-header-file hack/boilerplate.go.txt \
18-
--output-base $GOPATH/src \
19-
--output-package sigs.k8s.io/container-object-storage-interface-api/defaulters
20-
21-
lister-gen --input-dirs sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1 \
22-
--go-header-file hack/boilerplate.go.txt \
23-
--output-base $GOPATH/src \
24-
--output-package sigs.k8s.io/container-object-storage-interface-api/listers
25-
26-
informer-gen --input-dirs sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1 \
27-
--go-header-file hack/boilerplate.go.txt \
28-
--output-base $GOPATH/src \
29-
--listers-package sigs.k8s.io/container-object-storage-interface-api/listers \
30-
--versioned-clientset-package sigs.k8s.io/container-object-storage-interface-api/clientset \
31-
--output-package sigs.k8s.io/container-object-storage-interface-api/informers
32-
33-
client-gen --input objectstorage.k8s.io/v1alpha1 \
34-
--go-header-file hack/boilerplate.go.txt \
35-
--input-base sigs.k8s.io/container-object-storage-interface-api/apis/ \
36-
--output-package sigs.k8s.io/container-object-storage-interface-api/ \
37-
--output-base $GOPATH/src \
38-
--clientset-name "clientset"
39-
40-
controller-gen crd:crdVersions=v1 paths=$SCRIPT_ROOT/../apis/... output:dir=$SCRIPT_ROOT/../crds
3+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
4+
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
5+
6+
bash "${CODEGEN_PKG}"/generate-internal-groups.sh "deepcopy,client,informer,lister,openapi" \
7+
sigs.k8s.io/container-object-storage-interface-api/client \
8+
sigs.k8s.io/container-object-storage-interface-api/apis \
9+
sigs.k8s.io/container-object-storage-interface-api/apis \
10+
objectstorage:v1alpha1 \
11+
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"

hack/update-crd.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
SCRIPT_ROOT_RELATIVE=$(dirname "${BASH_SOURCE}")/..
4+
SCRIPT_ROOT=$(realpath "${SCRIPT_ROOT_RELATIVE}")
5+
CONTROLLERTOOLS_PKG=${CONTROLLERTOOLS_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/sigs.k8s.io/controller-tools 2>/dev/null || echo ../code-controller-tools)}
6+
7+
echo $CONTROLLERTOOLS_PKG
8+
9+
# find or download controller-gen
10+
pushd "${CONTROLLERTOOLS_PKG}"
11+
trap popd exit
12+
go run -v ./cmd/controller-gen crd:crdVersions=v1 paths="${SCRIPT_ROOT}/apis/..." output:crd:dir="${SCRIPT_ROOT}/crds"

0 commit comments

Comments
 (0)