From d5498c0433831294d6921f72eacc5de7ac351eb9 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Thu, 23 Jul 2026 20:37:39 +0200 Subject: [PATCH 1/4] [operator_build] Use local path replace for go.mod in meta operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The go mod edit -replace command was using a remote module reference with a raw commit SHA (e.g. github.com/user/repo@sha), which requires go mod tidy to resolve the SHA to a pseudo-version via the Go module proxy. In CI environments where the proxy cannot reach fork repositories, go mod tidy silently fails (no set -e), leaving the raw SHA in go.mod. The subsequent go work use then fails with "version must be of the form v1.2.3". Fix by using local path replaces instead — the operator source is already checked out at {{ operator.src }}, so no network access or version resolution is needed. Also add set -e to surface any future failures immediately. Co-Authored-By: Claude Opus 4.6 (1M context) --- roles/operator_build/tasks/build.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/operator_build/tasks/build.yml b/roles/operator_build/tasks/build.yml index 6aefbe2c1..0232f1edb 100644 --- a/roles/operator_build/tasks/build.yml +++ b/roles/operator_build/tasks/build.yml @@ -40,11 +40,12 @@ - name: "{{ operator.name }} - Update the go.mod file in meta operator for provided PR_SHA" # noqa: name[template] ansible.builtin.shell: | - go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ operator.pr_sha }} + set -e + go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ operator.pr_sha }} + go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} go mod tidy popd fi @@ -69,11 +70,12 @@ - name: "{{ operator.name }} - Update the go.mod file using latest commit if no PR is provided" # noqa: name[template] ansible.builtin.shell: | - go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pr_sha }} + set -e + go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pr_sha }} + go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} go mod tidy popd fi From e6ca7af28114fc4f0f34d9d34a67a6c3a4ed90fc Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Fri, 24 Jul 2026 06:20:44 +0200 Subject: [PATCH 2/4] [operator_build] Use pseudo-version instead of raw SHA or local path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix used local path replaces which broke the bindata step — pin-bundle-images.sh parses go.mod replace directives to extract commit SHAs for bundle image tags, and local paths have no version info. Instead, construct a proper Go pseudo-version (v0.0.0-DATE-HASH) from the commit metadata before calling go mod edit. This gives a valid go.mod version that both go work use and pin-bundle-images.sh can handle. Co-Authored-By: Claude Opus 4.6 (1M context) --- roles/operator_build/tasks/build.yml | 39 +++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/roles/operator_build/tasks/build.yml b/roles/operator_build/tasks/build.yml index 0232f1edb..59f665f34 100644 --- a/roles/operator_build/tasks/build.yml +++ b/roles/operator_build/tasks/build.yml @@ -38,14 +38,30 @@ ansible.builtin.set_fact: operator_api_path: "github.com/{{ cifmw_operator_build_org }}/{{ operator.name }}/{{ operator_base_module_name }}" +- name: "{{ operator.name }} - Build pseudo-version from commit metadata" # noqa: name[template] + ansible.builtin.shell: | + set -e + commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format:'%Y%m%d%H%M%S' {{ operator.pr_sha }}) + short_hash=$(echo "{{ operator.pr_sha }}" | cut -c1-12) + echo "v0.0.0-${commit_date}-${short_hash}" + args: + chdir: "{{ operator.src }}" + register: pseudo_version_out + when: + - cifmw_operator_build_meta_build + - operator.name != cifmw_operator_build_meta_name + - operator.pr_owner is defined + - operator.pr_sha is defined + - operator_base_module + - name: "{{ operator.name }} - Update the go.mod file in meta operator for provided PR_SHA" # noqa: name[template] ansible.builtin.shell: | set -e - go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} + go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ pseudo_version_out.stdout | trim }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} + go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ pseudo_version_out.stdout | trim }} go mod tidy popd fi @@ -68,14 +84,29 @@ ansible.builtin.set_fact: pr_sha: "{{ operator.pr_sha | default(git_head_out.stdout | trim) }}" +- name: "{{ operator.name }} - Build pseudo-version from HEAD commit" # noqa: name[template] + ansible.builtin.shell: | + set -e + commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format:'%Y%m%d%H%M%S' HEAD) + short_hash=$(git log -1 --format='%H' HEAD | cut -c1-12) + echo "v0.0.0-${commit_date}-${short_hash}" + args: + chdir: "{{ operator.src }}" + register: pseudo_version_out + when: + - cifmw_operator_build_meta_build + - operator.name != cifmw_operator_build_meta_name + - operator.pr_owner is not defined + - operator_base_module + - name: "{{ operator.name }} - Update the go.mod file using latest commit if no PR is provided" # noqa: name[template] ansible.builtin.shell: | set -e - go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} + go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pseudo_version_out.stdout | trim }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }} + go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pseudo_version_out.stdout | trim }} go mod tidy popd fi From 839a4a2a5b2df384f326c082d61b1637c364c8c6 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Fri, 24 Jul 2026 06:36:19 +0200 Subject: [PATCH 3/4] fixup: use format-local for UTC pseudo-version timestamp git --date=format: uses the commit's original timezone, not UTC. Go pseudo-versions require UTC timestamps. Switch to --date=format-local: with TZ=UTC to convert correctly. Co-Authored-By: Claude Opus 4.6 (1M context) --- roles/operator_build/tasks/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/operator_build/tasks/build.yml b/roles/operator_build/tasks/build.yml index 59f665f34..90fc5571b 100644 --- a/roles/operator_build/tasks/build.yml +++ b/roles/operator_build/tasks/build.yml @@ -41,7 +41,7 @@ - name: "{{ operator.name }} - Build pseudo-version from commit metadata" # noqa: name[template] ansible.builtin.shell: | set -e - commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format:'%Y%m%d%H%M%S' {{ operator.pr_sha }}) + commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y%m%d%H%M%S' {{ operator.pr_sha }}) short_hash=$(echo "{{ operator.pr_sha }}" | cut -c1-12) echo "v0.0.0-${commit_date}-${short_hash}" args: @@ -87,7 +87,7 @@ - name: "{{ operator.name }} - Build pseudo-version from HEAD commit" # noqa: name[template] ansible.builtin.shell: | set -e - commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format:'%Y%m%d%H%M%S' HEAD) + commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y%m%d%H%M%S' HEAD) short_hash=$(git log -1 --format='%H' HEAD | cut -c1-12) echo "v0.0.0-${commit_date}-${short_hash}" args: From 36ca1207b1bae27cf7203ad21594db7aa82f0dfa Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Fri, 24 Jul 2026 06:44:12 +0200 Subject: [PATCH 4/4] [operator_build] Add set -e to go.mod update shell scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit go mod tidy resolves raw commit SHAs to proper pseudo-versions, but its failure was silently swallowed because the shell scripts lacked set -e — the trailing if [ -d ./apis ] returned 0 even when go mod tidy failed, masking the error. The unresolved raw SHA then caused go work use to fail with "version must be of the form v1.2.3". Adding set -e ensures go mod tidy failures surface immediately. Co-Authored-By: Claude Opus 4.6 (1M context) --- roles/operator_build/tasks/build.yml | 39 +++------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/roles/operator_build/tasks/build.yml b/roles/operator_build/tasks/build.yml index 90fc5571b..9c5bc1b3b 100644 --- a/roles/operator_build/tasks/build.yml +++ b/roles/operator_build/tasks/build.yml @@ -38,30 +38,14 @@ ansible.builtin.set_fact: operator_api_path: "github.com/{{ cifmw_operator_build_org }}/{{ operator.name }}/{{ operator_base_module_name }}" -- name: "{{ operator.name }} - Build pseudo-version from commit metadata" # noqa: name[template] - ansible.builtin.shell: | - set -e - commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y%m%d%H%M%S' {{ operator.pr_sha }}) - short_hash=$(echo "{{ operator.pr_sha }}" | cut -c1-12) - echo "v0.0.0-${commit_date}-${short_hash}" - args: - chdir: "{{ operator.src }}" - register: pseudo_version_out - when: - - cifmw_operator_build_meta_build - - operator.name != cifmw_operator_build_meta_name - - operator.pr_owner is defined - - operator.pr_sha is defined - - operator_base_module - - name: "{{ operator.name }} - Update the go.mod file in meta operator for provided PR_SHA" # noqa: name[template] ansible.builtin.shell: | set -e - go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ pseudo_version_out.stdout | trim }} + go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ operator.pr_sha }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ pseudo_version_out.stdout | trim }} + go mod edit -replace {{ operator_api_path }}=github.com/{{ operator.pr_owner }}/{{ operator_base_module_name }}@{{ operator.pr_sha }} go mod tidy popd fi @@ -84,29 +68,14 @@ ansible.builtin.set_fact: pr_sha: "{{ operator.pr_sha | default(git_head_out.stdout | trim) }}" -- name: "{{ operator.name }} - Build pseudo-version from HEAD commit" # noqa: name[template] - ansible.builtin.shell: | - set -e - commit_date=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y%m%d%H%M%S' HEAD) - short_hash=$(git log -1 --format='%H' HEAD | cut -c1-12) - echo "v0.0.0-${commit_date}-${short_hash}" - args: - chdir: "{{ operator.src }}" - register: pseudo_version_out - when: - - cifmw_operator_build_meta_build - - operator.name != cifmw_operator_build_meta_name - - operator.pr_owner is not defined - - operator_base_module - - name: "{{ operator.name }} - Update the go.mod file using latest commit if no PR is provided" # noqa: name[template] ansible.builtin.shell: | set -e - go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pseudo_version_out.stdout | trim }} + go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pr_sha }} go mod tidy if [ -d ./apis ]; then pushd ./apis/ - go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pseudo_version_out.stdout | trim }} + go mod edit -replace {{ operator_api_path }}={{ operator_api_path }}@{{ pr_sha }} go mod tidy popd fi