Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newline to each stdout line from ansible output #421

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/common/ansible/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func GetStdout(events []messageModel.PlaybookRunResponseMessageYamlEventsElem, h

if event.Stdout != nil {
result += *event.Stdout
if event.EndLine > event.StartLine {
result += "\n"
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/common/ansible/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ var _ = Describe("Ansible", func() {
It("determines stdout from a successful run", func() {
events := loadFile("./test-events1.jsonl")
stdout := GetStdout(events, nil)
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [ping] ********************************************************************\x1b[0;32mok: [localhost]\x1b[0m\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;32mlocalhost\x1b[0m : \x1b[0;32mok=1 \x1b[0m changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \r\n"))
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [ping] ********************************************************************\n\x1b[0;32mok: [localhost]\x1b[0m\n\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;32mlocalhost\x1b[0m : \x1b[0;32mok=1 \x1b[0m changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \r\n\n"))
})

It("determines stdout from a failed run", func() {
events := loadFile("./test-events2.jsonl")
stdout := GetStdout(events, nil)
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [fail] ********************************************************************\x1b[0;31mfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Always fail\"}\x1b[0m\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;31mlocalhost\x1b[0m : ok=0 changed=0 unreachable=0 \x1b[0;31mfailed=1 \x1b[0m skipped=0 rescued=0 ignored=0 \r\n"))
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [fail] ********************************************************************\n\x1b[0;31mfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Always fail\"}\x1b[0m\n\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;31mlocalhost\x1b[0m : ok=0 changed=0 unreachable=0 \x1b[0;31mfailed=1 \x1b[0m skipped=0 rescued=0 ignored=0 \r\n\n"))
})

It("determines stdout from an incomplete run", func() {
events := loadFile("./test-events3.jsonl")
stdout := GetStdout(events, nil)
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [ping] ********************************************************************"))
Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [ping] ********************************************************************\n"))
})

It("determines stdout from an incomplete run (2)", func() {
Expand Down
Loading