add cap support check to gatewayClientForBuild
Signed-off-by: Cory Bennett <cbennett@netflix.com>v0.8
parent
516b9ec844
commit
efb36aa53c
|
@ -45,11 +45,16 @@ func (c *Client) Build(ctx context.Context, opt SolveOpt, product string, buildF
|
||||||
}
|
}
|
||||||
|
|
||||||
cb := func(ref string, s *session.Session) error {
|
cb := func(ref string, s *session.Session) error {
|
||||||
g, err := grpcclient.New(ctx, feOpts, s.ID(), product, c.gatewayClientForBuild(ref), gworkers)
|
gwClient := c.gatewayClientForBuild(ref)
|
||||||
|
g, err := grpcclient.New(ctx, feOpts, s.ID(), product, gwClient, gworkers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c, ok := g.(gateway.Client); ok {
|
||||||
|
gwClient.caps = c.BuildOpts().Caps
|
||||||
|
}
|
||||||
|
|
||||||
if err := g.Run(ctx, buildFunc); err != nil {
|
if err := g.Run(ctx, buildFunc); err != nil {
|
||||||
return errors.Wrap(err, "failed to run Build function")
|
return errors.Wrap(err, "failed to run Build function")
|
||||||
}
|
}
|
||||||
|
@ -59,14 +64,18 @@ func (c *Client) Build(ctx context.Context, opt SolveOpt, product string, buildF
|
||||||
return c.solve(ctx, nil, cb, opt, statusChan)
|
return c.solve(ctx, nil, cb, opt, statusChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) gatewayClientForBuild(buildid string) gatewayapi.LLBBridgeClient {
|
func (c *Client) gatewayClientForBuild(buildid string) *gatewayClientForBuild {
|
||||||
g := gatewayapi.NewLLBBridgeClient(c.conn)
|
g := gatewayapi.NewLLBBridgeClient(c.conn)
|
||||||
return &gatewayClientForBuild{g, buildid}
|
return &gatewayClientForBuild{
|
||||||
|
gateway: g,
|
||||||
|
buildID: buildid,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type gatewayClientForBuild struct {
|
type gatewayClientForBuild struct {
|
||||||
gateway gatewayapi.LLBBridgeClient
|
gateway gatewayapi.LLBBridgeClient
|
||||||
buildID string
|
buildID string
|
||||||
|
caps apicaps.CapSet
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) ResolveImageConfig(ctx context.Context, in *gatewayapi.ResolveImageConfigRequest, opts ...grpc.CallOption) (*gatewayapi.ResolveImageConfigResponse, error) {
|
func (g *gatewayClientForBuild) ResolveImageConfig(ctx context.Context, in *gatewayapi.ResolveImageConfigRequest, opts ...grpc.CallOption) (*gatewayapi.ResolveImageConfigResponse, error) {
|
||||||
|
@ -85,11 +94,17 @@ func (g *gatewayClientForBuild) ReadFile(ctx context.Context, in *gatewayapi.Rea
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) ReadDir(ctx context.Context, in *gatewayapi.ReadDirRequest, opts ...grpc.CallOption) (*gatewayapi.ReadDirResponse, error) {
|
func (g *gatewayClientForBuild) ReadDir(ctx context.Context, in *gatewayapi.ReadDirRequest, opts ...grpc.CallOption) (*gatewayapi.ReadDirResponse, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapReadDir); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.ReadDir(ctx, in, opts...)
|
return g.gateway.ReadDir(ctx, in, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) StatFile(ctx context.Context, in *gatewayapi.StatFileRequest, opts ...grpc.CallOption) (*gatewayapi.StatFileResponse, error) {
|
func (g *gatewayClientForBuild) StatFile(ctx context.Context, in *gatewayapi.StatFileRequest, opts ...grpc.CallOption) (*gatewayapi.StatFileResponse, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapStatFile); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.StatFile(ctx, in, opts...)
|
return g.gateway.StatFile(ctx, in, opts...)
|
||||||
}
|
}
|
||||||
|
@ -105,21 +120,33 @@ func (g *gatewayClientForBuild) Return(ctx context.Context, in *gatewayapi.Retur
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) Inputs(ctx context.Context, in *gatewayapi.InputsRequest, opts ...grpc.CallOption) (*gatewayapi.InputsResponse, error) {
|
func (g *gatewayClientForBuild) Inputs(ctx context.Context, in *gatewayapi.InputsRequest, opts ...grpc.CallOption) (*gatewayapi.InputsResponse, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapFrontendInputs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.Inputs(ctx, in, opts...)
|
return g.gateway.Inputs(ctx, in, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) NewContainer(ctx context.Context, in *gatewayapi.NewContainerRequest, opts ...grpc.CallOption) (*gatewayapi.NewContainerResponse, error) {
|
func (g *gatewayClientForBuild) NewContainer(ctx context.Context, in *gatewayapi.NewContainerRequest, opts ...grpc.CallOption) (*gatewayapi.NewContainerResponse, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.NewContainer(ctx, in, opts...)
|
return g.gateway.NewContainer(ctx, in, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) ReleaseContainer(ctx context.Context, in *gatewayapi.ReleaseContainerRequest, opts ...grpc.CallOption) (*gatewayapi.ReleaseContainerResponse, error) {
|
func (g *gatewayClientForBuild) ReleaseContainer(ctx context.Context, in *gatewayapi.ReleaseContainerRequest, opts ...grpc.CallOption) (*gatewayapi.ReleaseContainerResponse, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.ReleaseContainer(ctx, in, opts...)
|
return g.gateway.ReleaseContainer(ctx, in, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gatewayClientForBuild) ExecProcess(ctx context.Context, opts ...grpc.CallOption) (gatewayapi.LLBBridge_ExecProcessClient, error) {
|
func (g *gatewayClientForBuild) ExecProcess(ctx context.Context, opts ...grpc.CallOption) (gatewayapi.LLBBridge_ExecProcessClient, error) {
|
||||||
|
if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
|
||||||
return g.gateway.ExecProcess(ctx, opts...)
|
return g.gateway.ExecProcess(ctx, opts...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue