api/server/router/build: BuilderVersion: allow buildkit on Windows

Commit 7b153b9e28 changed the daemon to
advertise the recommended builder to use to V2 (BuildKit) for Linux
daemons, and V1 (Legacy Builder) for Windows daemons. For Linux daemons
we allowed the default to be overridden through the "features" field
in the daemon config (daemon.json), but for Windows we hard-coded it
to be V1, and no option to override.

With work in progress on implementing support for Windows in BuildKit,
we should remove this hardcoded assumption, and allow the default to
be overridden to advertise that BuildKit is supported.

Note that BuildKit on Windows is still very much a "work in progress",
and enabling it in the daemon may not even work, so users should not
try to enable this feature; a warning-level log is added to make it
visible that the feature is enabled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-06-20 01:15:58 +02:00
parent f4ffeb8c38
commit c6b9bb00f9
2 changed files with 19 additions and 6 deletions

View File

@@ -294,6 +294,12 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
return fmt.Errorf("error initializing buildkit: %w", err)
}
if runtime.GOOS == "windows" {
if enabled, ok := d.Features()["buildkit"]; ok && enabled {
log.G(ctx).Warn("Buildkit feature is enabled in the daemon.json configuration file. Support for BuildKit on Windows is experimental, and enabling this feature may not work. Use at your own risk!")
}
}
routers := buildRouters(routerOptions{
features: d.Features,
daemon: d,