build: add experimental support for print flag

Print flag can be used to make additional information
requests about the build and print their results.

Currently Dockerfile supports: outline, targets, subrequests.describe

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2022-05-04 18:48:50 -07:00
parent 17dc0e1108
commit eefa8188e1
98 changed files with 8536 additions and 3339 deletions

View File

@ -10,18 +10,18 @@ import (
)
type UsageInfo struct {
ID string
Mutable bool
InUse bool
Size int64
ID string `json:"id"`
Mutable bool `json:"mutable"`
InUse bool `json:"inUse"`
Size int64 `json:"size"`
CreatedAt time.Time
LastUsedAt *time.Time
UsageCount int
Parents []string
Description string
RecordType UsageRecordType
Shared bool
CreatedAt time.Time `json:"createdAt"`
LastUsedAt *time.Time `json:"lastUsedAt"`
UsageCount int `json:"usageCount"`
Parents []string `json:"parents"`
Description string `json:"description"`
RecordType UsageRecordType `json:"recordType"`
Shared bool `json:"shared"`
}
func (c *Client) DiskUsage(ctx context.Context, opts ...DiskUsageOption) ([]*UsageInfo, error) {

View File

@ -9,13 +9,13 @@ import (
)
type Info struct {
BuildkitVersion BuildkitVersion
BuildkitVersion BuildkitVersion `json:"buildkitVersion"`
}
type BuildkitVersion struct {
Package string
Version string
Revision string
Package string `json:"package"`
Version string `json:"version"`
Revision string `json:"revision"`
}
func (c *Client) Info(ctx context.Context) (*Info, error) {

View File

@ -61,7 +61,7 @@ func (smc *sourceMapCollector) Add(dgst digest.Digest, ls []*SourceLocation) {
}
smc.index[l.SourceMap] = idx
}
smc.locations[dgst] = ls
smc.locations[dgst] = append(smc.locations[dgst], ls...)
}
func (smc *sourceMapCollector) Marshal(ctx context.Context, co ...ConstraintsOpt) (*pb.Source, error) {

View File

@ -199,10 +199,10 @@ func marshal(ctx context.Context, v Vertex, def *Definition, s *sourceMapCollect
if opMeta != nil {
def.Metadata[dgst] = mergeMetadata(def.Metadata[dgst], *opMeta)
}
s.Add(dgst, sls)
if _, ok := cache[dgst]; ok {
return def, nil
}
s.Add(dgst, sls)
def.Def = append(def.Def, dt)
cache[dgst] = struct{}{}
return def, nil

View File

@ -209,8 +209,10 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
<-time.After(3 * time.Second)
cancelStatus()
}()
bklog.G(ctx).Debugf("stopping session")
s.Close()
if !opt.SessionPreInitialized {
bklog.G(ctx).Debugf("stopping session")
s.Close()
}
}()
var pbd *pb.Definition
if def != nil {