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

Generics: The Future #1820

Merged
merged 1 commit into from
Jul 21, 2022
Merged

Conversation

dlom
Copy link
Contributor

@dlom dlom commented Jul 14, 2022

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 14, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot requested review from 2uasimojo and akhil-rane July 14, 2022 18:10
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 14, 2022
@dlom
Copy link
Contributor Author

dlom commented Jul 14, 2022

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 14, 2022
Copy link
Member

@2uasimojo 2uasimojo left a 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 Show resolved Hide resolved
}

type ConditionType interface {
AsString() string
Copy link
Member

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?

?

Copy link
Contributor Author

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 Stringers instead of ConditionTypes

Copy link
Member

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.

@2uasimojo
Copy link
Member

doesn't compile yet because you haven't replaced

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 dlom marked this pull request as ready for review July 14, 2022 18:57
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2022
@openshift-ci openshift-ci bot requested a review from abutcher July 14, 2022 18:59
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 14, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 14, 2022

@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.

@2uasimojo
Copy link
Member

@dlom: PR needs rebase.

This is gonna be a nightmare to keep rebased. Basically every PR we land is gonna cause a merge conflict :(

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 20, 2022
The first use-case of this is the new FindCondition function, which
replaces several trivial array search functions.
@dlom
Copy link
Contributor Author

dlom commented Jul 20, 2022

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2022
@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #1820 (4ae1f97) into master (707d093) will decrease coverage by 0.23%.
The diff coverage is 48.59%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
...g/controller/clustersync/clustersync_controller.go 75.84% <0.00%> (ø)
...akeclusterinstall/fakeclusterinstall_controller.go 0.00% <0.00%> (ø)
...g/controller/machinepool/machinepool_controller.go 47.98% <0.00%> (ø)
pkg/controller/metrics/metrics.go 33.14% <0.00%> (ø)
.../openshift/hive/apis/hive/v1/clusterclaim_types.go 33.33% <0.00%> (-66.67%) ⬇️
...shift/hive/apis/hive/v1/clusterdeployment_types.go 33.33% <0.00%> (-66.67%) ⬇️
...hift/hive/apis/hive/v1/clusterdeprovision_types.go 33.33% <0.00%> (-66.67%) ⬇️
...ift/hive/apis/hive/v1/clusterinstall_conditions.go 0.00% <0.00%> (ø)
...m/openshift/hive/apis/hive/v1/clusterpool_types.go 33.33% <0.00%> (-66.67%) ⬇️
...nshift/hive/apis/hive/v1/clusterprovision_types.go 33.33% <0.00%> (-66.67%) ⬇️
... and 20 more

@dlom
Copy link
Contributor Author

dlom commented Jul 20, 2022

/retest

Copy link
Member

@2uasimojo 2uasimojo left a 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

Comment on lines +1808 to +1810
// 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)
Copy link
Member

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?

@2uasimojo
Copy link
Member

/lgtm

hello?

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 21, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 21, 2022

@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.

@openshift-merge-robot openshift-merge-robot merged commit 34a0d90 into openshift:master Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants