From cd5b1b659657047bd1992bdec283a89b6b7bf1fb Mon Sep 17 00:00:00 2001 From: Tobias Gruner Date: Wed, 19 Aug 2026 09:56:10 +0200 Subject: [PATCH] Run gofmt before generating config/crd/bases CRDs controller-gen crd runs twice per service across build-controller.sh (config/crd/bases) and build-controller-release.sh (helm/crds), reading from the same generated apis/ Go source tree. gofmt's doc-comment reformatter rewrites Markdown "*" list markers to "-" (Go 1.19+), but previously only ran once, at the very end of build-controller.sh, after the config/crd/bases controller-gen call but before the build-controller-release.sh one. So for any field whose doc comment has a bullet list, config/crd/bases and helm/crds permanently disagree on marker style for identical text -- regenerating always flips one file's CRD YAML relative to the other's. Move the gofmt call to run immediately after ack-generate produces the apis/ source, before either controller-gen crd invocation, so both capture doc comments on the same side of gofmt's rewrite. --- scripts/build-controller.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/build-controller.sh b/scripts/build-controller.sh index 3a455f70..a6e857ef 100755 --- a/scripts/build-controller.sh +++ b/scripts/build-controller.sh @@ -224,6 +224,16 @@ if ! $ACK_GENERATE_BIN_PATH "${apis_args[@]}"; then exit 2 fi +# gofmt rewrites Markdown-style list markers in doc comments (e.g. "*" -> "-") +# as part of its doc-comment formatting. Run it here, before the CRD schemas +# are generated from these doc comments, so that this controller-gen run and +# the later one in build-controller-release.sh (which reads the same, +# already-gofmt'd source) produce identical description text. Otherwise the +# two output targets (config/crd/bases and helm/crds) capture the doc +# comments on opposite sides of this rewrite and permanently disagree on +# list-marker style for the same enum text. +gofmt -w "$SERVICE_CONTROLLER_SOURCE_PATH/apis/$ACK_GENERATE_API_VERSION" + pushd "$SERVICE_CONTROLLER_SOURCE_PATH/apis/$ACK_GENERATE_API_VERSION" 1>/dev/null echo "Generating deepcopy code for $SERVICE"