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

added handling for adding rpms to an image as well as the relevant tests #28

Merged
merged 11 commits into from
Nov 2, 2023

Conversation

dbw7
Copy link
Contributor

@dbw7 dbw7 commented Oct 30, 2023

Currently working on getting elemental registration through combustion working in eib. So far, I've been able to get it work with some few hacks (which are omitted from here, along with the Elemental specific stuff as it is not complete). To get there though, I needed to be able to add the RPMs to the image, so I built the handling for that as well as the tests. I’m not sure if this is how you guys would have gone about it, so I’ve made this PR a draft for now

@dbw7 dbw7 requested review from atanasdinov and jdob October 30, 2023 04:29
@alknopfler
Copy link
Contributor

alknopfler commented Oct 31, 2023

Question:

@@ -85,10 +93,16 @@ func (b *Builder) prepareBuildDir() error {
b.eibBuildDir = b.buildConfig.BuildDir
}
b.combustionDir = filepath.Join(b.eibBuildDir, "combustion")
b.rpmBuildDir = filepath.Join(b.combustionDir, "rpms")
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

My gut reaction was that everything would be in a flat combustion directory. That might get a bit messy for debugging large builds, but I think we should start with that model and only make it more complex if we find a need to. So +1 to Alberto's comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good to me, my initial thinking was just maintaining the organization from the config dir which I commented on in another reply, but I'll make this change

@@ -23,6 +23,9 @@ type Builder struct {
eibBuildDir string
combustionDir string
combustionScripts []string
rpmBuildDir string
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use the same directory than combustion dir

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

pkg/build/rpm.go Outdated
func (b *Builder) getRPMFileNames() error {
b.rpmSourceDir = filepath.Join(b.buildConfig.ImageConfigDir, "rpms")

rpms, err := os.ReadDir(b.rpmSourceDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this one, "rpmSourceDir" refers to the user-created configuration directory. In here, I think it makes it significantly easier for us when the user knows to make an RPM dir and put all of their RPMs in there to be copied over to the image, though I'm interested to see other views

@dbw7 dbw7 marked this pull request as ready for review October 31, 2023 17:36
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm_test.go Show resolved Hide resolved
pkg/build/build.go Outdated Show resolved Hide resolved
@dbw7
Copy link
Contributor Author

dbw7 commented Nov 1, 2023

So a few things, first, I added a test for the situation where the rpm dir is empty, as well as handling for that, let me know how you guys feel about that. Also, because I decided to keep the rpm dir in "testData" using .gitkeep I had to add handling for that in getRPMFileNames() which I really dislike so that might not survive this pull request.

As for the other tests, I'm not sure if there was a more graceful way to go about what I did, so let me know if what I did was fine or if it's not convential. The main reason I didn't use defer here was to ensure the order of events

pkg/build/build.go Outdated Show resolved Hide resolved
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm.go Outdated Show resolved Hide resolved
pkg/build/rpm_test.go Outdated Show resolved Hide resolved
dbw7 added 5 commits November 1, 2023 14:45
copyFile is no longer attached to the build struct. getRPMFileNames now checks for the .rpm extension, to remove the previously unnecessary (and frankly ugly) logic. I also added more abstraction for readability. Finally, cleaned up the tests based on feedback and altered them to match changes.
@atanasdinov atanasdinov merged commit 3bc45ca into suse-edge:main Nov 2, 2023
2 checks passed
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.

4 participants