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

src: Add on prem blueprints import support (HMS-4683) #2519

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

avitova
Copy link
Contributor

@avitova avitova commented Oct 15, 2024

This pull request relates to #4683.
We want to support import on prem blueprints in our import feature. This enables importing toml blueprints that get automatically detected, and parsed.
A lot of fields we need to ignore, a lot of fields from our blueprints are not in the on-prem blueprint structure. This is our first attempt to allow on-prem blueprint, and it will get us more information whether users would use it or not. We also need to add a method to measure the usage of this feature. This is not here yet, and I would like to do it as a follow up, as it can raise discussions, and we do not want to block this feature on it.

We will bring a different solution, so eventually, we will get rid of this mapper. But the other solution that should be more "bulletproof" will take time, in the meantime we can use this one. :)

I know, that on-prem blueprints can also come in json, this will be quite easy to do, we will adjust the UI a bit for that, so that users would be able to import even on-prem json.

Feel free to ask any questions, and find bugs!

Copy link
Collaborator

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

What's the status here? should I test it out?

const isToml = filename.endsWith('.toml');
const isJson = filename.endsWith('.json');
if (isToml) {
var toml = require('toml');
Copy link
Collaborator

Choose a reason for hiding this comment

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

ugh... I'd rather import it globaly... (not sure why, but I think combining require and import is a no-no in JS)

@avitova avitova marked this pull request as ready for review November 5, 2024 08:42
@avitova avitova force-pushed the on-prem-bp branch 2 times, most recently from 5d1300a to f02df31 Compare November 5, 2024 08:45
@@ -77,7 +77,7 @@ const PackageRecommendations = () => {
},
});

if (response && response.data && response.data.packages.length > 0) {
if (response && response.data && response.data.packages && response.data.packages.length > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not related, but I was getting some errors, and I believe that we need to check for this too.

@avitova avitova force-pushed the on-prem-bp branch 3 times, most recently from cb0b3ad to d4a5800 Compare November 5, 2024 11:19
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 88.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 83.96%. Comparing base (7c99415) to head (4c804ac).

Files with missing lines Patch % Lines
...ueprints/helpers/onPremToHostedBlueprintMapper.tsx 80.00% 12 Missing ⚠️
src/Components/Blueprints/ImportBlueprintModal.tsx 94.91% 3 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2519      +/-   ##
==========================================
+ Coverage   83.93%   83.96%   +0.03%     
==========================================
  Files         162      163       +1     
  Lines       17950    18034      +84     
  Branches     1796     1814      +18     
==========================================
+ Hits        15066    15143      +77     
- Misses       2862     2869       +7     
  Partials       22       22              
Files with missing lines Coverage Δ
...geWizard/steps/Packages/PackageRecommendations.tsx 96.26% <100.00%> (+0.08%) ⬆️
src/Components/Blueprints/ImportBlueprintModal.tsx 90.18% <94.91%> (+4.76%) ⬆️
...ueprints/helpers/onPremToHostedBlueprintMapper.tsx 80.00% <80.00%> (ø)

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 7c99415...4c804ac. Read the comment docs.

@avitova
Copy link
Contributor Author

avitova commented Nov 5, 2024

/retest

1 similar comment
@avitova
Copy link
Contributor Author

avitova commented Nov 6, 2024

/retest

Copy link
Collaborator

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Just few ideas inline :)

@@ -0,0 +1,155 @@
import {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capital first letter is usually a React component, this is just a helper function, I'd name it with lower case first letter. possibly even place it in helpers/ sub folder.

blueprintFromFile,
[]
);
setImportedBlueprint(importBlueprintState);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we show some warning, that this is a best effort import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know how you like that one I came up with. We can adjust it. :)

dispatch(
addNotification({
variant: 'warning',
title: 'No blueprint was build',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is just a copy, but the warning is probably incorrect, we should say something like "File is not a valid blueprint"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this was according to mocks, but I am happy to change it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mocks are not always 100% tought through, this case I feel like it could have been copy pasted from other mock.
What I'm interested in is whether my comment makes sense to you, or if I just don't get why this might be actually correct message :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I feel like the notification might make sense. We already inform in the warning at the bottom of the text field that the format is not compatible with our blueprints. So this one just made sense to me, so that users know that we did not create any blueprint just from the fact that they uploaded the file. We can discuss this with Kelsea, but I think this is a minor thing:)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, totaly minor, if you feel this is good, lets keep it :)

@ezr-ondrej ezr-ondrej changed the title src: Add on prem blueprints import support src: Add on prem blueprints import support (HMS-4683) Nov 11, 2024
@avitova
Copy link
Contributor Author

avitova commented Nov 12, 2024

/retest

1 similar comment
@avitova
Copy link
Contributor Author

avitova commented Nov 12, 2024

/retest

@avitova
Copy link
Contributor Author

avitova commented Nov 12, 2024

Okay, I addressed all the comments, thanks for the review!
/retest

Copy link
Collaborator

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

I'm good here, but merging with the current CI state might be difficult xD

FTR: I've tested this with toml and seems fine, just one nit :)

const [importedBlueprint, setImportedBlueprint] =
React.useState<wizardState>();
const [isInvalidFormat, setIsInvalidFormat] = React.useState(false);
const [filename, setFilename] = React.useState('');
const [isLoading, setIsLoading] = React.useState(false);
const [isRejected, setIsRejected] = React.useState(false);
const [isOnPrem, setIsOnPrem] = React.useState(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to reset this flag in onClear handler.

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