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

Mapping product names #1091

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

Mapping product names #1091

wants to merge 7 commits into from

Conversation

dagarwal-mitre
Copy link
Collaborator

@dagarwal-mitre dagarwal-mitre commented May 7, 2024

🗣 Description

Added product names to the table with with tenant licensing information
Closes #993

💭 Motivation and context

This helps users understand which licenses they have

🧪 Testing

Tested with the different tenants

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • PR targets the correct parent branch (e.g., main or release-name) for merge.
  • Changes are limited to a single goal - eschew scope creep!
  • Changes are sized such that they do not touch excessive number of files.
  • All future TODOs are captured in issues, which are referenced in code comments.
  • These code changes follow the ScubaGear content style guide.
  • Related issues these changes resolve are linked preferably via closing keywords.
  • All relevant type-of-change labels added.
  • All relevant project fields are set.
  • All relevant repo and/or project documentation updated to reflect these changes.
  • Unit tests added/updated to cover PowerShell and Rego changes.
  • Functional tests added/updated to cover PowerShell and Rego changes.
  • All relevant functional tests passed.
  • All automated checks (e.g., linting, static analysis, unit/smoke tests) passed.

✅ Pre-merge checklist

  • PR passed smoke test check.

  • Feature branch has been rebased against changes from parent branch, as needed

    Use Rebase branch button below or use this reference to rebase from the command line.

  • Resolved all merge conflicts on branch

  • Notified merge coordinator that PR is ready for merge via comment mention

✅ Post-merge checklist

  • Feature branch deleted after merge to clean up repository.
  • Verified that all checks pass on parent branch (e.g., main or release-name) after merge.

@dagarwal-mitre dagarwal-mitre self-assigned this May 7, 2024
@dagarwal-mitre
Copy link
Collaborator Author

I am unsure where to put the product names csv file, currently it is in the ScubaGear folder, if it needs to be moved to a different location please reply to this comment.

@dagarwal-mitre dagarwal-mitre requested review from gdasher and removed request for tkol2022 May 7, 2024 17:23
$SkuID = $_.SkuId
# Find the corresponding product name
$matchingRow = $csvData | Where-Object { $_.GUID -eq $SkuID } | Select-Object -First 1
$productName = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the case where we fail to find a match (e.g. a new SKU), lets use some language here instead of just blank. "Unknown SKU Name"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

$matchingRow = $csvData | Where-Object { $_.GUID -eq $SkuID } | Select-Object -First 1
$productName = ""
if ($matchingRow) {
$productName = $matchingRow.'Product_Display_Name'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Forgive my powershell ignorance, but does this properly select from the matching row object?

Would it be better to use camelCase headers in the CSV or is the CSF just a direct import from Microsoft's website?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line will select from the matching row based on the SKU ID, but since it is using a direct import from microsoft's website I didn't do camel casing, in order to make it easier for future updates to directly import the csv rather than making changes to it. Currently the CSV file had a few columns removed which were unused, since the file original size was nearly 1MB and now it is closer to 450 kb. The goal was to make sure speed wasn't impacted, so I made the table size smaller.

[pscustomobject]@{
"Product Name" = $productName
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of the product names are quite long. Can you take a screenshot to show how the table looks now so we can see if it will look ok in practice, at least for commonly used SKUs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Screenshot 2024-05-07 at 2 13 03 PM This is currently how the table looks, and I believe of the 3 tenants, this has the longest product name

Copy link
Collaborator

Choose a reason for hiding this comment

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

The longest product name in the current file is 103 characters, the one displayed is 68 characters with padding on either side given the static table width. Doing some quick HTML editing to drop that in still shows it fitting on one line.

Screenshot 2024-05-20 at 9 23 49 AM

@@ -210,8 +210,22 @@ function New-Report {

# Handle AAD-specific reporting
if ($BaselineName -eq "aad") {

# Load the CSV file
$csvData = Import-Csv -Path "Product Names for Licensing.csv"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we update the unit test for this case (e.g. by mocking out Import-Csv to avoid loading the file)? I think we added a decent test for this table IIRC.

@schrolla schrolla added this to the Halibut milestone May 16, 2024
@tkol2022
Copy link
Collaborator

I am guessing that Microsoft updates the licensing plan data regularly. What is the plan to keep this information up to date in ScubaGear? Right now the new code is referencing a static CSV file.

image

@gdasher
Copy link
Collaborator

gdasher commented May 17, 2024

I am guessing that Microsoft updates the licensing plan data regularly. What is the plan to keep this information up to date in ScubaGear? Right now the new code is referencing a static CSV file.

image

Given the direct copy is used, we can likely generalize David Bui's github action to check for updates to this file as well Probably just be comparing hashes for changes and updating if so, for example?

Suggest we file an issue for that after this is committed.

Separately, please ping when the test cases have been updated and I will re-review for approval.

@schrolla
Copy link
Collaborator

I am guessing that Microsoft updates the licensing plan data regularly. What is the plan to keep this information up to date in ScubaGear? Right now the new code is referencing a static CSV file.
image

Given the direct copy is used, we can likely generalize David Bui's github action to check for updates to this file as well Probably just be comparing hashes for changes and updating if so, for example?

Suggest we file an issue for that after this is committed.

Separately, please ping when the test cases have been updated and I will re-review for approval.

Github automation is a good idea. My other thought was to add a new cmdlet to the tool that would reach out and grab the new version of the file directly and incorporate it into ScubaGear. That way, users could update the file directly outside the release cycle when needed if they had the necessary connectivity to do so. So I'd say, how about both as TODOs added beyond this issue?

@schrolla schrolla added the enhancement This issue or pull request will add new or improve existing functionality label May 20, 2024
@dagarwal-mitre
Copy link
Collaborator Author

I am guessing that Microsoft updates the licensing plan data regularly. What is the plan to keep this information up to date in ScubaGear? Right now the new code is referencing a static CSV file.
image

Given the direct copy is used, we can likely generalize David Bui's github action to check for updates to this file as well Probably just be comparing hashes for changes and updating if so, for example?
Suggest we file an issue for that after this is committed.
Separately, please ping when the test cases have been updated and I will re-review for approval.

Github automation is a good idea. My other thought was to add a new cmdlet to the tool that would reach out and grab the new version of the file directly and incorporate it into ScubaGear. That way, users could update the file directly outside the release cycle when needed if they had the necessary connectivity to do so. So I'd say, how about both as TODOs added beyond this issue?

2 comments/questions about this.

  1. Currently the CSV File is not a direct copy of the CSV file from Microsoft, because the original file from Microsoft was about 1 MB and in an effort to reduce the size, I had removed the last few columns which we didn't use from the CSV file, but if size is not a concern, we can use a direct copy instead.
  2. If we use a Github automation, couldn't we set it up so that it runs nightly, similar to the Nightly Testing that is run through a Github automation so there is always the newest version of the file and it wouldn't be tied to the release cycle.

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

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

See notes about recommendations for CSV file suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file should not be present in the top-level folder. Doing so means it would not be distributed in the PowerShell gallery package since it doesn't exist in the actual module. Recommend moving the file into the PowerShell/ScubaGear/Modules/CreateReport folder since that is the scope in which it is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend renaming the file to remove all spaces from the filename and renaming to something more specific such as "MicrosoftLicenseToProductNameMappings.csv". This helps users better understand what the file is and why it exists and removing spaces makes it less likely there will be an error processing the file in code in case someone forgets to enclose the space filled name in quotes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

The file has headers for 3 fields, but all fields include an unnamed and empty fourth field (shown by the double commas on the end of each row). Is there a reason for the fourth field? If so, it should have a name in the header. If not, the extra comma at the end of every line should be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extra commas have been removed

[pscustomobject]@{
"Product Name" = $productName
Copy link
Collaborator

Choose a reason for hiding this comment

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

The longest product name in the current file is 103 characters, the one displayed is 68 characters with padding on either side given the static table width. Doing some quick HTML editing to drop that in still shows it fitting on one line.

Screenshot 2024-05-20 at 9 23 49 AM

@gdasher
Copy link
Collaborator

gdasher commented May 22, 2024

I am guessing that Microsoft updates the licensing plan data regularly. What is the plan to keep this information up to date in ScubaGear? Right now the new code is referencing a static CSV file.
image

Given the direct copy is used, we can likely generalize David Bui's github action to check for updates to this file as well Probably just be comparing hashes for changes and updating if so, for example?
Suggest we file an issue for that after this is committed.
Separately, please ping when the test cases have been updated and I will re-review for approval.

Github automation is a good idea. My other thought was to add a new cmdlet to the tool that would reach out and grab the new version of the file directly and incorporate it into ScubaGear. That way, users could update the file directly outside the release cycle when needed if they had the necessary connectivity to do so. So I'd say, how about both as TODOs added beyond this issue?

2 comments/questions about this.

  1. Currently the CSV File is not a direct copy of the CSV file from Microsoft, because the original file from Microsoft was about 1 MB and in an effort to reduce the size, I had removed the last few columns which we didn't use from the CSV file, but if size is not a concern, we can use a direct copy instead.
  2. If we use a Github automation, couldn't we set it up so that it runs nightly, similar to the Nightly Testing that is run through a Github automation so there is always the newest version of the file and it wouldn't be tied to the release cycle.

Ok, makes sense. I think its fine to drop columns we don't need so long as we do it in a standardized way (e.g. ImportFrom-Csv | Select-Object -Blah -Blah | ExportTo-Csv or the like in the automation script) and not a manual process.

Yes, if we do automation we can run it on a cron schedule and just update main periodically. That's how I would think to do it anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue or pull request will add new or improve existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mapping SKU names to Product Name
4 participants