1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Utilize go generate

Use 'go generate' for auto-generating code. Drop the old 'mock' and
'apigen' makefile targets. Those are replaced with a single
  make generate

which (re-)generates everything.
This commit is contained in:
Markus Lehtonen 2021-09-21 12:46:41 +03:00
parent 16139ae1f5
commit 9487fbeb18
5 changed files with 48 additions and 9 deletions

View file

@ -98,15 +98,10 @@ templates:
-e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml -e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml
@rm nfd-worker.conf.tmp @rm nfd-worker.conf.tmp
mock: generate:
mockery --name=LabelSource --dir=source --inpkg --note="Re-generate by running 'make mock'" go mod vendor
mockery --name=APIHelpers --dir=pkg/apihelper --inpkg --note="Re-generate by running 'make mock'" go generate ./cmd/... ./pkg/... ./source/...
mockery --name=LabelerClient --dir=pkg/labeler --inpkg --note="Re-generate by running 'make mock'" rm -rf vendor/
mockery --name=NodeTopologyClient --dir=pkg/topologyupdater --inpkg --note="Re-generate by running 'make mock'"
apigen:
protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. pkg/labeler/labeler.proto
protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. pkg/topologyupdater/topology-updater.proto
gofmt: gofmt:
@$(GO_FMT) -w -l $$(find . -name '*.go') @$(GO_FMT) -w -l $$(find . -name '*.go')

View file

@ -16,6 +16,8 @@ limitations under the License.
package apihelper package apihelper
//go:generate mockery --name=APIHelpers --inpkg
import ( import (
topologyclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned" topologyclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned"
api "k8s.io/api/core/v1" api "k8s.io/api/core/v1"

20
pkg/labeler/doc.go Normal file
View file

@ -0,0 +1,20 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package labeler
//go:generate protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. labeler.proto
//go:generate mockery --name=LabelerClient --inpkg

View file

@ -0,0 +1,20 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package topologyupdater
//go:generate protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. -I . -I ../../vendor/ topology-updater.proto
//go:generate mockery --name=NodeTopologyClient --inpkg

View file

@ -16,6 +16,8 @@ limitations under the License.
package source package source
//go:generate mockery --name=LabelSource --inpkg
import ( import (
"fmt" "fmt"
) )