mirror of
https://github.com/docker/compose.git
synced 2026-02-09 01:59:22 +08:00
check buildx version before comparing it
Signed-off-by: yangfeiyu <yangfeiyu20102011@163.com>
This commit is contained in:
committed by
Nicolas De loof
parent
08de90c267
commit
000a4a4b9f
@@ -289,15 +289,11 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
|
||||
_ = os.Remove(metadataFile)
|
||||
}()
|
||||
|
||||
buildx, err := manager.GetPlugin("buildx", s.dockerCli, &cobra.Command{})
|
||||
buildx, err := s.getBuildxPlugin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if versions.LessThan(buildx.Version[1:], "0.17.0") {
|
||||
return nil, fmt.Errorf("compose build requires buildx 0.17 or later")
|
||||
}
|
||||
|
||||
args := []string{"bake", "--file", "-", "--progress", "rawjson", "--metadata-file", metadataFile}
|
||||
// FIXME we should prompt user about this, but this is a breaking change in UX
|
||||
for _, path := range read {
|
||||
@@ -414,6 +410,27 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (s *composeService) getBuildxPlugin() (*manager.Plugin, error) {
|
||||
buildx, err := manager.GetPlugin("buildx", s.dockerCli, &cobra.Command{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if buildx.Err != nil {
|
||||
return nil, buildx.Err
|
||||
}
|
||||
|
||||
if buildx.Version == "" {
|
||||
return nil, fmt.Errorf("failed to get version of buildx")
|
||||
}
|
||||
|
||||
if versions.LessThan(buildx.Version[1:], "0.17.0") {
|
||||
return nil, fmt.Errorf("compose build requires buildx 0.17 or later")
|
||||
}
|
||||
|
||||
return buildx, nil
|
||||
}
|
||||
|
||||
// makeConsole wraps the provided writer to match [containerd.File] interface if it is of type *streams.Out.
|
||||
// buildkit's NewDisplay doesn't actually require a [io.Reader], it only uses the [containerd.Console] type to
|
||||
// benefits from ANSI capabilities, but only does writes.
|
||||
|
||||
Reference in New Issue
Block a user