Skip to content

Commit

Permalink
fix(testworkflows): support +00:00 timezone in CLI TestWorkflows logs (
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 authored Jun 12, 2024
1 parent c4548a9 commit cefbfa2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/kubectl-testkube/commands/testworkflows/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ func printResultDifference(res1 *testkube.TestWorkflowResult, res2 *testkube.Tes
return changed
}

func getTimestampLength(line string) int {
// 29th character will be either '+' for +00:00 timestamp,
// or 'Z' for UTC timestamp (without 00:00 section).
if len(line) >= 29 && line[29] == '+' {
return len(time.RFC3339Nano)
}
return LogTimestampLength
}

func watchTestWorkflowLogs(id string, signature []testkube.TestWorkflowSignature, client apiclientv1.Client) (*testkube.TestWorkflowResult, error) {
ui.Info("Getting logs from test workflow job", id)

Expand All @@ -217,7 +226,7 @@ func watchTestWorkflowLogs(id string, signature []testkube.TestWorkflowSignature
// Strip timestamp + space for all new lines in the log
for len(l.Log) > 0 {
if isLineBeginning {
l.Log = l.Log[LogTimestampLength+1:]
l.Log = l.Log[getTimestampLength(l.Log)+1:]
isLineBeginning = false
}
newLineIndex := strings.Index(l.Log, "\n")
Expand Down

0 comments on commit cefbfa2

Please sign in to comment.