From 7e7c49c2e7a498adc018bc6eb56ae1036975b0bd Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 24 Feb 2023 23:59:02 -0700 Subject: [PATCH] Exposed build output to api --- admin_api/admin_api.go | 10 ++++++++++ database/func.go | 3 ++- database/types.go | 13 +++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/admin_api/admin_api.go b/admin_api/admin_api.go index 9750fb8..27847fe 100644 --- a/admin_api/admin_api.go +++ b/admin_api/admin_api.go @@ -217,6 +217,16 @@ func createSchema(db database.Database) (graphql.Schema, error) { return nil, nil }, }, + "buildOutput": &graphql.Field{ + Type: graphql.String, + Description: "Logs of the top level container build for the run.", + Resolve: func(p graphql.ResolveParams) (interface{}, error) { + if run, ok := p.Source.(database.Run); ok { + return string(run.BuildOutput), nil + } + return nil, nil + }, + }, "stdout": &graphql.Field{ Type: graphql.String, Description: "The stdout used to validate the run.", diff --git a/database/func.go b/database/func.go index b481f42..dd4a026 100644 --- a/database/func.go +++ b/database/func.go @@ -323,7 +323,7 @@ WHERE id=$5;` func (db *Database) GetRunsForPipeline(pipelineId uuid.UUID) ([]Run, error) { query := ` -SELECT id, in_progress, result, stdout, stderr +SELECT id, in_progress, result, build_output, stdout, stderr FROM runs WHERE pipeline=$1;` @@ -342,6 +342,7 @@ WHERE pipeline=$1;` &idStr, &run.InProgress, &run.Result, + &run.BuildOutput, &run.Stdout, &run.Stderr, ); err != nil { diff --git a/database/types.go b/database/types.go index f4c003b..1c2bffc 100644 --- a/database/types.go +++ b/database/types.go @@ -54,12 +54,13 @@ type Webhook struct { } type Run struct { - Id uuid.UUID - Pipeline uuid.UUID - InProgress bool - Result *int64 - Stdout []byte - Stderr []byte + Id uuid.UUID + Pipeline uuid.UUID + InProgress bool + Result *int64 + BuildOutput []byte + Stdout []byte + Stderr []byte } type CommandExecution struct {