Skip to content

Commit 6a5875a

Browse files
committed
Do code generation non-containerized
Also clean-up hack/update_codegen.sh script a bit.
1 parent 2aae104 commit 6a5875a

File tree

6 files changed

+7
-55
lines changed

6 files changed

+7
-55
lines changed

Dockerfile_generator

Lines changed: 0 additions & 15 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,8 @@ templates:
151151
@rm nfd-worker.conf.tmp
152152
@rm nfd-topology-updater.conf.tmp
153153

154-
.generator.image.stamp: Dockerfile_generator
155-
$(IMAGE_BUILD_CMD) \
156-
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
157-
-t nfd-generator \
158-
-f Dockerfile_generator .
159-
160-
generate: .generator.image.stamp
161-
$(CONTAINER_RUN_CMD) --rm \
162-
-v "`pwd`:/go/node-feature-discovery" \
163-
-v "`go env GOCACHE`:/.cache" \
164-
-v "`go env GOMODCACHE`:/go/pkg/mod" \
165-
--user=`id -u`:`id -g`\
166-
nfd-generator \
167-
./hack/update_codegen.sh
154+
generate:
155+
hack/update_codegen.sh
168156

169157
gofmt:
170158
@$(GO_FMT) -w -l $$(find . -name '*.go')

hack/update_codegen.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,19 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
TMP_VENDOR_DIR=gen-vendor
22-
23-
function cleanup() {
24-
echo "Cleaning up..."
25-
rm -rf ${TMP_VENDOR_DIR}
26-
# We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file.
27-
"${GO_CMD}" mod tidy
28-
}
29-
30-
# Temporal work around until https://github.com/kubernetes/kubernetes/pull/125051 is merged
31-
# and added to a release.
32-
find api/generated/ -name 'nodefeature*' | xargs rm
33-
34-
trap cleanup EXIT
3521
GO_CMD=${1:-go}
3622
NFD_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
3723

38-
"${GO_CMD}" mod vendor
39-
4024
# Go generate
4125
"${GO_CMD}" generate ./cmd/... ./pkg/... ./source/...
4226

4327
# Generate CRDs
44-
controller-gen object crd output:crd:stdout paths=./api/... > deployment/base/nfd-crds/nfd-api-crds.yaml
28+
go tool controller-gen object crd output:crd:stdout paths=./api/... > deployment/base/nfd-crds/nfd-api-crds.yaml
4529
mkdir -p deployment/helm/node-feature-discovery/crds
4630
cp deployment/base/nfd-crds/nfd-api-crds.yaml deployment/helm/node-feature-discovery/crds
4731

4832
# Generate clientset and informers
49-
mv vendor ${TMP_VENDOR_DIR}
50-
CODEGEN_PKG=${CODEGEN_PKG:-$(ls -d -1 ./${TMP_VENDOR_DIR}/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
33+
CODEGEN_PKG=$(go list -m -f '{{.Dir}}' k8s.io/code-generator)
5134

5235
cd $(dirname ${BASH_SOURCE[0]})/..
5336

@@ -58,10 +41,6 @@ kube::codegen::gen_helpers \
5841
${NFD_ROOT}/api/nfd \
5942
--boilerplate ${NFD_ROOT}/hack/boilerplate.go.txt
6043

61-
# HACK: manually patching the auto-generated code as code-generator cannot
62-
# properly handle deepcopy of MatchExpressionSet.
63-
sed s'/out = new(map\[string\]\*MatchExpression)/out = new(MatchExpressionSet)/' -i api/nfd/v1alpha1/zz_generated.deepcopy.go
64-
6544
# Switch to work in the api worktree
6645
pushd "${NFD_ROOT}/api/nfd" > /dev/null
6746

pkg/client-nfd/compat/artifact-client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package compat
1818

19-
//go:generate mockery --name=ArtifactClient --inpackage
19+
//go:generate go tool mockery --name=ArtifactClient --inpackage
2020

2121
import (
2222
"context"

pkg/podres/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package podres
1818

19-
//go:generate mockery --srcpkg=k8s.io/kubelet/pkg/apis/podresources/v1 --name PodResourcesListerClient
19+
//go:generate go tool mockery --srcpkg=k8s.io/kubelet/pkg/apis/podresources/v1 --name PodResourcesListerClient
2020

2121
import (
2222
"fmt"

source/source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package source
1818

19-
//go:generate mockery --name=LabelSource --inpackage
19+
//go:generate go tool mockery --name=LabelSource --inpackage
2020

2121
import (
2222
"fmt"

0 commit comments

Comments
 (0)