Enable to get build definition from Inspect API

This commit adds two fields to the response of Inspect API.

- Definition: Build definition of the first build executed by Build API.
- CurrentDefinition: Build definition of the latest build executed by Build or
  Solve API.

The client can use these information for debugging the build deeply.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
Kohei Tokunaga
2023-06-30 20:57:17 +09:00
parent f72ea677f1
commit 4c730ee96b
5 changed files with 201 additions and 135 deletions

View File

@@ -146,7 +146,15 @@ func (b *localController) Inspect(ctx context.Context, ref string) (*controllera
if ref != b.ref {
return nil, errors.Errorf("unknown ref %q", ref)
}
return &controllerapi.InspectResponse{Options: b.buildConfig.buildOptions}, nil
var curDef *solverpb.Definition
var origDef *solverpb.Definition
if b.buildConfig.resultCtx != nil {
curDef, _ = build.DefinitionFromResultHandler(ctx, b.buildConfig.resultCtx)
}
if b.originalResult != nil {
origDef, _ = build.DefinitionFromResultHandler(ctx, b.originalResult)
}
return &controllerapi.InspectResponse{Options: b.buildConfig.buildOptions, Definition: origDef, CurrentDefinition: curDef}, nil
}
func (b *localController) Solve(ctx context.Context, ref string, target *solverpb.Definition, progress progress.Writer) error {