Repository navigation
Declare the Dagger version in the dagger import - #206
Merged
Merged
Conversation
Deploying dang with
|
| Latest commit: |
f5c896e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://027c3ed6.dang-3kk.pages.dev |
| Branch Preview URL: | https://dagger-view.dang-3kk.pages.dev |
A Dagger import's `dagger` key takes the Dagger API version its source is
written against, written like the `dang` key:
[imports.Dagger]
dagger = "v0.19.0"
The engine picks a client's core API view from its client version, which
`dagger session --version` sets, so the version is appended to the session
command (the default one or a custom `service`). A Dagger module's schema is
introspected with ModuleSource.withEngineVersion, since
introspectionSchemaJSON otherwise uses the module's own engineVersion. Both
get vX.Y.Z: Dagger guesses at versions without the "v" or the patch, and
the parser already drops prerelease suffixes as engine.APIViewVersion does.
An engine older than the version would silently serve its own API and echo
the requested view in __schemaVersion, so a new session is checked against
the engine's version first. A version can't be combined with `endpoint`,
whose view Dang doesn't control.
`dagger = true` keeps its meaning: no version is passed, so the API follows
the dagger CLI that starts the session, and a module's schema follows its
engineVersion. ImportSource.Dagger and ImportConfig.DaggerVersion let
embedders read the version.
Signed-off-by: Alex Suraci <[email protected]>
Show `dagger = "vX.Y.Z"` in the dang.toml reference and the dang-language skill, in place of `dagger = true`. Signed-off-by: Alex Suraci <[email protected]>
Version.String writes Dang versions: it drops a zero patch and prints the zero Version as the current Dang version, so an embedder formatting ImportConfig.DaggerVersion for `dagger = true` got "2.1". Export DaggerVersionString and DaggerSource.VersionString, which give "vX.Y.Z" or "" for no version, use them internally, and point the doc comments at them. DaggerSource now marshals to JSON and TOML as false, true or "vX.Y.Z", and a JSON null decodes as no Dagger import, so a marshaled ImportSource decodes back. Signed-off-by: Alex Suraci <[email protected]>
Say what the older form means, and that it's the one to use with endpoint. Signed-off-by: Alex Suraci <[email protected]>
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.
Based on main (#185 has merged). A Dagger import's
daggerkey now takes the Dagger API version its source is written against, the same waydang = "..."takes the Dang version:Why
Since #185,
dangsets up Dagger only when dang.toml declares a Dagger import. A nearby dagger.json or dagger.toml no longer turns it on just because a dang.toml exists. That makes the declaration worth something: it can say which core API the module targets, so a newer engine keeps serving the API the code was written for.The
daggerkeydang(Declare the Dang version per project, add dang migrate #185's sharedparseVersion): an optional leadingv,X.YorX.Y.Z, and an optional prerelease or build suffix, which is dropped (Keep the prerelease of the declared Dagger version #208 keeps the prerelease, which Dagger's prerelease-granular API views need). A module'sengineVersion, e.g.v1.0.0-beta.19, can be copied in as is.vX.Y.Z, since Dagger guesses at versions without thevor the patch (vX.Y.Z[-prerelease]with Keep the prerelease of the declared Dagger version #208)."0.19"becomesv0.19.0.dagger = truestill works and means what it did: no version is sent, the API follows thedaggerCLI that starts the session, and a Dagger module's schema follows itsengineVersion. The docs lead with the version form.trueis also the form to use withendpoint.endpoint, since an endpoint's version was set by whoever started it, and"0.0".ImportSource.Daggeris now aDaggerSource{Enabled, Version}, andImportConfiggainsDaggerVersion. Embedders (the Dagger SDK) can read the version withDaggerSource.VersionString()/DaggerVersionString(Version), which returnvX.Y.Z, or""fordagger = true. Don't useVersion.String(), which uses Dang's format.DaggerSourcereads and writesfalse,trueor"vX.Y.Z"in both TOML and JSON (a service's JSON output is read intoImportSource), and"dagger": nullmeans no Dagger import.How Dagger picks the API version
From reading dagger/dagger main at the time (the same at v0.19.0). Since then: dagger#14881 (merged) lets a module's clients declare their own version, which is what a standalone
dangsession's--versionalready does; dagger#14810 (in review) makes v1.0.0 prerelease views granular from v1.0.0-beta.22 and caps a module's declared view at the engine's; dagger#14902 (in review) makes the dang.toml governing an entrypoint module's sources that module's engine version.engine.APIViewVersion(clientVersion)(engine/server/session.go:1542). Prerelease and build suffixes are dropped (engine/version.go:165).dagger session --version <v>sets the client version (internal/cmd/dagger/session.go:53,engine/client/client.go:1889-1906). Requests can't override it, because the session proxy rewritesX-Dagger-Client-Metadata(client.go:1710). The Go SDK'sWithVersionOverrideuses the same flag.--version, the CLI's own version is used. The API served follows thedaggerCLI that starts the session, not the engine's latest.MinimumClientVersion(v0.19.0), anddagger sessionfails on startup.__schemaVersion.engineVersion, not the session's (core/schema/modulesource.go:1128-1141).ModuleSource.withEngineVersionoverrides it.What Dang does with a version
--version vX.Y.Zis added to the session command, the defaultdagger sessionor a customservice.{ version __schemaVersion }. If the engine is older than the declared version, it stops with "…the Dagger engine is vX; upgrade Dagger". This catches the case where the engine would otherwise quietly serve an older API.moduleSource(ref).withEngineVersion("vX.Y.Z").introspectionSchemaJSON.Open questions (resolved)
engineVersion: resolved on the Dagger side. Dagger will make dang.toml'sdaggerthe version of every Dang module, winning overengineVersion(which is being retired): dagger#14902 does it for entrypoint modules, and a follow-up does it for all Dang modules. Type-checking and the runtime then agree by construction, so Dang needs no warning.--versionis a hidden flag that Dagger calls test-only: resolved. The Go SDK now passessession --versionby default (dagger#14879, merged), so Dagger relies on the flag outside tests. It has been stable from v0.19 to main.Tests
pkg/dang/dagger_version_test.go, with no real engine involved:daggerkey parsing:true,false, version forms,null, wrong types, and the refused combinations;ImportSourcefor each form;ResolveDaggerImport;daggerscript and HTTP server. It asserts the session was started assession --version v0.19.0, that the check runs before introspection, that an older engine fails, and thatdagger = truestarts a plainsessionwith no check.