Skip to content

Commit

Permalink
Move regex up, to match reprotRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperMalachowski committed Jan 31, 2025
1 parent 62883db commit 1eccbbb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/imagebuilder/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import (
)

// reportRegex is a regular expression that matches the image build report
var reportRegex = regexp.MustCompile(`(?s)---IMAGE BUILD REPORT---\n(.*)\n---END OF IMAGE BUILD REPORT---`)
var (
reportRegex = regexp.MustCompile(`(?s)---IMAGE BUILD REPORT---\n(.*)\n---END OF IMAGE BUILD REPORT---`)

timestampRegex = regexp.MustCompile(`\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z\s+`)
)

type BuildReport struct {
// Status is the overall status of the build including signing and pushing
Expand Down Expand Up @@ -45,7 +49,7 @@ func (br *BuildReport) GetImages() []string {

func NewBuildReportFromLogs(log string) (*BuildReport, error) {
// Strip all timestamps from log
log = regexp.MustCompile(`\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z\s+`).ReplaceAllString(log, "")
log = timestampRegex.ReplaceAllString(log, "")

// Find the report in the log
matches := reportRegex.FindStringSubmatch(log)
Expand Down

0 comments on commit 1eccbbb

Please sign in to comment.