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

On-prem: read blueprints from disk (COMPOSER-2413) #2603

Merged
merged 7 commits into from
Dec 21, 2024

Conversation

kingsleyzissou
Copy link
Collaborator

We can use the cockpit files api to read in blueprints from disk.

This PR adds commits to bring in the required dependencies, some convenience scripts and an initial commit using an RTK query function to read blueprints from file and pull the details into the store.

@lucasgarfield
Copy link
Collaborator

I can't wait to see this in action! I'm trying to get it running locally but can't get anything to appear in Cockpit. I noticed quite a few changes to the makefile... what should I do to get this to run?

@kingsleyzissou
Copy link
Collaborator Author

I can't wait to see this in action! I'm trying to get it running locally but can't get anything to appear in Cockpit. I noticed quite a few changes to the makefile... what should I do to get this to run?

Oh right, so we need to pull in some of the cockpit dependencies. Try make cockpit/devel, hopefully that does the trick. I am copying this all into a VM and then running that.

@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 5 times, most recently from 2e17a88 to dadbaec Compare November 28, 2024 13:13
@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 2 times, most recently from 6983959 to 85f4c58 Compare December 3, 2024 10:03
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 19.27711% with 67 lines in your changes missing coverage. Please review.

Project coverage is 85.04%. Comparing base (d0f2317) to head (df9970c).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/store/cockpitApi.ts 8.57% 32 Missing ⚠️
src/test/mocks/cockpit/index.ts 21.05% 15 Missing ⚠️
fec.config.js 0.00% 10 Missing ⚠️
src/test/mocks/cockpit/fsinfo.ts 9.09% 10 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2603      +/-   ##
==========================================
- Coverage   85.28%   85.04%   -0.25%     
==========================================
  Files         180      183       +3     
  Lines       20519    20588      +69     
  Branches     2002     2002              
==========================================
+ Hits        17500    17509       +9     
- Misses       2997     3057      +60     
  Partials       22       22              
Files with missing lines Coverage Δ
src/constants.ts 100.00% <100.00%> (ø)
src/store/emptyCockpitApi.ts 100.00% <100.00%> (ø)
fec.config.js 0.00% <0.00%> (ø)
src/test/mocks/cockpit/fsinfo.ts 9.09% <9.09%> (ø)
src/test/mocks/cockpit/index.ts 21.05% <21.05%> (ø)
src/store/cockpitApi.ts 29.31% <8.57%> (-29.03%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0f2317...df9970c. Read the comment docs.

@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 2 times, most recently from c73c587 to 8dd626a Compare December 4, 2024 15:43
@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 7 times, most recently from 3640100 to 71de59a Compare December 6, 2024 14:13
@kingsleyzissou
Copy link
Collaborator Author

I had to change some typescript config which made this PR a lot bigger. I think if we want to go ahead with this, it would probably be better to split the typescript changes into a separate PR.

@lucasgarfield lucasgarfield changed the title On-prem: read blueprints from disk On-prem: read blueprints from disk (COMPOSER-2413) Dec 6, 2024
@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 7 times, most recently from 76e95e9 to d831f5b Compare December 18, 2024 21:44
@kingsleyzissou kingsleyzissou marked this pull request as ready for review December 18, 2024 21:45
@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 4 times, most recently from 7ef321a to 4b9333a Compare December 18, 2024 21:51
@kingsleyzissou kingsleyzissou force-pushed the cockpit_fileapi branch 2 times, most recently from 7f1ac45 to 6e579ed Compare December 19, 2024 15:27
Copy link
Collaborator

@lucasgarfield lucasgarfield left a comment

Choose a reason for hiding this comment

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

Most excellent!

@kingsleyzissou
Copy link
Collaborator Author

/retest

This is just to follow the convention already used in the project.
The on-prem version of this repo depends on the `cockpit` project. Some
of the files from the `cockpit` repo are needed to build and run this
project. These files are saved into the `pkg/lib` directory, this commit
adds some convenience scripts to the Makefile to do this.
Limit the cockpit workaround to only delete the `cockpit` directory at
the root of the project. Otherwise this command would delete some of the
mocks that we need to compile the project.
Add some stub functions for the cockpit library, these will be needed
for tests to pass and for stubbing out the library for the service.
It was necessary to do a bit of plumbing to get typescript, webpack &
vitest all happy. To do this we had had to create a separate tsconfig
for the on-prem version and the service frontend.

We override the module resolution for both config files. For on-prem we
check modules in `pkg/lib` and for the service we resolve the modules to
stub functions of the `cockpit` & `cockpit/fsinfo` modules. This was so
typescript and webpack would not complain.

For on-prem we had to intruct webpack to resolve modules from both
`node_modules` and `pkg/lib`. While for the service we set the
resulotion for the two modules to false, which means they won't get
bundled with the service.

Lastly, we needed to set some aliases in the vitest config so that
vitest could resolve the `cockpit` & `cockpit/fsinfo` modules.

Using the cjs `require` keyword to import cockpit would have worked to
make typescript and webpack compile since these imports are not
statically analysed like the `import` keyword is. However, this approach
broke the tests as `require` imports are not supported in vitest.
Add an initial commit to scan a preset directory for user blueprint
files. This makes use of the cockpit files api.
Use the blueprint existing blueprint converter to convert
the on-prem blueprint to the hosted blueprint
@lucasgarfield lucasgarfield merged commit 47156c4 into osbuild:main Dec 21, 2024
7 checks passed
@kingsleyzissou kingsleyzissou deleted the cockpit_fileapi branch December 23, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants