Skip to content

Commit

Permalink
Update code generator script
Browse files Browse the repository at this point in the history
The script we were using is fully deprecated so we need to upgrade
to a new code generator.
  • Loading branch information
thomasferrandiz committed Dec 16, 2024
1 parent 5bc9a84 commit daa12ca
Show file tree
Hide file tree
Showing 47 changed files with 343 additions and 750 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Generate code
if: steps.changed-files.outputs.any_changed == 'true'
run: chmod +x vendor/k8s.io/code-generator/generate-internal-groups.sh && ./hack/generate-code.sh && hack/verify-codegen.sh
run: ./hack/generate-code.sh && hack/verify-codegen.sh

- name: Run go fmt
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down
4 changes: 2 additions & 2 deletions cmd/controlloop/controlloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
nadclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned"
nadinformers "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/informers/externalversions"

wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned"
wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/controlloop"
wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned"
wbinformers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/logging"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/reconciler"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/nodeslicecontroller/node_slice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"

clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned"
informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/informers/externalversions"
clientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned"
informers "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/informers/externalversions"
node_controller "github.com/k8snetworkplumbingwg/whereabouts/pkg/node-controller"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/node-controller/signals"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/whereabouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (

"github.com/k8snetworkplumbingwg/whereabouts/pkg/allocate"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1"
wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned/fake"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/config"
wbclientset "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned/fake"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes"
whereaboutstypes "github.com/k8snetworkplumbingwg/whereabouts/pkg/types"
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/client/whereabouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/k8snetworkplumbingwg/whereabouts/e2e/entities"
whereaboutscnicncfiov1alpha1 "github.com/k8snetworkplumbingwg/whereabouts/pkg/api/whereabouts.cni.cncf.io/v1alpha1"
wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/client/clientset/versioned"
wbclient "github.com/k8snetworkplumbingwg/whereabouts/pkg/generated/clientset/versioned"
)

const (
Expand Down
16 changes: 10 additions & 6 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ set -o pipefail

SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

bash ./vendor/k8s.io/code-generator/generate-groups.sh "client,informer,lister" \
github.com/k8snetworkplumbingwg/whereabouts/pkg/client \
github.com/k8snetworkplumbingwg/whereabouts/pkg/api \
whereabouts.cni.cncf.io:v1alpha1 \
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
source "${CODEGEN_PKG}/kube_codegen.sh"

cp -r github.com/k8snetworkplumbingwg/whereabouts/pkg/client/* pkg/client
THIS_PKG="github.com/k8snetworkplumbingwg/whereabouts"

kube::codegen::gen_client \
--with-watch \
--output-dir "${SCRIPT_ROOT}/pkg/generated" \
--output-pkg "${THIS_PKG}/pkg/generated" \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
"${SCRIPT_ROOT}/pkg/api"

8 changes: 4 additions & 4 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
DIFFROOT="${SCRIPT_ROOT}/pkg"
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg"
_tmp="${SCRIPT_ROOT}/_tmp"
TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg"

cleanup() {
rm -rf "${_tmp}"
rm -rf "${TMP_DIFFROOT}"
}
trap "cleanup" EXIT SIGINT

Expand All @@ -20,6 +19,7 @@ mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"

"${SCRIPT_ROOT}/hack/update-codegen.sh"

echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
Expand Down

This file was deleted.

Loading

0 comments on commit daa12ca

Please sign in to comment.