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

fix(UserContainer): Fix a small bug in ImagePullPolicy mapper and add tests for error cases #963

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

KengoA
Copy link
Contributor

@KengoA KengoA commented Feb 16, 2024

Pull Request Checklist

Description of PR
When checking for string values of image_pull_policy in the UserContainer class, the current implementation was adding redundant items in the policy_mapper dict as it was confusing the name and value properties.

This PR simplifies this logic while covering the same use cases, and adds tests for normal and error cases.

Signed-off-by: KengoA <20113339+KengoA@users.noreply.github.com>
Signed-off-by: KengoA <20113339+KengoA@users.noreply.github.com>
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d553546) 81.7% compared to head (5b97580) 81.7%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #963   +/-   ##
=====================================
  Coverage   81.7%   81.7%           
=====================================
  Files         54      54           
  Lines       4208    4208           
  Branches     889     889           
=====================================
+ Hits        3439    3441    +2     
+ Misses       574     572    -2     
  Partials     195     195           

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

Comment on lines -40 to -43
# some users might submit the policy without underscores
**{ipp.value.lower().replace("_", ""): ipp for ipp in ImagePullPolicy},
# some users might submit the policy in lowercase
**{ipp.name.lower(): ipp for ipp in ImagePullPolicy},
Copy link
Contributor Author

@KengoA KengoA Feb 16, 2024

Choose a reason for hiding this comment

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

These were not accessing the intended values and created duplicate key-value pairs.

Reference:

# src/hera/workflows/models/io/k8s/api/core/v1.py

class ImagePullPolicy(Enum):
    always = "Always"
    never = "Never"
    if_not_present = "IfNotPresent"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good find, thanks! cc @flaviuvadan JFYI 👀

@KengoA KengoA marked this pull request as ready for review February 16, 2024 09:03
@elliotgunton elliotgunton added semver:patch A change requiring a patch version bump type:bug A general bug labels Feb 16, 2024
Copy link
Collaborator

@elliotgunton elliotgunton left a comment

Choose a reason for hiding this comment

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

Thank you! 🚀

Comment on lines -40 to -43
# some users might submit the policy without underscores
**{ipp.value.lower().replace("_", ""): ipp for ipp in ImagePullPolicy},
# some users might submit the policy in lowercase
**{ipp.name.lower(): ipp for ipp in ImagePullPolicy},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good find, thanks! cc @flaviuvadan JFYI 👀

@elliotgunton elliotgunton merged commit 089a7ae into argoproj-labs:main Feb 16, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants