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

Allow explicit passing of plural name to new_class instead of suffix #403

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

jacobtomlinson
Copy link
Member

@jacobtomlinson jacobtomlinson commented Jun 11, 2024

Reverts #392
Closes #402

In #392 I added support for specifying the plural_suffix in new_class. This was done because previously it just assumed the plural form added an s suffix (pod => pods). In #391 an example was given where the suffix should be es (ec2nodeclass => ec2nodeclasses), so I added the ability to modify the suffix.

However since then I found an example where we don't simply add a suffix, but instead replace the last letter with a suffix (policy => policies).

This PR reverts the ability to modify the suffix and instead gives the ability to specify the entire plural. This makes things less "clever" and hopefully solves other edge cases we haven't thought of yet.

from kr8s.objects import new_class

MyPolicy = new_class(
        kind="MyPolicy",
        plural="MyPolicies",
        version="newclass.example.com/v1",
        namespaced=True,
    )

Plural is still optional though, and if you omit it then we just assume the plural form appends an s to the singular.

This change is slightly breaking because I opted to replace the plural_suffix with just plural rather than allow both. But the impact should be low because it is a very new addition and I expect few users will have adopted it.

@jacobtomlinson jacobtomlinson added bug Something isn't working kr8s breaking A breaking change labels Jun 11, 2024
@github-actions github-actions bot added tests and removed bug Something isn't working breaking A breaking change labels Jun 11, 2024
@jacobtomlinson jacobtomlinson changed the title Allow explicit passing of plural name to new_class Allow explicit passing of plural name to new_class instead of suffix Jun 11, 2024
@jacobtomlinson jacobtomlinson added bug Something isn't working breaking A breaking change labels Jun 11, 2024
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.29%. Comparing base (87063fc) to head (8db9e27).
Report is 106 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
+ Coverage   94.61%   95.29%   +0.67%     
==========================================
  Files          29       29              
  Lines        3141     3574     +433     
==========================================
+ Hits         2972     3406     +434     
+ Misses        169      168       -1     

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

@jacobtomlinson jacobtomlinson merged commit 74fa848 into kr8s-org:main Jun 11, 2024
12 checks passed
@jacobtomlinson jacobtomlinson deleted the new-class-plural branch June 11, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A breaking change bug Something isn't working kr8s tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve plural suffix support
1 participant