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

osbuild: do not assume osbuild stage messages have a final \n #1201

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 9 additions & 6 deletions pkg/osbuild/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import (
// and based on what we learn here we may consider tweaking
// the osbuild progress
type Status struct {
// Trace contains a single log line, usually very low-level or
// stage output but useful for e.g. bug reporting. Should in
// general not be displayed to the user but the concatenation
// of all "trace" lines should give the same information as
// running osbuild on a terminal
// Trace contains log lines, usually very low-level or stage
// output but useful for e.g. bug reporting. Should in general
// not be displayed to the user but the concatenation of all
// "trace" lines should give the same information as running
// osbuild on a terminal. It may contain multiple lines and
// may not end with a \n
Trace string

// Message contains a high level user-visible message about
Expand Down Expand Up @@ -106,7 +107,9 @@ func (sr *StatusScanner) Status() (*Status, error) {
if context.Origin == "osbuild.monitor" {
msg = strings.TrimSpace(status.Message)
} else {
trace = strings.TrimSpace(status.Message)
// arbitrary osbuild messages can be very long and
// may not end with a \n so do not assume this
trace = status.Message
}

st := &Status{
Expand Down
4 changes: 2 additions & 2 deletions pkg/osbuild/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestScannerSimple(t *testing.T) {
st, err := scanner.Status()
assert.NoError(t, err)
assert.Equal(t, &osbuild.Status{
Trace: "source/org.osbuild.curl (org.osbuild.curl): Downloaded https://rpmrepo.osbuild.org/v2/mirror/public/f39/f39-x86_64-fedora-20231109/Packages/k/kpartx-0.9.5-2.fc39.x86_64.rpm",
Trace: "source/org.osbuild.curl (org.osbuild.curl): Downloaded https://rpmrepo.osbuild.org/v2/mirror/public/f39/f39-x86_64-fedora-20231109/Packages/k/kpartx-0.9.5-2.fc39.x86_64.rpm\n",
Progress: &osbuild.Progress{
Done: 0,
Total: 4,
Expand All @@ -39,7 +39,7 @@ func TestScannerSimple(t *testing.T) {
st, err = scanner.Status()
assert.NoError(t, err)
assert.Equal(t, &osbuild.Status{
Trace: "source/org.osbuild.curl (org.osbuild.curl): Downloaded https://rpmrepo.osbuild.org/v2/mirror/public/f39/f39-x86_64-fedora-20231109/Packages/l/langpacks-fonts-en-4.0-9.fc39.noarch.rpm",
Trace: "source/org.osbuild.curl (org.osbuild.curl): Downloaded https://rpmrepo.osbuild.org/v2/mirror/public/f39/f39-x86_64-fedora-20231109/Packages/l/langpacks-fonts-en-4.0-9.fc39.noarch.rpm\n",
Progress: &osbuild.Progress{
Done: 0,
Total: 4,
Expand Down
Loading