diff --git a/Makefile b/Makefile index 4cc10c3..f91dc64 100644 --- a/Makefile +++ b/Makefile @@ -110,12 +110,9 @@ check: $(GOIMPORTS) $(GOLANGCI_LINT) $(MOCKGEN) @REPO_ROOT=$(REPO_ROOT) bash $(GARDENER_HACK_DIR)/check-charts.sh ./charts .PHONY: generate -generate: deepcopy-gen defaulter-gen conversion-gen $(CONTROLLER_GEN) $(HELM) $(MOCKGEN) $(YQ) $(VGOPATH) +generate: $(CONTROLLER_GEN) $(HELM) $(MOCKGEN) $(YQ) $(VGOPATH) @GOPATH=$(GOPATH) VGOPATH=$(VGOPATH) \ MOCKGEN=$(MOCKGEN) \ - DEEPCOPY_GEN=$(DEEPCOPY_GEN) \ - DEFAULTER_GEN=$(DEFAULTER_GEN) \ - CONVERSION_GEN=$(CONVERSION_GEN) \ REPO_ROOT=$(REPO_ROOT) \ GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) \ bash $(GARDENER_HACK_DIR)/generate-sequential.sh ./charts/... ./cmd/... ./example/... ./pkg/... @@ -163,9 +160,6 @@ $(LOCALBIN): mkdir -p $(LOCALBIN) ## Tool Binaries -DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen -CONVERSION_GEN ?= $(LOCALBIN)/conversion-gen -DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions @@ -178,18 +172,3 @@ ENVTEST_K8S_VERSION = 1.31.0 envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest - -.PHONY: deepcopy-gen -deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary. -$(DEEPCOPY_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(CODE_GENERATOR_VERSION) - -.PHONY: defaulter-gen -defaulter-gen: $(DEFAULTER_GEN) ## Download defaulter-gen locally if necessary. -$(DEFAULTER_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/defaulter-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/defaulter-gen@$(CODE_GENERATOR_VERSION) - -.PHONY: conversion-gen -conversion-gen: $(CONVERSION_GEN) ## Download conversion-gen locally if necessary. -$(CONVERSION_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/conversion-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/conversion-gen@$(CODE_GENERATOR_VERSION) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 77a0132..25d0c06 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -1,86 +1,24 @@ -#!/usr/bin/env bash +#!/bin/bash set -o errexit set -o nounset set -o pipefail -BASE_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -export TERM="xterm-256color" - -VGOPATH="$VGOPATH" -DEEPCOPY_GEN="$DEEPCOPY_GEN" -DEFAULTER_GEN="$DEFAULTER_GEN" -CONVERSION_GEN="$CONVERSION_GEN" - -bold="$(tput bold)" -blue="$(tput setaf 4)" -normal="$(tput sgr0)" - -function qualify-gvs() { - APIS_PKG="$1" - GROUPS_WITH_VERSIONS="$2" - join_char="" - res="" - - for GVs in ${GROUPS_WITH_VERSIONS}; do - IFS=: read -r G Vs <<<"${GVs}" - - for V in ${Vs//,/ }; do - res="$res$join_char$APIS_PKG/$G/$V" - join_char="," - done - done - - echo "$res" -} - -function qualify-gs() { - APIS_PKG="$1" - unset GROUPS - IFS=' ' read -ra GROUPS <<< "$2" - join_char="" - res="" - - for G in "${GROUPS[@]}"; do - res="$res$join_char$APIS_PKG/$G" - join_char="," - done - - echo "$res" -} - # setup virtual GOPATH source "$GARDENER_HACK_DIR"/vgopath-setup.sh -# We need to explicitly pass GO111MODULE=off to k8s.io/code-generator as it is significantly slower otherwise, -# see https://github.com/kubernetes/code-generator/issues/100. -export GO111MODULE=off - -echo "${bold}Public types${normal}" - -echo "Generating ${blue}deepcopy${normal}" -"$DEEPCOPY_GEN" \ - --go-header-file "$BASE_DIR/boilerplate.go.txt" \ - --input-dirs "$(qualify-gvs "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis" "config:v1alpha1 metal:v1alpha1")" \ - -O zz_generated.deepcopy +CODE_GEN_DIR=$(go list -m -f '{{.Dir}}' k8s.io/code-generator) +source "${CODE_GEN_DIR}/kube_codegen.sh" -echo "${bold}Internal types${normal}" +rm -f $GOPATH/bin/*-gen -echo "Generating ${blue}deepcopy${normal}" -"$DEEPCOPY_GEN" \ - --go-header-file "$BASE_DIR/boilerplate.go.txt" \ - --input-dirs "$(qualify-gs "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis" "config metal")" \ - -O zz_generated.deepcopy +CURRENT_DIR=$(dirname $0) +PROJECT_ROOT="${CURRENT_DIR}"/.. -echo "Generating ${blue}defaulter${normal}" -"$DEFAULTER_GEN" \ - --go-header-file "$BASE_DIR/boilerplate.go.txt" \ - --input-dirs "$(qualify-gvs "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis" "config:v1alpha1 metal:v1alpha1")" \ - -O zz_generated.defaults +kube::codegen::gen_helpers \ + --boilerplate "${GARDENER_HACK_DIR}/LICENSE_BOILERPLATE.txt" \ + "${PROJECT_ROOT}/pkg/apis/metal" -echo "Generating ${blue}conversion${normal}" -"$CONVERSION_GEN" \ - --go-header-file "$BASE_DIR/boilerplate.go.txt" \ - --input-dirs "$(qualify-gs "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis" "config metal")" \ - --input-dirs "$(qualify-gvs "github.com/ironcore-dev/gardener-extension-provider-metal/pkg/apis" "config:v1alpha1 metal:v1alpha1")" \ - -O zz_generated.conversion +kube::codegen::gen_helpers \ + --boilerplate "${GARDENER_HACK_DIR}/LICENSE_BOILERPLATE.txt" \ + "${PROJECT_ROOT}/pkg/apis/config" \ No newline at end of file diff --git a/pkg/apis/config/v1alpha1/zz_generated.conversion.go b/pkg/apis/config/v1alpha1/zz_generated.conversion.go index 3b81f97..92c2dbf 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/config/v1alpha1/zz_generated.conversion.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by conversion-gen. DO NOT EDIT. diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go index ad1f617..5e9554c 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by deepcopy-gen. DO NOT EDIT. diff --git a/pkg/apis/config/v1alpha1/zz_generated.defaults.go b/pkg/apis/config/v1alpha1/zz_generated.defaults.go index d1bc6c9..dce68e6 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.defaults.go +++ b/pkg/apis/config/v1alpha1/zz_generated.defaults.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by defaulter-gen. DO NOT EDIT. diff --git a/pkg/apis/config/zz_generated.deepcopy.go b/pkg/apis/config/zz_generated.deepcopy.go index 2bc3238..8ab4b88 100644 --- a/pkg/apis/config/zz_generated.deepcopy.go +++ b/pkg/apis/config/zz_generated.deepcopy.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by deepcopy-gen. DO NOT EDIT. diff --git a/pkg/apis/metal/v1alpha1/zz_generated.conversion.go b/pkg/apis/metal/v1alpha1/zz_generated.conversion.go index 32bb196..72ecad8 100644 --- a/pkg/apis/metal/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/metal/v1alpha1/zz_generated.conversion.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by conversion-gen. DO NOT EDIT. diff --git a/pkg/apis/metal/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/metal/v1alpha1/zz_generated.deepcopy.go index 520f4cd..bad12ef 100644 --- a/pkg/apis/metal/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/metal/v1alpha1/zz_generated.deepcopy.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by deepcopy-gen. DO NOT EDIT. diff --git a/pkg/apis/metal/v1alpha1/zz_generated.defaults.go b/pkg/apis/metal/v1alpha1/zz_generated.defaults.go index b3026ac..dce68e6 100644 --- a/pkg/apis/metal/v1alpha1/zz_generated.defaults.go +++ b/pkg/apis/metal/v1alpha1/zz_generated.defaults.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by defaulter-gen. DO NOT EDIT. @@ -16,16 +17,5 @@ import ( // Public to allow building arbitrary schemes. // All generated defaulters are covering - they call all nested defaulters. func RegisterDefaults(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&WorkerConfig{}, func(obj interface{}) { SetObjectDefaults_WorkerConfig(obj.(*WorkerConfig)) }) return nil } - -func SetObjectDefaults_WorkerConfig(in *WorkerConfig) { - if in.ExtraIgnition != nil { - if in.ExtraIgnition.SecretRef != nil { - if in.ExtraIgnition.SecretRef.Name == "" { - in.ExtraIgnition.SecretRef.Name = "" - } - } - } -} diff --git a/pkg/apis/metal/zz_generated.deepcopy.go b/pkg/apis/metal/zz_generated.deepcopy.go index f79938b..c32898c 100644 --- a/pkg/apis/metal/zz_generated.deepcopy.go +++ b/pkg/apis/metal/zz_generated.deepcopy.go @@ -1,7 +1,8 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors +// // SPDX-License-Identifier: Apache-2.0 // Code generated by deepcopy-gen. DO NOT EDIT.