Skip to content

Commit

Permalink
Merge pull request #829 from marquiz/devel/generate-containerized
Browse files Browse the repository at this point in the history
Containerized auto-generation
  • Loading branch information
k8s-ci-robot authored Aug 10, 2022
2 parents 07e9d5b + ac3030c commit b78f65e
Show file tree
Hide file tree
Showing 35 changed files with 156 additions and 53 deletions.
22 changes: 22 additions & 0 deletions Dockerfile_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.18-buster as builder

# Install tools
RUN go install github.com/vektra/mockery/[email protected] && \
go install sigs.k8s.io/controller-tools/cmd/[email protected] && \
git clone https://github.com/kubernetes/code-generator -b v0.20.7 --depth 1 && \
go install k8s.io/code-generator/cmd/[email protected] && \
go install golang.org/x/tools/cmd/[email protected] && \
go install github.com/golang/protobuf/[email protected]

RUN apt-get update && apt-get install unzip

RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-linux-x86_64.zip && \
unzip protoc-3.17.3-linux-x86_64.zip -d /usr/local && \
rm protoc-3.17.3-linux-x86_64.zip && \
chmod a+x /usr/local/bin/protoc && \
find /usr/local -type d | xargs chmod 755 && \
find /usr/local -type f | xargs chmod a+r


# Expect to be working with nfd
WORKDIR /go/node-feature-discovery
28 changes: 11 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ BASE_IMAGE_MINIMAL ?= gcr.io/distroless/base

MDL ?= mdl

K8S_CODE_GENERATOR ?= ../code-generator

# Docker base command for working with html documentation.
# Use host networking because 'jekyll serve' is stupid enough to use the
# same site url than the "host" it binds to. Thus, all the links will be
Expand Down Expand Up @@ -129,21 +127,17 @@ templates:
-e "}; /$$end/p; d }" -i deployment/helm/node-feature-discovery/values.yaml
@rm nfd-worker.conf.tmp

generate:
go mod vendor
go generate ./cmd/... ./pkg/... ./source/...
rm -rf vendor/
controller-gen object crd output:crd:stdout paths=./pkg/apis/... > deployment/base/nfd-crds/nodefeaturerule-crd.yaml
cp deployment/base/nfd-crds/nodefeaturerule-crd.yaml deployment/helm/node-feature-discovery/manifests/
rm -rf sigs.k8s.io
$(K8S_CODE_GENERATOR)/generate-groups.sh client,informer,lister \
sigs.k8s.io/node-feature-discovery/pkg/generated \
sigs.k8s.io/node-feature-discovery/pkg/apis \
"nfd:v1alpha1" --output-base=. \
--go-header-file hack/boilerplate.go.txt
rm -rf pkg/generated
mv sigs.k8s.io/node-feature-discovery/pkg/generated pkg/
rm -rf sigs.k8s.io
.generator.image.stamp: Dockerfile_generator
$(IMAGE_BUILD_CMD) -t nfd-generator -f Dockerfile_generator .

generate: .generator.image.stamp
$(CONTAINER_RUN_CMD) --rm \
-v "`pwd`:/go/node-feature-discovery" \
-v "`go env GOCACHE`:/.cache" \
-v "`go env GOMODCACHE`:/go/pkg/mod" \
--user=`id -u`:`id -g`\
nfd-generator \
./hack/generate.sh

gofmt:
@$(GO_FMT) -w -l $$(find . -name '*.go')
Expand Down
30 changes: 30 additions & 0 deletions hack/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash -e
set -o pipefail

# Default path for code-generator repo
K8S_CODE_GENERATOR=${K8S_CODE_GENERATOR:-../code-generator}

go mod vendor

go generate ./cmd/... ./pkg/... ./source/...

rm -rf vendor/

controller-gen object crd output:crd:stdout paths=./pkg/apis/... > deployment/base/nfd-crds/nodefeaturerule-crd.yaml

cp deployment/base/nfd-crds/nodefeaturerule-crd.yaml deployment/helm/node-feature-discovery/manifests/

rm -rf sigs.k8s.io

${K8S_CODE_GENERATOR}/generate-groups.sh client,informer,lister \
sigs.k8s.io/node-feature-discovery/pkg/generated \
sigs.k8s.io/node-feature-discovery/pkg/apis \
"nfd:v1alpha1" --output-base=. \
--go-header-file hack/boilerplate.go.txt

rm -rf pkg/generated

mv sigs.k8s.io/node-feature-discovery/pkg/generated pkg/

rm -rf sigs.k8s.io

2 changes: 1 addition & 1 deletion pkg/api/feature/generated.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/feature/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apihelper/apihelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

package apihelper

//go:generate mockery --name=APIHelpers --inpkg
//go:generate mockery --name=APIHelpers --inpackage

import (
topologyclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned"
Expand Down
17 changes: 16 additions & 1 deletion pkg/apihelper/mock_APIHelpers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions pkg/generated/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/fake/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/scheme/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/informers/externalversions/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/informers/externalversions/generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/informers/externalversions/nfd/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/listers/nfd/v1alpha1/expansion_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/listers/nfd/v1alpha1/nodefeaturerule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/labeler/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ limitations under the License.
package labeler

//go:generate protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. -I . -I ../.. -I ../../vendor labeler.proto
//go:generate mockery --name=LabelerClient --inpkg
//go:generate mockery --name=LabelerClient --inpackage
17 changes: 16 additions & 1 deletion pkg/labeler/mock_LabelerClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/topologyupdater/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ 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
//go:generate mockery --name=NodeTopologyClient --inpackage
17 changes: 16 additions & 1 deletion pkg/topologyupdater/mock_NodeTopologyClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion source/mock_LabelSource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b78f65e

Please sign in to comment.