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

⚠️ Add predicates as variadic args for Owns, For, and Watches func #799

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

mszostok
Copy link
Contributor

Description

  • This PR adds options for defining the Predicate. Watches, Owns, For, and Watches
  • Add tests coverage for implemented logic using ginko & gomega

Implemented with Functional Options pattern as described here: #602 (comment)

I decided to go with Input struct for each method to have separation and make those methods independent of each other.

Fixes: #572

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 14, 2020
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

The design looks much cleaner and extensible. 💯 Really great job!

/assign @DirectXMan12 @gerred

@vincepri vincepri added this to the v0.6.0 milestone Feb 21, 2020
@vincepri vincepri changed the title ✨ Add predicates as variadic args for Owns, For, and Watches func ⚠️ Add predicates as variadic args for Owns, For, and Watches func Feb 21, 2020
@DirectXMan12
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, mszostok

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2020
@DirectXMan12
Copy link
Contributor

FYI, this'll prob mean some cherry-picking for the next v0.5.x release

@vincepri
Copy link
Member

did we say that varargs are breaking changes and need to go into the next release?

@DirectXMan12
Copy link
Contributor

Yeah -- it changes the type signature.

For instance, if you had func callWithPod(cb func(runtime.Object) ctrl.Builder), you could no longer pass For or Owns to that function.

@vincepri
Copy link
Member

vincepri commented Mar 2, 2020

Sounds good, I'll put a hold on this once we want to open master for v0.6. Given that there are a few PRs in flight for v0.5.x, I'm thinking we can wait for those to be merged, cut v0.5.1 and then open master to v0.6.

/hold
until breaking change on master are open

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 2, 2020
@@ -63,32 +63,62 @@ func (blder *Builder) ForType(apiType runtime.Object) *Builder {
return blder.For(apiType)
}

// ForInput represents the information set by For method.
type ForInput struct {
Copy link

Choose a reason for hiding this comment

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

Can we get away without exporting this type?
Likewise for OwnsInput and WatchesInput?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to allow custom implementations of options (which is nice), this has to be public

Copy link

Choose a reason for hiding this comment

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

Ah, so that others can implement ForOption.ApplyToFor and company. I see.

@vincepri
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 26, 2020
@vincepri
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 26, 2020
@k8s-ci-robot k8s-ci-robot merged commit 71edbc4 into kubernetes-sigs:master Mar 26, 2020
@mszostok mszostok deleted the watches-v2 branch April 24, 2020 17:08
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot specify per-watch predicates on builders
6 participants