diff --git a/go.mod b/go.mod index d4b6e2ea52..7441464d4a 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/opencontainers/image-spec v1.1.1 github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292 github.com/openshift/api v0.0.0-20260309185601-71270106f276 - github.com/openshift/build-machinery-go v0.0.0-20251023084048-5d77c1a5e5af + github.com/openshift/build-machinery-go v0.0.0-20260902143904-520f675c892b github.com/openshift/client-go v0.0.0-20260306160707-3935d929fc7d github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c diff --git a/go.sum b/go.sum index b5879eaa9d..8f8d2b9f45 100644 --- a/go.sum +++ b/go.sum @@ -371,8 +371,8 @@ github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab43 github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M= github.com/openshift/api v0.0.0-20260309185601-71270106f276 h1:9QZuPCOT0ME3I7NmsAGBuzGvEyCyzQhAmbfmfCmrLhI= github.com/openshift/api v0.0.0-20260309185601-71270106f276/go.mod h1:pyVjK0nZ4sRs4fuQVQ4rubsJdahI1PB94LnQ8sGdvxo= -github.com/openshift/build-machinery-go v0.0.0-20251023084048-5d77c1a5e5af h1:UiYYMi/CCV+kwWrXuXfuUSOY2yNXOpWpNVgHc6aLQlE= -github.com/openshift/build-machinery-go v0.0.0-20251023084048-5d77c1a5e5af/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE= +github.com/openshift/build-machinery-go v0.0.0-20260902143904-520f675c892b h1:ErTc+6D1n/rpRaUYP++h0YlOzM+q7UaAdqDZrzhA0ho= +github.com/openshift/build-machinery-go v0.0.0-20260902143904-520f675c892b/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE= github.com/openshift/client-go v0.0.0-20260306160707-3935d929fc7d h1:T+9HFgEEcnu1TDDfsO5JcJC6N0/Kzob5AtG9IpITHJ8= github.com/openshift/client-go v0.0.0-20260306160707-3935d929fc7d/go.mod h1:tIA3XSb/WsC/Fg0YNRfs/JrMrloBKPGF+NKVutd7nMI= github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b h1:it0YPE/evO6/m8t8wxis9KFI2F/aleOKsI6d9uz0cEk= diff --git a/vendor/github.com/openshift/build-machinery-go/.gitignore b/vendor/github.com/openshift/build-machinery-go/.gitignore index 19607d9e60..0ff90ea9b3 100644 --- a/vendor/github.com/openshift/build-machinery-go/.gitignore +++ b/vendor/github.com/openshift/build-machinery-go/.gitignore @@ -1 +1,2 @@ *.log.raw +make/examples/golang-versions-check/_output/ diff --git a/vendor/github.com/openshift/build-machinery-go/AGENTS.md b/vendor/github.com/openshift/build-machinery-go/AGENTS.md new file mode 100644 index 0000000000..91c04f1f5c --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/AGENTS.md @@ -0,0 +1,38 @@ +# AI Agent Instructions for build-machinery-go + +**Audience:** AI agents editing **this repository** only — not downstream repos +that vendor these fragments. Those repos should maintain their own root-level +`AGENTS.md`. + +| File | Purpose | +|------|---------| +| [ARCHITECTURE.md](ARCHITECTURE.md) | Make stack design, project layout, verification model | +| [CONTRIBUTING.md](CONTRIBUTING.md) | Development workflow, PR expectations, external guidelines | + +## What This Repo Is + +Reusable GNU Make fragments and helper scripts. Downstream repos include one +vendored entry file (`golang.mk`, `default.mk`, or `operator.mk`) in their +`Makefile`. See [ARCHITECTURE.md](ARCHITECTURE.md) for stacks, layout, and +include chains. + +## Critical Rules + +1. **Run `make verify` before considering any change complete.** +2. **Do not hand-edit `*.log` files** — regenerate with `make update`. +3. **Add new behavior in `make/targets/`**, not in entry files. +4. **Keep backward compatibility** — every repo that vendors this module is affected. +5. **Update examples and logs together** when changing `make/targets/`. + +## What NOT to Do + +- Hand-edit `*.example.mk.help.log` or `Makefile.test.log`. +- Change `make/targets/` without updating examples and regenerating logs. +- Edit files under `make/examples/*/vendor/`. +- Duplicate logic across entry files. +- Modify OWNERS or OWNERS_ALIASES. +- Use AI to respond to review comments. + +For workflow details (container image, branch name, commit structure), see +[CONTRIBUTING.md](CONTRIBUTING.md). For org-wide conventions, see the links in +CONTRIBUTING.md and [openshift/coderabbit](https://github.com/openshift/coderabbit). diff --git a/vendor/github.com/openshift/build-machinery-go/ARCHITECTURE.md b/vendor/github.com/openshift/build-machinery-go/ARCHITECTURE.md new file mode 100644 index 0000000000..b95b495452 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/ARCHITECTURE.md @@ -0,0 +1,226 @@ +# Architecture Overview + +build-machinery-go provides reusable GNU Make fragments and helper scripts that +OpenShift Go repositories vendor and include in their own `Makefile`. This +document describes how the pieces fit together. Update it when the makefile +layout or verification model changes. + +## 1. Project Structure + +See also [AGENTS.md](AGENTS.md) for contributor-oriented rules. Layout: + +``` +build-machinery-go/ +├── Makefile # Meta-verification of example makefiles and logs +├── make/ +│ ├── golang.mk # Entry: pure Go projects +│ ├── default.mk # Entry: OpenShift Go (+ images, bindata, codegen) +│ ├── operator.mk # Entry: OpenShift operators +│ ├── *.example.mk # Copy-paste starting points for downstream repos +│ ├── *.example.mk.help.log # Checked-in `make help` output (audit trail) +│ ├── targets/ # Composable make modules +│ └── examples/ # Integration tests for makefile fragments +├── scripts/ # Shell helpers invoked by make targets +└── commitchecker/ # Small Go binary using golang.mk (dogfooding) +``` + +## 2. High-Level System Diagram + +This repository is a **library**, not a deployed service. Component repos consume +it at build time: + +``` +┌─────────────────────────┐ +│ OpenShift component │ +│ repo (operator, etc.) │ +└───────────┬─────────────┘ + │ go mod vendor + ▼ +┌─────────────────────────┐ include ┌──────────────────────────┐ +│ vendor/.../build- │ ───────────────► │ Component Makefile │ +│ machinery-go/make/*.mk │ │ (build, test, verify, │ +└─────────────────────────┘ │ images, codegen, ...) │ + ▲ └──────────────────────────┘ + │ verify via examples +┌───────────┴─────────────┐ +│ build-machinery-go │ +│ (this repo) │ +│ make verify / update │ +└─────────────────────────┘ +``` + +Data flow: makefile fragments define targets; component repos run those targets +locally and in CI. This repo validates fragment behavior through checked-in log +output from example makefiles. + +## 3. Core Components + +### 3.1. Make fragment stacks + +Three predefined stacks layer on top of each other. Downstream repos include +exactly one entry file from their vendored copy: + +| Stack | Entry file | Extends | Typical targets | +|----------|--------------------|-----------|------------------------------------------| +| Golang | `make/golang.mk` | — | `build`, `test-unit`, `verify-gofmt` | +| Default | `make/default.mk` | Golang | + `images`, `verify-codegen`, `bindata` | +| Operator | `make/operator.mk` | Default | + `test-operator-integration`, profiles | + +**Include chain:** + +``` +operator.mk + └── default.mk + ├── targets/openshift/deps.mk + ├── targets/openshift/images.mk + ├── targets/openshift/bindata.mk + ├── targets/openshift/codegen.mk + └── golang.mk + ├── targets/help.mk + └── targets/golang/*.mk + +operator.mk also includes: + └── targets/openshift/operator/*.mk +``` + +Entry files are thin wrappers that `include` modules from `make/targets/`. New +behavior belongs in `make/targets/`, not duplicated in entry files. + +### 3.2. Target modules (`make/targets/`) + +| Directory | Purpose | +|-------------------------------|---------------------------------------------------| +| `targets/golang/` | Build, test, fmt, vet, version, vulncheck | +| `targets/openshift/` | Images, bindata, codegen, deps, kustomize, yq, rpm | +| `targets/openshift/operator/` | Release, telepresence, profile manifests, MOM | + +Each `*.mk` file defines related targets and their `verify-*` / `update-*` +counterparts where applicable. + +### 3.3. Scripts (`scripts/`) + +Shell scripts hold logic too complex for inline make recipes: + +| Script | Used by | +|--------------------------------|------------------------------------| +| `update-deps.sh` | Dependency update targets | +| `test-operator-integration.sh` | Operator integration test target | +| `run-telepresence.sh` | Telepresence development workflow | +| `vulncheck.sh` | Vulnerability scanning target | + +### 3.4. commitchecker + +A minimal Go package that includes `golang.mk` from the parent directory. It +dogfoods the Golang stack to confirm fragments still work for real Go builds. +See [`commitchecker/README.md`](commitchecker/README.md) for downstream CI usage. + +## 4. Downstream Consumption + +Component repos vendor this module and include one entry file: + +```makefile +include $(addprefix vendor/github.com/openshift/build-machinery-go/make/, \ + default.mk \ +) +``` + +Paths resolve relative to the included file via +`$(dir $(lastword $(MAKEFILE_LIST)))`, so fragments work regardless of vendored +path depth. + +For a starting point, copy the matching `*.example.mk` into the component repo's +`Makefile` and adjust `GO_BUILD_PACKAGES`, image names, and codegen paths. + +## 5. Verification Model + +This repo does not build OpenShift operators. It verifies makefile fragments +through: + +1. **Example makefiles** (`make/*.example.mk`) — `make help` output captured in + checked-in `*.help.log` files. +2. **Integration examples** (`make/examples/*/Makefile.test`) — exercise + specific targets (codegen, profile manifests, golang version checks). + Output captured in `Makefile.test.log` files. +3. **Root `Makefile`** — runs all examples and diffs output via + `make verify` / `make update`. + +Log files are the audit trail: any change to makefile behavior must be visible +in regenerated log diffs. + +## 6. External Integrations + +| Integration | Purpose | How | +|-------------|---------|-----| +| OpenShift release images | CI build root; reproducible `make update` | `registry.ci.openshift.org/openshift/release` (see `.ci-operator.yaml`) | +| `govulncheck` | Dependency vulnerability scanning | Invoked by `scripts/vulncheck.sh` via `targets/golang/vulncheck.mk` | +| Codegen / image tooling | Bindata, CRD schema, controller-gen, imagebuilder | Referenced by `targets/openshift/*.mk`; run in downstream repos | +| Telepresence | Local operator development | `scripts/run-telepresence.sh` (operator stack only) | + +Downstream repos may integrate additional external tools through their own +Makefile variables; this repo provides the make targets that invoke them. + +## 7. Deployment & Infrastructure + +**Distribution:** Published as the Go module +`github.com/openshift/build-machinery-go`. Downstream repos pin a version in +`go.mod` and copy fragments into `vendor/` via `go mod vendor`. There is no +runtime deployment of this repository itself. + +**CI/CD:** OpenShift Prow via ci-operator. Build root image is defined in +[`.ci-operator.yaml`](.ci-operator.yaml) (`rhel-9-release-golang-1.23-openshift-4.19`). +The primary CI check is `make verify`, which diffs example makefile output +against checked-in logs. + +**Infrastructure owned by this repo:** None. Make targets in downstream repos may +build container images, generate manifests, or interact with clusters, but that +machinery runs in consumer repositories, not here. + +## 8. Security Considerations + +| Area | Practice | +|------|----------| +| Dependency scanning | `vulncheck` target runs `govulncheck`; fails on module vulnerabilities | +| Vendor integrity | `verify-deps` / `update-deps` targets in Default stack validate dependency state in downstream repos | +| Script execution | Helper scripts use `bash -e` and clean up temp files (`trap` in `vulncheck.sh`) | +| Secrets | No credentials or cluster access in this repo; downstream targets that need `KUBECONFIG` run in component repos | +| Supply chain | Changes to makefile fragments are auditable via checked-in `*.log` diffs in PRs | + +This repo does not implement authentication or authorization. Security-sensitive +operations (image pushes, cluster deploys) are gated by CI and credentials in +downstream repositories. + +## 9. Development & Testing Environment + +**Local setup:** Clone the repo and run `make verify`. See +[CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow, including the +container command to match CI log output. + +**Testing approach:** + +| Layer | Mechanism | +|-------|-----------| +| Makefile fragments | `make/examples/*/Makefile.test` integration examples | +| Help output | `make/*.example.mk.help.log` snapshot tests | +| Golang stack | `commitchecker/` dogfooding build | + +**Code quality:** `make verify` is the gate. Downstream stacks additionally +expose `verify-gofmt`, `verify-govet`, `verify-codegen`, and related targets. + +## 10. Project Identification + +| Field | Value | +|-------|-------| +| Project name | build-machinery-go | +| Repository | https://github.com/openshift/build-machinery-go | +| Module path | `github.com/openshift/build-machinery-go` | +| Maintainers | See [OWNERS](OWNERS) (`control-plane-approvers`, `jsafrane`, `sanchezl`) | + +## 11. Glossary + +| Term | Definition | +|------|------------| +| **Stack** | One of Golang, Default, or Operator entry-file layers | +| **Fragment** | A `*.mk` file included into a downstream `Makefile` | +| **Target module** | A composable `make/targets/**/*.mk` file defining related targets | +| **Log audit** | Checked-in `*.log` files that snapshot makefile output for `git diff` verification | +| **Downstream repo** | An OpenShift component repo that vendors and includes these make fragments | diff --git a/vendor/github.com/openshift/build-machinery-go/CLAUDE.md b/vendor/github.com/openshift/build-machinery-go/CLAUDE.md new file mode 100644 index 0000000000..43c994c2d3 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/vendor/github.com/openshift/build-machinery-go/CONTRIBUTING.md b/vendor/github.com/openshift/build-machinery-go/CONTRIBUTING.md new file mode 100644 index 0000000000..5d7814832d --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/CONTRIBUTING.md @@ -0,0 +1,93 @@ +# Contributing to build-machinery-go + +build-machinery-go ships reusable GNU Make fragments consumed by many OpenShift +Go projects via `go mod vendor`. Changes here have broad downstream impact. + +Read [ARCHITECTURE.md](ARCHITECTURE.md) for how the make stacks and verification +model work. + +## Related guidelines + +This repository does not define org-wide OpenShift or Go conventions. Use these +instead: + +| Topic | Where | +|-------|-------| +| Control plane code conventions, testing, PR process, review expectations | [openshift/service-ca-operator/CONTRIBUTING.md](https://github.com/openshift/service-ca-operator/blob/main/CONTRIBUTING.md) | +| OpenShift CI / Prow / Jira integration | [docs.ci.openshift.org](https://docs.ci.openshift.org/) | +| Commit signature verification | [OpenShift contribution policy](https://docs.google.com/document/d/1184EPSGunUkcSQYUK8T4a6iyawwi6f2zxdbB2jtG9nQ/edit?usp=sharing) | +| AI code review configuration | [openshift/coderabbit](https://github.com/openshift/coderabbit) | + +For reviews, reach out via [OWNERS](OWNERS) or the control plane Slack channels +listed in the service-ca-operator contributing guide. + +## Development workflow + +1. Fork the repo and clone your fork. +2. Create a feature branch from `master`. +3. Make your changes. When makefile behavior changes, add or update examples under + `make/examples/`. +4. Run `make verify` locally before pushing. +5. Open a PR against `openshift/build-machinery-go:master`. + +Functional changes that regenerate logs should use two commits when applicable: +code first, then `update generated` for `*.log` files only. + +## Verification + +This repo validates makefile fragments through **checked-in log snapshots**, not +unit tests. See [ARCHITECTURE.md §5](ARCHITECTURE.md#5-verification-model) for +details. + +- Run `make update` after changing `make/targets/` or examples, then commit the + regenerated `*.log` files. +- Never hand-edit `*.example.mk.help.log` or `Makefile.test.log`. + +### Matching CI output + +Local `make update` output may differ across distributions. To match CI, run +update in the same build root image as Prow (defined in +[`.ci-operator.yaml`](.ci-operator.yaml)): + +```bash +podman run -it --rm --pull=always \ + -v "$(pwd)":/go/src/$(go list -m) \ + --workdir=/go/src/$(go list -m) \ + registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.23-openshift-4.19 \ + make update +``` + +## Make fragment changes + +- Add new behavior in `make/targets/`, not in entry files (`golang.mk`, + `default.mk`, `operator.mk`). +- Keep backward compatibility unless a breaking change is explicitly agreed. +- Place complex shell logic in `scripts/` — follow the + [shell styleguide](https://google.github.io/styleguide/shellguide.html). +- Do not add Go dependencies without justification in the PR description. + +## Pull requests + +Follow the linked control plane and OpenShift CI guidelines for Jira titles +(`CNTRLPLANE-XXXX:` or `NO-JIRA:`), `/lgtm`, `/approve`, `/verified`, and Prow +retests. + +Repository-specific expectations: + +- `make verify` must pass in CI. +- Changes to `make/targets/` must include updated examples and regenerated logs. +- Breaking fragment interface changes need maintainer agreement and a migration + note for downstream repos. +- Do not modify `OWNERS` or `OWNERS_ALIASES` without explicit direction. + +For makefile-only changes, `/verified by ci` is typically sufficient when +`make verify` passes. + +## Areas requiring extra care + +- Entry file changes (`golang.mk`, `default.mk`, `operator.mk`) affect every + downstream repo on that stack. +- Target module interface changes (variables, target names, defaults) must stay + backward compatible or document migration. +- Log normalization sed filters in the root `Makefile` must not hide real + behavior changes. diff --git a/vendor/github.com/openshift/build-machinery-go/OWNERS b/vendor/github.com/openshift/build-machinery-go/OWNERS index 1bbac46c7f..c54ee52b60 100644 --- a/vendor/github.com/openshift/build-machinery-go/OWNERS +++ b/vendor/github.com/openshift/build-machinery-go/OWNERS @@ -1,9 +1,9 @@ reviewers: + - control-plane-approvers - 2uasimojo - - benluddy - jsafrane - sanchezl approvers: - - benluddy + - control-plane-approvers - jsafrane - sanchezl diff --git a/vendor/github.com/openshift/build-machinery-go/OWNERS_ALIASES b/vendor/github.com/openshift/build-machinery-go/OWNERS_ALIASES new file mode 100644 index 0000000000..66464a003e --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/OWNERS_ALIASES @@ -0,0 +1,16 @@ +aliases: + control-plane-approvers: + - ardaguclu + - atiratree + - benluddy + - bertinatto + - everettraven + - flavianmissi + - gangwgr + - ingvagabund + - kaleemsiddiqu + - p0lyn0mial + - rh-roman + - ricardomaraschini + - tjungblu + - xueqzhan diff --git a/vendor/github.com/openshift/build-machinery-go/README.md b/vendor/github.com/openshift/build-machinery-go/README.md index 66862f61a2..54fbed76b2 100644 --- a/vendor/github.com/openshift/build-machinery-go/README.md +++ b/vendor/github.com/openshift/build-machinery-go/README.md @@ -37,8 +37,9 @@ Extends [#Default](). `scripts` contain more complicated logic that is used in some make targets. ## Contributing -### Updating generated files -We track the log output from the makefile tests to make sure any change is visible and can be audited. Unfortunately due to subtle linux tooling differences in distributions and versions, `make update` may not get you the exact output as the CI. To avoid it, just run the command in the same container as CI: -``` -podman run -it --rm --pull=always -v $( pwd ):/go/src/$( go list -m ) --workdir=/go/src/$( go list -m ) registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.15-openshift-4.7 make update -``` + +See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow, PR guidelines, +and how to regenerate checked-in makefile logs. + +For architecture details, see [ARCHITECTURE.md](ARCHITECTURE.md). For AI agent +instructions, see [AGENTS.md](AGENTS.md) ([CLAUDE.md](CLAUDE.md) references it via `@AGENTS.md`). diff --git a/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk b/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk index d08f74a42d..6674f7eb65 100644 --- a/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk @@ -60,10 +60,17 @@ ifndef OS_GIT_VERSION OS_GIT_VERSION = $(SOURCE_GIT_TAG) endif +# OS_MAJOR_VERSION is populated by ART +# If building out of the ART pipeline, fallback to '0' and let implementations decide how they handle it +ifndef OS_MAJOR_VERSION + OS_MAJOR_VERSION = "0" +endif + define version-ldflags -X $(1).versionFromGit="$(OS_GIT_VERSION)" \ -X $(1).commitFromGit="$(SOURCE_GIT_COMMIT)" \ -X $(1).gitTreeState="$(SOURCE_GIT_TREE_STATE)" \ --X $(1).buildDate="$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')" +-X $(1).buildDate="$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')" \ +-X $(1).majorFromGit="$(OS_MAJOR_VERSION)" endef GO_LD_FLAGS ?=-ldflags "$(call version-ldflags,$(GO_PACKAGE)/pkg/version) $(GO_LD_EXTRAFLAGS)" diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk index bdd7f479da..9692c1d829 100644 --- a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk @@ -1,3 +1,23 @@ +# verify-golang-versions — ensure Go versions are consistent across build sources. +# +# OpenShift repos declare a Go version in up to three places: go.mod, +# Dockerfile (builder image tag), and .ci-operator.yaml (CI build root). +# When these drift apart, builds can silently use the wrong Go version or +# fail in hard-to-diagnose ways. In particular, if go.mod declares a version +# higher than the CI builder, the build fails because GOTOOLCHAIN=local +# prevents Go from downloading a newer toolchain. This target catches +# that drift at verify time by extracting the Go MAJOR.MINOR from each source +# and comparing them. +# +# Rules: +# 1. All CI sources (Dockerfile, .ci-operator.yaml) must declare the same Go version. +# 2. go.mod may declare a version <= the CI version (Go is backward-compatible). +# 3. go.mod must NOT declare a version higher than the CI builder. +# 4. Every extracted version must be a valid MAJOR.MINOR number. +# +# Usage: +# $(call verify-golang-versions,Dockerfile.rhel7) + include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ ../../lib/golang.mk \ ../../lib/tmp.mk \ @@ -9,11 +29,28 @@ include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ verify-golang-versions: @if [ -f "$(PERMANENT_TMP)/golang-versions" ]; then \ - LINES=$$(cat "$(PERMANENT_TMP)/golang-versions" | sort | uniq | wc -l); \ - if [ $${LINES} -gt 1 ]; then \ + GOMOD_VER=""; \ + CI_VER=""; \ + if [ -f "$(PERMANENT_TMP)/named-golang-versions" ]; then \ + GOMOD_VER=$$(grep '^go\.mod:' "$(PERMANENT_TMP)/named-golang-versions" | sed 's/go\.mod: *//'); \ + CI_VER=$$(grep -v '^go\.mod:' "$(PERMANENT_TMP)/named-golang-versions" | sed 's/^[^:]*: *//' | sort | uniq); \ + fi; \ + CI_COUNT=$$(echo "$${CI_VER}" | grep -c . 2>/dev/null || :); \ + if [ "$${CI_COUNT}" -gt 1 ]; then \ echo "Golang version mismatch:"; \ cat "$(PERMANENT_TMP)/named-golang-versions" | sort | sed 's/^/- /'; \ false; \ + elif [ -n "$${GOMOD_VER}" ] && [ -n "$${CI_VER}" ]; then \ + GOMOD_MAJOR=$$(echo "$${GOMOD_VER}" | cut -d. -f1); \ + GOMOD_MINOR=$$(echo "$${GOMOD_VER}" | cut -d. -f2); \ + CI_MAJOR=$$(echo "$${CI_VER}" | cut -d. -f1); \ + CI_MINOR=$$(echo "$${CI_VER}" | cut -d. -f2); \ + if [ "$${GOMOD_MAJOR}" -gt "$${CI_MAJOR}" ] 2>/dev/null || \ + { [ "$${GOMOD_MAJOR}" -eq "$${CI_MAJOR}" ] 2>/dev/null && [ "$${GOMOD_MINOR}" -gt "$${CI_MINOR}" ] 2>/dev/null; }; then \ + echo "Golang version mismatch:"; \ + cat "$(PERMANENT_TMP)/named-golang-versions" | sort | sed 's/^/- /'; \ + false; \ + fi; \ fi; \ fi .PHONY: verify-golang-versions @@ -24,6 +61,10 @@ define verify-golang-version-reference-internal verify-golang-versions-$(1): .empty-golang-versions-files verify-golang-versions-$(1): @mkdir -p "$(PERMANENT_TMP)" + @if ! echo "$(2)" | grep -qxE '[0-9]+\.[0-9]+'; then \ + echo "Error: could not extract a valid golang version from $(1) (got '$(2)')"; \ + false; \ + fi @echo "$(1): $(2)" >> "$(PERMANENT_TMP)/named-golang-versions" @echo "$(2)" >> "$(PERMANENT_TMP)/golang-versions" .PHONY: verify-golang-versions-$(1) diff --git a/vendor/modules.txt b/vendor/modules.txt index f63b30862f..bdc323d3e9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -791,7 +791,7 @@ github.com/openshift/api/template/v1 github.com/openshift/api/unidling/v1alpha1 github.com/openshift/api/user github.com/openshift/api/user/v1 -# github.com/openshift/build-machinery-go v0.0.0-20251023084048-5d77c1a5e5af +# github.com/openshift/build-machinery-go v0.0.0-20260902143904-520f675c892b ## explicit; go 1.22.0 github.com/openshift/build-machinery-go github.com/openshift/build-machinery-go/make