Skip to content

build: keep replaced plugin modules in the require graph#5682

Merged
norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:fix/plugins-keep-tidy
Jul 22, 2026
Merged

build: keep replaced plugin modules in the require graph#5682
norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:fix/plugins-keep-tidy

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

What

Add src/jetstream/plugins_keep.go, a //go:build tools file that
blank-imports the three local plugin modules that have their own go.mod
and a replace directive: cfapppush, kubernetes (and kubernetes/auth
transitively), and monocular.

Why

Those modules are otherwise imported only by extra_plugins.go, which is
generated from plugin-config.yaml and gitignored so each deployment can
choose its own plugin set. On any checkout where generation has not run —
Dependabot, a fresh clone, an IDE before go generatego mod tidy cannot
see those imports, prunes their require lines while the replace directives
remain, and fails every backend build with:

module .../plugins/cfapppush ... is replaced but not required

This is why every Go Dependabot PR has been failing the backend build.

How this changes file production

The module graph is no longer produced solely from the generated,
deployment-specific extra_plugins.go. The keep-file pins those requires
independently, so go mod tidy yields a consistent go.mod whether or not
generation has run. extra_plugins.go stays gitignored and remains the only
thing that controls what a deployment actually compiles in — the keep-file is
excluded from every normal build by its tools tag.

Effect on operators

  • Deploying from a release artifact (tarball / cf-push zip / docker image):
    no change. The shipped binary is identical; the keep-file is never compiled
    in.
  • Building from source: builds are more robust — fresh-clone and go mod tidy
    no longer break. Selecting a plugin subset via plugin-config.yaml /
    extra_plugins.go works exactly as before.
  • An operator who physically removes one of the three plugin directories from
    a fork must also drop that import from plugins_keep.go.

Verification

  • Dependabot scenario (remove extra_plugins.go, go mod tidy, build):
    build passes, go.mod byte-identical to committed.
  • Subset build excluding the three modules: builds and does not link them in.
  • go build ./... (normal) unaffected; keep-file excluded by the tools tag.

The local plugin modules with their own go.mod (cfapppush, kubernetes,
monocular) are imported only by extra_plugins.go, which is generated from
plugin-config.yaml and gitignored so each deployment picks its own plugin
set. On any checkout where generation has not run — dependabot, a fresh
clone, an IDE before `go generate` — `go mod tidy` cannot see those imports,
prunes their require lines while the replace directives remain, and fails
every backend build with "replaced but not required".

Add a `//go:build tools` keep-file that blank-imports those three modules to
pin their requires regardless of extra_plugins.go. It is never compiled into
the binary; what a deployment runs is still controlled solely by the
gitignored extra_plugins.go.

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@norman-abramovitz
norman-abramovitz merged commit 27c106a into cloudfoundry:develop Jul 22, 2026
22 checks passed
@nabramovitz
nabramovitz deleted the fix/plugins-keep-tidy branch July 22, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants