-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2841 from tonistiigi/outline
dockerfile: support for outline requests
- Loading branch information
Showing
16 changed files
with
1,380 additions
and
240 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
package builder | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/moby/buildkit/frontend/gateway/client" | ||
"github.com/moby/buildkit/frontend/subrequests" | ||
"github.com/moby/buildkit/frontend/subrequests/outline" | ||
"github.com/moby/buildkit/frontend/subrequests/targets" | ||
"github.com/moby/buildkit/solver/errdefs" | ||
) | ||
|
||
func checkSubRequest(ctx context.Context, opts map[string]string) (*client.Result, bool, error) { | ||
req, ok := opts["requestid"] | ||
req, ok := opts[keyRequestID] | ||
if !ok { | ||
return nil, false, nil | ||
} | ||
switch req { | ||
case subrequests.RequestSubrequestsDescribe: | ||
res, err := describe() | ||
return res, true, err | ||
case outline.RequestSubrequestsOutline, targets.RequestTargets: // handled later | ||
return nil, false, nil | ||
default: | ||
return nil, true, errdefs.NewUnsupportedSubrequestError(req) | ||
} | ||
} | ||
|
||
func describe() (*client.Result, error) { | ||
all := []subrequests.Request{ | ||
outline.SubrequestsOutlineDefinition, | ||
targets.SubrequestsTargetsDefinition, | ||
subrequests.SubrequestsDescribeDefinition, | ||
} | ||
dt, err := json.MarshalIndent(all, " ", "") | ||
dt, err := json.MarshalIndent(all, "", " ") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
b := bytes.NewBuffer(nil) | ||
if err := subrequests.PrintDescribe(dt, b); err != nil { | ||
return nil, err | ||
} | ||
|
||
res := client.NewResult() | ||
res.Metadata = map[string][]byte{ | ||
"result.json": dt, | ||
"result.txt": b.Bytes(), | ||
"version": []byte(subrequests.SubrequestsDescribeDefinition.Version), | ||
} | ||
return res, nil | ||
} |
Oops, something went wrong.