Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v7

- name: Install Go
uses: actions/setup-go@v6
uses: actions/setup-go@v7
with:
go-version-file: go.mod

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2
curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2

- name: Verify
run: |
Expand Down
20 changes: 1 addition & 19 deletions .govulncheck.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
ignored-vulnerabilities:
# Incorrect parsing of IPv6 host literals in net/url
# Found in: net/url@go1.24.13
# Fixed in: net/url@go1.25.8
- id: GO-2026-4601
silence-until: 2026-09-03
info: https://pkg.go.dev/vuln/GO-2026-4601
# Inefficient candidate hostname parsing in crypto/x509
# Found in: crypto/x509@go1.24.13
# Fixed in: crypto/x509@go1.25.11
- id: GO-2026-5037
silence-until: 2026-09-03
info: https://pkg.go.dev/vuln/GO-2026-5037
# FileInfo can escape from a Root in os
# Found in: os@go1.24.13
# Fixed in: os@go1.25.8
- id: GO-2026-4602
info: https://pkg.go.dev/vuln/GO-2026-4602
silence-until: 2026-09-03
ignored-vulnerabilities: []
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/codeready-toolchain/api

go 1.24.4
go 1.26.0

toolchain go1.24.13
toolchain go1.26.5
Comment on lines +3 to +5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

set -eu
printf '%s\n' '--- api go.mod ---'
cat -n go.mod | sed -n '1,20p'
printf '%s\n' '--- api README prerequisite lines ---'
rg -n -C 2 'Go version|1\.24|1\.26|toolchain' README.md .github Makefile* 2>/dev/null || true
printf '%s\n' '--- api workflow/toolchain references ---'
rg -n -i 'go-version|setup-go|1\.24|1\.26|toolchain' .github Makefile* 2>/dev/null || true

Repository: codeready-toolchain/api

Length of output: 3860


🏁 Script executed:

set -eu
printf '%s\n' '--- toolchain-common go.mod ---'
cat -n go.mod | sed -n '1,15p'
printf '%s\n' '--- toolchain-common Go CI references ---'
rg -n -i 'go-version|setup-go|1\.24|1\.26|toolchain' .github Makefile* 2>/dev/null || true
printf '%s\n' '--- api dependency references ---'
rg -n 'codeready-toolchain/api|replace .*api' go.mod go.sum .github Makefile* 2>/dev/null || true

Repository: codeready-toolchain/toolchain-common

Length of output: 1919


🏁 Script executed:

set -eu
printf '%s\n' '--- host-operator go.mod ---'
cat -n go.mod | sed -n '1,15p'
printf '%s\n' '--- host-operator Go CI references ---'
rg -n -i 'go-version|setup-go|1\.24|1\.26|toolchain' .github Makefile* 2>/dev/null || true
printf '%s\n' '--- api dependency references ---'
rg -n 'codeready-toolchain/api|replace .*api' go.mod go.sum .github Makefile* 2>/dev/null || true

Repository: codeready-toolchain/host-operator

Length of output: 3435


🏁 Script executed:

set -eu
printf '%s\n' '--- toolchain-e2e go.mod ---'
cat -n go.mod | sed -n '1,15p'
printf '%s\n' '--- toolchain-e2e Go CI and documentation references ---'
rg -n -i 'go-version|setup-go|1\.24|1\.26|toolchain' .github Makefile* required_tools.adoc 2>/dev/null || true
printf '%s\n' '--- api dependency references ---'
rg -n 'codeready-toolchain/api|replace .*api' go.mod go.sum .github Makefile* 2>/dev/null || true

Repository: codeready-toolchain/toolchain-e2e

Length of output: 2730


🌐 Web query:

Go toolchain selection behavior when a dependency module's go.mod requires a newer Go version than the main module, and whether Go 1.24 automatically switches for that dependency

💡 Result:

In Go, the toolchain selection behavior is determined by the configuration in the main module's go.mod file (or go.work file in a workspace) and the GOTOOLCHAIN environment variable [1][2]. When a dependency module requires a newer Go version than the main module, the go command does not automatically switch toolchains based on the dependency's requirements alone [1][3]. Instead, it enforces compatibility constraints [3][4]. The specific behaviors are as follows: 1. Mandatory Version Requirement: Since Go 1.21, the go directive in a go.mod file is a mandatory requirement [3][2]. A Go toolchain will refuse to build a module if it requires a Go version newer than what the current toolchain supports [2][5]. If a dependency requires a newer Go version, the current (older) toolchain will typically fail during the dependency resolution or build process because it cannot satisfy the requirement [2][4]. 2. Automatic Toolchain Switching: If GOTOOLCHAIN is set to auto (the default) or path, the go command can automatically download and switch to a newer toolchain [1][4]. However, this switching is governed by the go and toolchain directives in the main module’s go.mod (or go.work), not by the requirements of indirect dependencies [1][5]. The main module must explicitly indicate that a newer toolchain is required [1][4]. 3. Updating for Dependencies: When you add or update a dependency that requires a newer Go version, commands like go get will typically notice the new requirement and update the main module's go.mod file—specifically the go line and the toolchain line—to match the requirements of the dependency [1][4]. This ensures that future invocations of the go command use an appropriate toolchain that satisfies the new dependency's minimum Go version [1]. 4. Go 1.24 and Newer: Go 1.24 does not introduce a mechanism to "automatically switch" to a newer toolchain purely because a dependency happens to require it without those requirements being reflected in the main module [6]. The fundamental rule remains: the main module's go.mod dictates the environment [1]. Go 1.24 continues to rely on the main module's go and toolchain directives to determine if an upgrade is necessary, and it ensures that the toolchain selected is capable of building the entire dependency graph [1][6]. If you are working in a module that does not have its go or toolchain lines updated to a version capable of supporting your newer dependencies, the build will fail [2][4]. In summary, Go toolchain switching is a top-down process driven by the main module's configuration. Dependencies do not trigger automatic toolchain switching; rather, commands like go get update the main module to support the dependencies, which subsequently allows the go command to select the correct toolchain for future operations [1][4].

Citations:


🏁 Script executed:

set -eu
printf '%s\n' '--- host-operator Go directives ---'
rg -n -C 2 '^(go|toolchain) ' go.mod
printf '%s\n' '--- host-operator setup-go workflow sections ---'
rg -n -A 5 -B 3 'go-version-file|setup-go' .github/workflows

Repository: codeready-toolchain/host-operator

Length of output: 3827


🏁 Script executed:

set -eu
printf '%s\n' '--- toolchain-common Go directives ---'
rg -n -C 2 '^(go|toolchain) ' go.mod
printf '%s\n' '--- toolchain-common setup-go workflow sections ---'
rg -n -A 5 -B 3 'go-version-file|setup-go' .github/workflows

Repository: codeready-toolchain/toolchain-common

Length of output: 2476


🏁 Script executed:

set -eu
printf '%s\n' '--- toolchain-e2e Go directives ---'
rg -n -C 2 '^(go|toolchain) ' go.mod
printf '%s\n' '--- toolchain-e2e setup-go workflow sections ---'
rg -n -A 5 -B 3 'go-version-file|setup-go' .github/workflows

Repository: codeready-toolchain/toolchain-e2e

Length of output: 2390


🏁 Script executed:

set -eu
python3 - <<'PY'
from pathlib import Path
import re

repos = {
    "api": Path("go.mod"),
    "toolchain-common": Path("../toolchain-common/go.mod"),
    "host-operator": Path("../host-operator/go.mod"),
    "toolchain-e2e": Path("../toolchain-e2e/go.mod"),
}
for name, path in repos.items():
    text = path.read_text()
    directives = dict(re.findall(r"(?m)^(go|toolchain)\s+(\S+)", text))
    print(name, directives)
PY

Repository: codeready-toolchain/api

Length of output: 745


🌐 Web query:

site:go.dev/doc/toolchain dependency go.mod requires newer Go version automatic toolchain switching

💡 Result:

The Go toolchain includes an automatic switching mechanism that ensures compatibility when a project requires a newer Go version than the one currently installed [1]. When you run a Go command in a main module that specifies a higher Go version in its go.mod file than the currently installed Go toolchain, the Go command automatically attempts to resolve this discrepancy [1]. If automatic switching is permitted by the GOTOOLCHAIN configuration (which defaults to 'auto'), the command will look for a newer version of the toolchain, first checking the system PATH for a specifically named binary (e.g., go1.21.9) and otherwise downloading and caching the required version [1]. Key points regarding this behavior include: 1. Toolchain Directive: The go.mod file contains a go directive that specifies the minimum required Go version [1]. Additionally, a toolchain directive may be present to explicitly record the toolchain name used, which helps maintain repeatability [1]. 2. Version Resolution: If the version specified in the go.mod file is newer than the bundled toolchain, the Go command automatically switches to the newer version to execute the command [1]. 3. Configuration: This behavior is controlled by the GOTOOLCHAIN environment variable. If automatic switching is disabled, the Go command will refuse to run if the required version exceeds the bundled version, requiring a manual update [1]. 4. Updates: When commands (such as go get) update the module requirements to a version needing a newer Go release, they automatically update the go and toolchain lines in the go.mod or go.work file to reflect the new requirements [1].

Citations:


🏁 Script executed (no clone):

set -eu
python3 - <<'PY'
from urllib.request import urlopen
url = "https://go.dev/doc/toolchain"
text = urlopen(url, timeout=20).read().decode()
terms = (
    "dependency",
    "go.mod file",
    "GOTOOLCHAIN",
    "automatically switches",
    "module graph",
)
for i, line in enumerate(text.splitlines(), 1):
    if any(term.lower() in line.lower() for term in terms):
        print(f"{i}: {line.strip()}")
PY

Length of output: 2411


🌐 Web query:

site:go.dev/doc/toolchain "dependency" "go.mod" "switch" newer toolchain

💡 Result:

To switch to or specify a newer toolchain in Go, you can use the toolchain directive within your go.mod file [1]. The go.mod file contains a go directive that specifies the minimum required Go version for your module [1]. The toolchain directive, when added to the go.mod file, provides a mechanism to select a specific Go toolchain version that takes precedence over the version specified in the go directive [1]. When you run Go commands (such as go get, go work use, or go install), the Go toolchain may automatically switch to a newer version if your module's requirements demand a newer Go version than your current toolchain provides, provided the GOTOOLCHAIN environment variable is configured to allow automatic switching (e.g., set to auto or path) [1]. When such a switch occurs or when you manually update your environment, Go commands will automatically update the go and toolchain lines in your go.mod file to ensure reproducibility [1]. Specifically, if a command triggers a switch or update, it writes the new minimum Go version requirement to the go.mod file and records the specific toolchain name in the toolchain directive [1]. This ensures that subsequent runs of the go command utilize the specified toolchain version [1].

Citations:


🌐 Web query:

actions/setup-go go-version-file go.mod toolchain directive or go directive behavior

💡 Result:

When using actions/setup-go (v6.0.0 and later) with the go-version-file input set to a go.mod file, the action performs Go version selection by checking both the toolchain and go directives [1][2][3]. The behavior is as follows: 1. Precedence: If the toolchain directive is present in the go.mod file, the action uses the version specified there [1][2][4]. If no toolchain directive exists, it falls back to the version specified in the go directive [2][4][5]. 2. Environment Variable Override: The action respects the GOTOOLCHAIN environment variable [6]. If GOTOOLCHAIN is explicitly set to local, the action ignores the toolchain directive and defaults to the version defined in the go directive [6][7][8]. This behavior ensures alignment with the official Go toolchain selection guidelines, preventing the action from automatically selecting a newer toolchain when restricted to local versions [7][8]. 3. Version Resolution: - If a specific patch version is provided in either directive, the action uses that exact version [2][4]. - If only a major or major.minor version is provided (e.g., go 1.23), the action searches for the latest available patch version in the local cache, the versions-manifest.json file, and finally, the official Go language download site [4][9]. This version selection logic is designed to ensure consistency between the Go environment installed by the action and the requirements defined within the project's dependency files [2][3]. Additionally, when using go.mod for version detection, the action's cache keys automatically incorporate the version detected from these directives to prevent cache conflicts [2][3]. If both go-version and go-version-file inputs are provided, the explicit go-version input takes precedence and overrides the version detected from the go.mod file [1][2][5].

Citations:


🏁 Script executed on all repositories:

set -eu
python3 - <<'PY'
from pathlib import Path
import re

go_mod = Path("go.mod")
if not go_mod.exists():
    print("no go.mod")
    raise SystemExit(0)

text = go_mod.read_text()
directives = dict(re.findall(r"(?m)^(go|toolchain)\s+(\S+)", text))
api_dep = bool(re.search(r"(?m)^\s*github\.com/codeready-toolchain/api\s+\S+", text))
setup_go = []
for workflow in Path(".github/workflows").glob("*"):
    if workflow.is_file():
        workflow_text = workflow.read_text(errors="replace")
        if "go-version-file: go.mod" in workflow_text:
            setup_go.append(str(workflow))

print({
    "go_directive": directives.get("go"),
    "toolchain_directive": directives.get("toolchain"),
    "direct_api_dependency": api_dep,
    "setup_go_reads_go_mod": bool(setup_go),
    "setup_go_workflows": setup_go,
})
if go_mod.name == "go.mod" and Path("README.md").exists():
    readme = Path("README.md").read_text()
    matches = [line.strip() for line in readme.splitlines()
               if re.search(r"Go version|go 1\.24|Go 1\.24|1\.26", line)]
    if matches:
        print({"readme_go_lines": matches})
PY

Length of output: 2038


Align all Go toolchain contracts with Go 1.26.

Update README.md, required_tools.adoc, and the go.mod files for toolchain-common, host-operator, and toolchain-e2e. These modules directly require the API module but declare Go 1.24.4 and go1.24.13; their CI reads those declarations with actions/setup-go. Otherwise, explicitly test and document the required GOTOOLCHAIN switching configuration.

📍 Affects 2 files
  • go.mod#L3-L5 (this comment)
  • README.md#L10-L10
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` around lines 3 - 5, Align all Go toolchain declarations with Go 1.26:
update the root go.mod lines 3-5, README.md line 10, and the go.mod files for
toolchain-common, host-operator, and toolchain-e2e to use the Go 1.26
requirements and toolchain version. Also update required_tools.adoc accordingly,
or explicitly configure and document the required GOTOOLCHAIN switching behavior
if any module must retain older declarations.

Sources: Path instructions, Linked repositories


require (
// using latest commit from 'github.com/openshift/api branch release-4.20'
Expand Down Expand Up @@ -37,12 +37,13 @@ require (
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/tools v0.44.0 // indirect
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
28 changes: 16 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,36 +100,40 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
golang.org/x/tools/go/expect v0.1.0-deprecated h1:jY2C5HGYR5lqex3gEniOQL0r7Dq5+VGVgY1nudX5lXY=
golang.org/x/tools/go/expect v0.1.0-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 0 additions & 1 deletion gofmt_exclude

This file was deleted.

17 changes: 0 additions & 17 deletions make/format.mk

This file was deleted.

27 changes: 21 additions & 6 deletions make/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ API_GROUPNAME=toolchain
API_FULL_GROUPNAME=toolchain.dev.openshift.com
API_VERSION:=v1alpha1

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)


## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen
Expand All @@ -29,6 +23,27 @@ $(CRD_REF_DOCS): go.mod | $(LOCALBIN) ## install crd-ref-docs locally if necessa
manifests: $(CONTROLLER_GEN) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)


## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen
PATH_TO_CRD_BASES=config/crd/bases
CONTROLLER_TOOLS_VERSION ?= v0.18.0

$(CONTROLLER_GEN): ## install controller-gen locally if necessary.
GOBIN=$(LOCALBIN) $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen

$(OPENAPI_GEN): ## install openapi-gen locally if necessary.
GOBIN=$(LOCALBIN) $(GO) install k8s.io/kube-openapi/cmd/openapi-gen

$(CRD_REF_DOCS): ## install crd-ref-docs locally if necessary.
GOBIN=$(LOCALBIN) $(GO) install github.com/elastic/crd-ref-docs@latest
Comment on lines +36 to +45

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C2 'CONTROLLER_TOOLS_VERSION|CRD_REF_DOCS|OPENAPI_GEN|go install' \
  make/generate.mk go.mod go.sum 2>/dev/null || true

Repository: codeready-toolchain/api

Length of output: 1826


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- make/generate.mk ---'
cat -n make/generate.mk
printf '%s\n' '--- module and tool references ---'
rg -n -C3 'controller-tools|kube-openapi|crd-ref-docs|CONTROLLER_TOOLS_VERSION|CRD_REF_DOCS|OPENAPI_GEN|CONTROLLER_GEN|generate' \
  go.mod go.sum Makefile make .github 2>/dev/null || true
printf '%s\n' '--- tracked generator/config files ---'
git ls-files | rg '(^|/)(generate\.mk|go\.mod|go\.sum|Makefile|.*openapi.*|.*crd.*)' || true

Repository: codeready-toolchain/api

Length of output: 12817


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- downstream Go versions and API dependency ---'
rg -n -C2 '^(go|toolchain) |github.com/codeready-toolchain/api' go.mod

Repository: codeready-toolchain/toolchain-common

Length of output: 500


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- api module declarations ---'
sed -n '1,80p' go.mod
printf '%s\n' '--- generator target dependencies in the repository ---'
rg -n 'controller-gen|openapi-gen|crd-ref-docs|CONTROLLER_TOOLS_VERSION|`@latest`|go install' \
  --glob '!vendor/**' --glob '!node_modules/**' . 2>/dev/null || true
printf '%s\n' '--- recent changes for generate.mk ---'
git log --oneline -8 -- make/generate.mk

Repository: codeready-toolchain/api

Length of output: 12474


🌐 Web query:

Go command documentation go install package without @Version module-aware behavior and reproducibility

💡 Result:

When using the go install command without a version suffix (e.g., go install example.com/pkg), the behavior is strictly tied to the context of the main module [1][2][3]. In this mode, the command operates within the existing environment defined by the go.mod file in the current directory or its parent directory [1][2]. Key points regarding this behavior and reproducibility include: 1. Context-Dependent Execution: Without a version suffix, go install relies on the module graph, dependency requirements, and directives (such as replace or exclude) specified in the local go.mod file [2][3]. If invoked outside of a module while module-aware mode is enabled, the command will typically report an error [3][4]. 2. Reproducibility: Because this approach respects the versions already locked in your go.mod and go.sum files, it provides consistent, reproducible builds across different environments [2][5]. This is fundamentally different from using a version suffix like @latest, which intentionally ignores the local go.mod file and fetches the latest available version from the module proxy, thereby sacrificing local version pinning [1][2]. 3. Module-Aware Mode: The exact execution mode (module-aware vs. legacy GOPATH mode) is determined by the GO111MODULE environment variable and the presence of a go.mod file [1][6]. In modern Go, module-aware mode is the standard [1][7]. 4. Recommended Practice: For reproducible builds, it is best practice to manage dependencies via the go.mod file and install tools or packages without version suffixes, ensuring they adhere to the project's pinned dependency versions [2][8]. Using @version suffixes is intended specifically for installing tools or executables in a way that is isolated from the current project's dependency graph [1][2]. To ensure full reproducibility (including avoiding host-specific path leaks in binaries), it is recommended to use the -trimpath flag during the build or install process [9].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Makefile and tool declarations ---'
cat -n Makefile
printf '%s\n' '--- tools.go ---'
cat -n tools.go
printf '%s\n' '--- all CRD_REF_DOCS declarations/usages ---'
rg -n -C3 'CRD_REF_DOCS|crd-ref-docs|CONTROLLER_TOOLS_VERSION|controller-tools|kube-openapi' \
  --glob '!go.sum' . 2>/dev/null || true
printf '%s\n' '--- relevant commit summaries ---'
git show --stat --oneline b2e67fc 2>/dev/null || true
git show --format=fuller --no-ext-diff --unified=20 b2e67fc -- make/generate.mk tools.go go.mod 2>/dev/null || true

Repository: codeready-toolchain/api

Length of output: 12226


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- available crd-ref-docs release tags ---'
git ls-remote --tags --refs https://github.com/elastic/crd-ref-docs.git \
  | sed -n 's#.*refs/tags/##p' \
  | tail -20

Length of output: 277


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

mk = Path("make/generate.mk").read_text()
mod = Path("go.mod").read_text()
tools = Path("tools.go").read_text()

for name in ("CONTROLLER_GEN", "OPENAPI_GEN", "CRD_REF_DOCS", "CONTROLLER_TOOLS_VERSION"):
    defs = re.findall(rf"(?m)^\s*{name}\s*(?:\?[:]?=|:=|=)", mk)
    uses = len(re.findall(rf"\$\({name}\)", mk))
    print(f"{name}: definitions={len(defs)}, references={uses}")

for module in (
    "sigs.k8s.io/controller-tools",
    "k8s.io/kube-openapi",
    "github.com/elastic/crd-ref-docs",
):
    print(f"{module}: go.mod direct/indirect entries="
          f"{len(re.findall(rf'(?m)^\\s*{re.escape(module)}\\s+\\S+', mod))}")
    print(f"{module}: tools.go reference={module in tools}")
PY

printf '%s\n' '--- dry-run of the affected target with an isolated minimal Makefile ---'
make -f - -n gen-crd-ref-docs <<'EOF'
CRD_REF_DOCS :=
gen-crd-ref-docs: $(CRD_REF_DOCS)
	$(CRD_REF_DOCS) --source-path ./api/v1alpha1
EOF

Repository: codeready-toolchain/api

Length of output: 398


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Makefile includes and variable definitions ---'
rg -n -C4 'include|CRD_REF_DOCS|LOCALBIN|GO[[:space:]]*[:?+]?=' Makefile make .github 2>/dev/null || true
printf '%s\n' '--- tool module declarations ---'
rg -n -C2 'sigs.k8s.io/controller-tools|k8s.io/kube-openapi|github.com/elastic/crd-ref-docs' \
  go.mod tools.go go.sum

Repository: codeready-toolchain/api

Length of output: 4833


Define CRD_REF_DOCS and pin crd-ref-docs.

CRD_REF_DOCS is undefined, so make generate cannot run the documentation generator. Define it under LOCALBIN and replace @latest with a fixed version. controller-gen and openapi-gen already use versions selected by go.mod.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@make/generate.mk` around lines 18 - 27, Define CRD_REF_DOCS alongside the
other generator binary variables so it resolves under LOCALBIN, then update the
CRD_REF_DOCS installation rule to install a fixed crd-ref-docs version instead
of `@latest`. Preserve the existing controller-gen and openapi-gen version
behavior.


.PHONY: generate
generate: generate-object generate-crd gen-crd-ref-docs generate-openapi dispatch-crds ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

Expand Down
20 changes: 20 additions & 0 deletions make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ GO_PACKAGE_ORG_NAME ?= $(shell basename $$(dirname $$PWD))
GO_PACKAGE_REPO_NAME ?= $(shell basename $$PWD)
GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME}

.PHONY: format-go-code
## Formats any go file that does not match formatting defined by gofmt
format-go-code:
# The + tells find to batch multiple found files into a single gofmt invocation (like xargs),
# which is much faster than the alternative \;, which runs gofmt once per file. Removing it
# would be a syntax error — find -exec requires either + or \; as a terminator.
$(Q)find . -name '*.go' -not -path '*/vendor/*' -not -path '*/.git/*' -exec gofmt -s -l -w {} +

.PHONY: check-go-format
## Verify the formatting defined by 'gofmt'
check-go-format:
$(Q)find . -name '*.go' -not -path '*/vendor/*' -not -path '*/.git/*' -exec gofmt -s -l {} + 2>&1 \
| tee $(OUT_DIR)/gofmt-errors \
| read \
&& echo "ERROR: These files differ from gofmt's style (run 'make format-go-code' to fix this):" \
&& cat $(OUT_DIR)/gofmt-errors \
&& exit 1 \
|| true

.PHONY: build
## Build
build:
Expand All @@ -17,3 +36,4 @@ build:
.PHONY: verify-replace-run
verify-replace-run:
./scripts/verify-replace.sh;

Loading