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

Removes GVKRequired struct #400

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Sep 7, 2023

Description

It doesn't look like we need this duplication.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
@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 Sep 7, 2023
@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.04% ⚠️

Comparison is base (edd5ad9) 81.64% compared to head (0afe663) 81.60%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #400      +/-   ##
==========================================
- Coverage   81.64%   81.60%   -0.04%     
==========================================
  Files          21       21              
  Lines         937      935       -2     
==========================================
- Hits          765      763       -2     
  Misses        119      119              
  Partials       53       53              
Flag Coverage Δ
e2e 61.92% <50.00%> (+0.13%) ⬆️
unit 77.17% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
internal/resolution/entities/bundle_entity.go 98.27% <100.00%> (-0.03%) ⬇️
...lution/variablesources/bundles_and_dependencies.go 87.09% <100.00%> (ø)

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

@@ -47,23 +47,13 @@ func (g GVK) String() string {
return fmt.Sprintf(`group:"%s" version:"%s" kind:"%s"`, g.Group, g.Version, g.Kind)
}

type GVKRequired property.GVKRequired
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have the type GVK property.GVK type alias above? Why do we need one of these two aliases but not both?

Copy link
Member Author

Choose a reason for hiding this comment

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

@stevekuznetsov I beleive this is only for use to define String() method on it.

I see no reason for GVKRequired to exist as both are esentially the same struct\schema.

Copy link
Member Author

@m1kola m1kola Sep 7, 2023

Choose a reason for hiding this comment

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

Another guess: probably we re-define structs so we don't spread property.GVK across controller-runtime codebase.

Copy link
Member

Choose a reason for hiding this comment

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

a) if we need aliases here, we need all of them
b) if there's a semantic difference between GVK and GVKRequired, we need to keep that difference here
c) if there's not a difference, let's go to "github.com/operator-framework/operator-registry/alpha/property" and remove GVKRequired.

so we don't spred property.GVK across controller-runtime codebase.

What does this mean? Why would we not want to do "spread"? What are the implications?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha! I didn't even notice GVKRequired was an alias for property.GVKRequired.

if there's a semantic difference between GVK and GVKRequired, we need to keep that difference here

There is semantic difference between properties (they have different type), but not between structs: they both represent GVK. See:

What does this mean? Why would we not want to do "spread"? What are the implications?

Like probably there was an idea to redefine struct in operator controller to have less dependency on operator-registry? I don't know, I'm just guessing what the original author meant 🤷‍♂️.

Copy link
Member

Choose a reason for hiding this comment

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

There is semantic difference between properties (they have different type), but not between structs: they both represent GVK.

If there is a semantic difference, I don't know that we can remove the use of one. Users are expected to understand the implication of each.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are not removing olm.gvk.required property type. User will still be using it. I'm only proposing to re-use a struct into which we unmarshal values of properties of both types olm.gvk and olm.gvk.required. GVKRequired is being converted into GVK anyway.

But I agree with you - this should be done on operator-registry side first. When creating this PR I didn't notice that that operator-registry also has two different structs for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, I see. It looks like the only purpose of separate GVKRequired is to enable operator-registry to get its type using reflection and map it to a property type.

@m1kola m1kola marked this pull request as ready for review September 7, 2023 16:27
@m1kola m1kola requested a review from a team as a code owner September 7, 2023 16:27
@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 Sep 7, 2023
Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2023
@tmshort tmshort added this pull request to the merge queue Sep 8, 2023
Merged via the queue into operator-framework:main with commit 5cbc9a0 Sep 8, 2023
12 checks passed
stevekuznetsov added a commit that referenced this pull request Sep 9, 2023
m1kola added a commit to m1kola/operator-controller that referenced this pull request Sep 11, 2023
This reverts commit 5cbc9a0.

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
github-merge-queue bot pushed a commit that referenced this pull request Sep 11, 2023
This reverts commit 5cbc9a0.

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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