Skip to content

Conversation

lzap
Copy link
Contributor

@lzap lzap commented Sep 26, 2025

Because I have modified my PATH to include a custom osbuild binary, it
is useful to see which osbuild version is being used by image-builder.
After this change, the output looks like this:

$ go run ./cmd/image-builder --version
image-builder:
  version: unknown
  commit: unknown
  dependencies:
    images: v0.197.0
    osbuild: osbuild 162

A very tiny refactoring to improve readability of the function.

This commit refactors the readVersionInfo function to improve
code readability and maintainability.
Because I have modified my PATH to include a custom osbuild binary, it
is useful to see which osbuild version is being used by image-builder.
After this change, the output looks like this:

$ go run ./cmd/image-builder --version
image-builder:
  version: unknown
  commit: unknown
  dependencies:
    images: v0.197.0
    osbuild: osbuild 162
@lzap lzap requested a review from a team as a code owner September 26, 2025 14:08
@lzap lzap requested review from mvo5, achilleas-k and thozza and removed request for a team September 26, 2025 14:08
Copy link
Collaborator

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

I like it! One small questin inline and I wonder if we could add some smoke test to test_container_version_smoke for this? (just a single line)

}

func readVersionFromBinary() *versionDescription {
var osbuildCmd = "osbuild"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Silly question, why is this a var? Given that its not mocked or anything we could as well just hardcode it in line 56?

Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

Except for my inline comment, this LGTM.

Comment on lines +56 to +62
cmd := exec.Command(osbuildCmd, "--version")
var out bytes.Buffer
cmd.Stdout = &out
if err := cmd.Run(); err != nil {
vd.ImageBuilder.Dependencies.OSBuild = fmt.Sprintf("error: %s", err)
}
vd.ImageBuilder.Dependencies.OSBuild = strings.TrimSpace(out.String())
Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants