init: export generated files and install the module in one call#6
Open
eunomie wants to merge 4 commits into
Open
init: export generated files and install the module in one call#6eunomie wants to merge 4 commits into
eunomie wants to merge 4 commits into
Conversation
Add reusable fork primitives so an SDK 'init' can stage a new module, generate it, and register it in the workspace in a single returned Changeset: - PolyfillWorkspaceFork.withGeneratedModule generates a module that only exists in the fork's staged 'after' state (it is not on the host yet) and overlays the generated files. Codegen cannot run from inside a module function, so it routes through the workspace-module-generate helper, extended with a --staged-dir-id mode that loads the staged directory by ID and runs GeneratedContextChangeset. - PolyfillWorkspaceFork.withInstalledModule registers the module in the workspace dagger.toml under [modules.<name>], mirroring 'dagger mod install'. Re-installing the same name is a no-op. Signed-off-by: Yves Brissaud <yves@dagger.io>
Add checks for the new fork primitives: generating a module that only exists in the fork adds its generated files, installing it records a [modules.<name>] entry in dagger.toml with a workspace-relative source, and re-installing the same module is a no-op. Signed-off-by: Yves Brissaud <yves@dagger.io>
Wire the SDK init skeleton to the new polyfill primitives so a scaffolded SDK's 'init' leaves a ready-to-run module: it stages the module, generates it, and installs it into the workspace in one Changeset, with no follow-up generate or install step. Signed-off-by: Yves Brissaud <yves@dagger.io>
b5ca544 to
c6ebcbd
Compare
The four PolyfillGeneration functions each rebuilt the same golang:1.26-alpine container (go caches, mount + build the workspace-module-generate helper) and three repeated the same --cwd/--local flag construction. Extract both into a shared 'helper' container field and a 'locationFlags' helper, leaving each function with just its env var and exec. Signed-off-by: Yves Brissaud <yves@dagger.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make a new SDK module usable from a single
initcall. Today, creating a modulewith e.g.
dagger call go-sdk initrequires two manual follow-ups before it canbe used:
This folds generate and install into the single
Changesetthatinitalready returns, so one call leaves a ready-to-run module. The work lives in the
shared
polyfill, so every SDK inherits it once bumped (the per-SDKinitoptsin with two lines — see the companion
go-sdkchange).What changed
polyfill— two reusable fork primitives:PolyfillWorkspaceFork.withGeneratedModule(modulePath)generates a modulethat exists only in the fork's staged state (not on the host yet) and
overlays the generated files. Codegen can't run from inside a Dang module
function, so it routes through the
workspace-module-generatehelper,extended with a
--staged-dir-idmode that loads the staged directory by IDand runs
GeneratedContextChangeset.PolyfillWorkspaceFork.withInstalledModule(modulePath, name)registers themodule in the workspace
dagger.tomlunder[modules.<name>], mirroringdagger mod install. Re-installing the same name is a no-op.init-template— the SDK init skeleton wires both primitives (generatealways; self-install skipped for a root-level module at path
.).polyfill-e2e— checks for staged generate, install, and installidempotency.
No API changes:
initkeeps its signature.Verification
dagger call <sdk> init --name mybuild -yproduced the module +dagger.gen.go/go.mod/internal/...+ adagger.tomlentry, anddagger call mybuild ...worked immediately — no separate generate/install.dagger check -m .dagger/modules/polyfill-e2e(11 checks, incl. 3 new)passes on engine
v1.0.0-beta.3.go test/go vetpass.Follow-ups
go-sdkchange wires itsinitto these primitives.initwiring once this
polyfillis bumped.