mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
bake: raise maximum size limit and fix size check
Similar to https://github.com/docker/buildx/pull/2716. Use the file size rather than the proto size, raise the allowed limit to the same value for consistency, and improve the error message to include the limit in human units. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
parent
48153169d8
commit
9fc6f39d71
@ -11,15 +11,17 @@ import (
|
|||||||
controllerapi "github.com/docker/buildx/controller/pb"
|
controllerapi "github.com/docker/buildx/controller/pb"
|
||||||
"github.com/docker/buildx/driver"
|
"github.com/docker/buildx/driver"
|
||||||
"github.com/docker/buildx/util/progress"
|
"github.com/docker/buildx/util/progress"
|
||||||
|
"github.com/docker/go-units"
|
||||||
"github.com/moby/buildkit/client"
|
"github.com/moby/buildkit/client"
|
||||||
"github.com/moby/buildkit/client/llb"
|
"github.com/moby/buildkit/client/llb"
|
||||||
"github.com/moby/buildkit/frontend/dockerui"
|
"github.com/moby/buildkit/frontend/dockerui"
|
||||||
gwclient "github.com/moby/buildkit/frontend/gateway/client"
|
gwclient "github.com/moby/buildkit/frontend/gateway/client"
|
||||||
"github.com/moby/buildkit/session"
|
"github.com/moby/buildkit/session"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxBakeDefinitionSize = 2 * 1024 * 1024 // 2 MB
|
||||||
|
|
||||||
type Input struct {
|
type Input struct {
|
||||||
State *llb.State
|
State *llb.State
|
||||||
URL string
|
URL string
|
||||||
@ -178,9 +180,9 @@ func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Refere
|
|||||||
name := inp.URL
|
name := inp.URL
|
||||||
inp.URL = ""
|
inp.URL = ""
|
||||||
|
|
||||||
if len(dt) > proto.Size(stat) {
|
if int64(len(dt)) > stat.Size {
|
||||||
if proto.Size(stat) > 1024*512 {
|
if stat.Size > maxBakeDefinitionSize {
|
||||||
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size")
|
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size (%s)", units.HumanSize(maxBakeDefinitionSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
dt, err = ref.ReadFile(ctx, gwclient.ReadRequest{
|
dt, err = ref.ReadFile(ctx, gwclient.ReadRequest{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user