-
Notifications
You must be signed in to change notification settings - Fork 240
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
Generics: The Future #1820
Generics: The Future #1820
Conversation
Skipping CI for Draft Pull Request. |
/hold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome @dlom!
I assume it doesn't compile yet because you haven't replaced all the occurrences of Find*Condition
in the codebase, right?
apis/hive/v1/generics.go
Outdated
} | ||
|
||
type ConditionType interface { | ||
AsString() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what happens if you do one of these (mutually exclusive) alternatives?
- Use the existng fmt.Stringer interface
- Nix the interface and just use
string()
inline inFindCondition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about the fmt.Stringer
interface... I think I'll do something like this
type ConditionType interface {
fmt.Stringer
}
so that ConditionType
can still be used as the generic constraint on FindCondition
. Alternatively, FindCondition
could take Stringer
s instead of ConditionType
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I prefer the former. The latter would mean you would have to change every condition type to a Stringer, which isn't awful, but if it's gonna be an interface type anyway, I like the explicitness of ConditionType
.
That said, what about my second bullet? Then all the condition types can just be string
and we don't need an interface for it.
We crossed in the mail. Looking good. Take the Draft status off once you think it'll build, so CI can take a crack at it. |
@dlom: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This is gonna be a nightmare to keep rebased. Basically every PR we land is gonna cause a merge conflict :( |
The first use-case of this is the new FindCondition function, which replaces several trivial array search functions.
/unhold |
Codecov Report
@@ Coverage Diff @@
## master #1820 +/- ##
==========================================
- Coverage 41.71% 41.47% -0.24%
==========================================
Files 354 355 +1
Lines 33142 33239 +97
==========================================
- Hits 13824 13785 -39
- Misses 18155 18291 +136
Partials 1163 1163
|
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this!
One nit inline; but let's do it in a FUP so you don't have to keep chasing rebases.
/lgtm
// This is a hack to get Go to accept this arbitrary string as the proper type | ||
dummy := hivev1.ClusterDeploymentCondition{Type: "ClusterImageSetNotFound"} | ||
lc := controllerutils.FindCondition(cd.Status.Conditions, dummy.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather make a const for it, no?
/lgtm hello? |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 2uasimojo, dlom The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@dlom: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
xref: https://issues.redhat.com/browse/HIVE-1935