Skip to content

storage: use -json parameter for system_profiler SPSoftwareDataType#993

Open
marie wants to merge 1 commit into
podman-container-tools:mainfrom
marie:use-json-sys-profiler
Open

storage: use -json parameter for system_profiler SPSoftwareDataType#993
marie wants to merge 1 commit into
podman-container-tools:mainfrom
marie:use-json-sys-profiler

Conversation

@marie

@marie marie commented Jul 17, 2026

Copy link
Copy Markdown

Update the system_profiler SPSoftwareDataType command to use the -json flag. This allows the system to parse OS information without the external go-shellwords library.

Fixes: #983

@github-actions github-actions Bot added the storage Related to "storage" package label Jul 17, 2026

@mtrmac mtrmac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

func getRelease() (string, error) {
cmd := exec.Command("system_profiler", "SPSoftwareDataType")
osName, err := cmd.Output()
cmd := exec.Command("system_profiler", "SPSoftwareDataType", "-json")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The man page documents [-json] dataType1 ... dataTypeN; I agree putting -json at the end currently works, but given the BSD tradition it might be a tiny bit safer to put it first.

}
var result struct {
SPSoftwareDataType []struct {
KernelVersion string `json:"kernel_version"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given encoding/json/v2.RejectUnknownMembers landing in Go 1.27, it might help future maintainers to add a comment that this contains other fields which we ignore, to ensure RejectUnknownMembers is not used in the future.

Removes go-shellwords dependency from kernel_darwin.go

Fixes: podman-container-tools#983

Signed-off-by: Maria Glushenok <glushenokm@gmail.com>
@marie
marie force-pushed the use-json-sys-profiler branch from d670c0b to 9bdc786 Compare July 21, 2026 16:26
@marie

marie commented Jul 21, 2026

Copy link
Copy Markdown
Author

@mtrmac I've fixed the problems you mentioned. Could you review it one more time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage Related to "storage" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid use of github.com/mattn/go-shellwords in storage/pkg/parsers/kernel/kernel_darwin.go

2 participants