Skip to content

Commit c3bd972

Browse files
committed
logs streaming from dgctl
1 parent 3cb98dc commit c3bd972

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

dgctl/cmd/exec.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func cleanupDiggerOutput(output string) string {
188188
// removes output of terraform -version command that terraform-exec executes on every run
189189
i := strings.Index(output, startingDelimeter)
190190
if i != -1 {
191-
startPos = i
191+
startPos = i + len(startingDelimeter)
192192
}
193193

194194
e := strings.Index(output, endingDelimiter)
@@ -318,7 +318,6 @@ var execCmd = &cobra.Command{
318318
var jobId *int64
319319
for {
320320
runId, jobId, logsUrl, err = GetWorkflowIdAndUrlFromDiggerJobId(client, repoOwner, repoName, spec.JobId)
321-
log.Printf("=============")
322321
if err == nil {
323322
break
324323
}
@@ -331,9 +330,9 @@ var execCmd = &cobra.Command{
331330
for {
332331
j, _, err := client.Actions.GetWorkflowJobByID(context.Background(), repoOwner, repoName, *jobId)
333332
if err != nil {
334-
log.Printf("GetWorkflowJobByID error: %v", err)
333+
log.Printf("GetWorkflowJobByID error: %v please view the logs in the job directly", err)
334+
os.Exit(1)
335335
}
336-
log.Printf("job status: %v", *j.Status)
337336
if *j.Status == "completed" {
338337
break
339338
}
@@ -342,15 +341,15 @@ var execCmd = &cobra.Command{
342341

343342
logs, _, err := client.Actions.GetWorkflowJobLogs(context.Background(), repoOwner, repoName, *jobId, 1)
344343

345-
log.Printf("stereaming logs from: %v || %v", logs, err)
344+
log.Printf("streaming logs from remote job:")
346345
logsContent, err := GetUrlContents(logs.String())
347346

348347
if err != nil {
349348
log.Printf("error while fetching logs: %v", err)
350349
os.Exit(1)
351350
}
352-
353-
log.Printf("logsContent is: %v", logsContent)
351+
cleanedLogs := cleanupDiggerOutput(logsContent)
352+
log.Printf("logsContent is: %v", cleanedLogs)
354353
},
355354
}
356355

0 commit comments

Comments
 (0)