-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dockerfile: support for outline requests #2841
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec9a3ac
dockerfile: support for outline requests
tonistiigi b1a2aa7
buildctl: print subrequest metadata result to stdout
tonistiigi 3b1fd05
dockerfile: add secret and ssh information to outline
tonistiigi f950ba7
dockerfile: add request for listing targets
tonistiigi e7c8b22
dockerfile: add target stage information to outline
tonistiigi b88e435
subrequests: add base and platform to targets request
tonistiigi 9924649
subrequest: always return version with subrequest result
tonistiigi f7bbe2f
subrequests: add text formatting to results
tonistiigi d1b0d8a
subrequests: normalize json fields to lowercase
tonistiigi 28a156b
dockerfile: remove filtering out empty targets
tonistiigi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want a case for
result.json
as well? Feels like we could format it here, in case the frontend hasn't done it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need a specific printer for this and I don't want
buildctl
to have too much hardcoded info about specific requests.Or are you saying that if there is a
result.json
we should only print that directly and not the full result like it is in current commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we have an exception for
result.txt
, I'm just wondering why we shouldn't also have one forresult.json
. I think at the least, we should print directly and not the whole result if we find aresult.json
similar toresult.txt
.Although maybe for buildctl, since it's a dev tool, we should assume no knowledge of the response, and always print out everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That what it does atm. There is a special case for
result.txt
, so if it exists then the expectation is that frontend has already formatted the result and we can just print that output. Otherwise we just print whatever frontend provided(including result.json). If it makes more sense I can make it so that it only printsresult.json
if it exists and skips the rest.