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: simplify code by removing osbuild.Mounts type #373

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Jan 16, 2024

A quick drive-by commit for your consideration. I noticed while writing a test for the bootupd stage that the osbuild.Mounts type is not really helping me and hence wonder if we can do away with it. I did a grep and it seems the type is also not used outside images. Feel free to close this is you disagree or are attached to the type but to me the code feels easier to work with without it (and if you agree with this change I would like to see if osbuild.Device might also benefit from this).


The osbuild.Mounts type is just an alias to []osbuild.Mount and it feels like it does not add clarity. From the type it's not clear if it's a slice or a map (like osbuild.Devices). While it is nice to abstract things away one needs to know it anyway when constructing the type so this commit removes the type and just exposes/uses []osbuild.Mount directly.

Another benefit of this is that the pointers used are now clearer (IMHO) - i.e. []Mount is a slice so no need to indirect it further via *Mounts in the function signatures.

Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

I agree with this.

There was an idea that the abstraction might be expanded to include some useful methods that work on the Mounts type/alias. Another idea was that it might become an interface where different stages can add their own implementations with restrictions.

None of that happened so let's clean it up. It's a low impact change and it removes ambiguities so I'm all for it.

@mvo5 mvo5 marked this pull request as ready for review January 16, 2024 12:16
@achilleas-k achilleas-k added this pull request to the merge queue Jan 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 16, 2024
@achilleas-k
Copy link
Member

The rebase on the merge queue seems to be causing issues. Doing a UI rebase to see what's up.

@achilleas-k
Copy link
Member

Ah, of course. The bootupd stage was merged and this PR merges cleanly but not correctly.

Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Needs post-rebase fixes.

The `osbuild.Mounts` type is just an alias to `[]osbuild.Mount`
and it feels like it does not add clarity. From the type it's
not clear if it's a slice or a map (like `osbuild.Devices`). While
it is nice to abstract things away one needs to know it anyway when
constructing the type so this commit removes the type and just
exposes/uses `[]osbuild.Mount` directly.

Another benefit of this is that the pointers used are now clearer
(IMHO) - i.e. `[]Mount` is a slice so no need to indirect it further
via `*Mounts` in the function signatures.
@achilleas-k achilleas-k added this pull request to the merge queue Jan 17, 2024
Merged via the queue into osbuild:main with commit b81b603 Jan 17, 2024
10 checks passed
@mvo5 mvo5 deleted the simplify-osbuild-mounts branch January 17, 2024 13:33
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.

2 participants