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

feat: Add guardrails for parsing OS version #619

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

Conversation

h4l0gen
Copy link

@h4l0gen h4l0gen commented May 11, 2024

adding guardrails for parsing OS version as per discussion

Closes #438

Signed-off-by: h4l0gen <ks3913688@gmail.com>
Copy link

codecov bot commented May 11, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 33.92%. Comparing base (2602d59) to head (9383ae4).
Report is 63 commits behind head on main.

Files Patch % Lines
pkg/patch/patch.go 76.47% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #619      +/-   ##
==========================================
+ Coverage   32.51%   33.92%   +1.41%     
==========================================
  Files          17       18       +1     
  Lines        1621     1518     -103     
==========================================
- Hits          527      515      -12     
+ Misses       1062      970      -92     
- Partials       32       33       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@h4l0gen
Copy link
Author

h4l0gen commented May 11, 2024

Hey sorry, as per this we need to run golangci-lint too, i will run it and make required changes if any.

Signed-off-by: Kapil Sharma <ks3913688@gmail.com>
@h4l0gen h4l0gen changed the title adding guardrails for parsing OS version feat: adding guardrails for parsing OS version May 11, 2024
@h4l0gen h4l0gen changed the title feat: adding guardrails for parsing OS version feat: Add guardrails for parsing OS version May 11, 2024
osVersion := strings.Join(versionParts[:2], ".")
return "ubuntu", osVersion, nil
}
return "", "", fmt.Errorf("invalid Ubuntu version format: %s", osData["VERSION_ID"])
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add this check in getAptImageName if the os.Type is Debian instead?

@@ -301,34 +301,40 @@ func patchWithContext(ctx context.Context, ch chan error, image, reportFile, pat
return eg.Wait()
}

func getOSType(ctx context.Context, osreleaseBytes []byte) (string, error) {
func getOSType(ctx context.Context, osreleaseBytes []byte) (string, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

since a lot of the work is repeated with getOSVersion, maybe we can combine the two functions into one and remove getOSVersion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

[REQ] add guardrails for parsing OS version
2 participants