-
Notifications
You must be signed in to change notification settings - Fork 19
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 OperatorPolicy to create OLM subscriptions #162
Allow OperatorPolicy to create OLM subscriptions #162
Conversation
subscriptionSpec := r.buildSubscription(policy) | ||
err := r.Get(context.TODO(), | ||
types.NamespacedName{Namespace: subscriptionSpec.Namespace, Name: subscriptionSpec.Name}, | ||
subscriptionSpec) |
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.
For the Get, I think it's better to pass in an empty subscription, since that will be overwritten with what was found on the cluster.
operatorGroup := r.buildOperatorGroup(policy) | ||
err = r.Create(context.TODO(), operatorGroup) |
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 is fine for the initial prototype, but eventually it will need to consider what to do when there is already an operator group in the namespace. Just a comment here so we don't forget 😀
|
||
// buildSubscription bootstraps the subscription spec defined in the operator policy | ||
// with the apiversion and kind in preparation for resource creation | ||
func (r *OperatorPolicyReconciler) buildSubscription( |
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 don't think this will ever need anything from the Reconciler object, so this could be changed to just a function, as opposed to a method. The advantage to that is that it is then a bit easier to test in a unit test, because it's obvious that you don't need to instantiate a client or anything.
The CI is currently failing for the PR, because it is just barely missing the test coverage goal. I think adjusting this and buildOperatorGroup
to be regular functions, and adding a unit test for each, would solve this nicely. Eventually of course we'll want e2e tests for OperatorPolicies.
Modified the controller logic such that the OperatorPolicy controller can create OLM subscriptions based on the policy spec. Currently, an OperatorGroup is created for each Subscription. Future implementation will support creating OperatorGroups based on installModes supported by the generated CSVs. ref: https://issues.redhat.com/browse/ACM-6597 Signed-off-by: Jason Zhang <jaszhang@redhat.com>
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.
Thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JustinKuli, zyjjay 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 |
de86a78
into
open-cluster-management-io:main
Modified the controller logic such that the OperatorPolicy controller can create OLM subscriptions based on the policy spec. Currently, an OperatorGroup is created for each Subscription. Future implementation will support creating OperatorGroups based on installModes supported by the generated CSVs.
ref: https://issues.redhat.com/browse/ACM-6597