Repository: redhat-developer/service-binding-operator
Pull request #79 (2019-07-18 10:58:19)

Move planner into a separate package
Moving into a separate package will make re-usability easier.

openshift-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **baijum**
You can assign the PR to them by writing `/assign @baijum` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-developer%2Fservice-binding-operator).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/redhat-developer/service-binding-operator/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["baijum"]} -->
baijum: /approve
openshift-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/redhat-developer/service-binding-operator/pull/79#issuecomment-512776054" title="Approved">baijum</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-developer%2Fservice-binding-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/redhat-developer/service-binding-operator/blob/master/OWNERS)~~ [baijum]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/controller/servicebindingrequest/planner.go b/pkg/controller/servicebindingrequest/planner/planner.go
similarity index 99%
rename from pkg/controller/servicebindingrequest/planner.go
rename to pkg/controller/servicebindingrequest/planner/planner.go
index 9d7a9983..704dc32d 100644
--- a/pkg/controller/servicebindingrequest/planner.go
+++ b/pkg/controller/servicebindingrequest/planner/planner.go
@@ -1,4 +1,4 @@
-package servicebindingrequest
+package planner
 
 import (
 	"context"
diff --git a/pkg/controller/servicebindingrequest/reconciler.go b/pkg/controller/servicebindingrequest/reconciler.go
index b21f9041..36f8dbae 100644
--- a/pkg/controller/servicebindingrequest/reconciler.go
+++ b/pkg/controller/servicebindingrequest/reconciler.go
@@ -14,6 +14,7 @@ import (
 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
 
 	"github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
+	"github.com/redhat-developer/service-binding-operator/pkg/controller/servicebindingrequest/planner"
 )
 
 // Reconciler reconciles a ServiceBindingRequest object
@@ -66,8 +67,8 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err
 	logger.WithValues("ServiceBindingRequest.Name", instance.Name).
 		Info("Found service binding request to inspect")
 
-	planner := NewPlanner(ctx, r.client, request.Namespace, instance)
-	plan, err := planner.Plan()
+	plnr := planner.NewPlanner(ctx, r.client, request.Namespace, instance)
+	plan, err := plnr.Plan()
 	if err != nil {
 		return RequeueOnNotFound(err)
 	}
diff --git a/pkg/controller/servicebindingrequest/retriever.go b/pkg/controller/servicebindingrequest/retriever.go
index cb441433..2653dcfd 100644
--- a/pkg/controller/servicebindingrequest/retriever.go
+++ b/pkg/controller/servicebindingrequest/retriever.go
@@ -6,6 +6,7 @@ import (
 	"strings"
 
 	"github.com/go-logr/logr"
+	"github.com/redhat-developer/service-binding-operator/pkg/controller/servicebindingrequest/planner"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -18,7 +19,7 @@ import (
 type Retriever struct {
 	ctx    context.Context   // request context
 	client client.Client     // Kubernetes API client
-	plan   *Plan             // plan instance
+	plan   *planner.Plan     // plan instance
 	logger logr.Logger       // logger instance
 	data   map[string][]byte // data retrieved
 }
@@ -182,7 +183,7 @@ func (r *Retriever) Retrieve() error {
 }
 
 // NewRetriever instantiate a new retriever instance.
-func NewRetriever(ctx context.Context, client client.Client, plan *Plan) *Retriever {
+func NewRetriever(ctx context.Context, client client.Client, plan *planner.Plan) *Retriever {
 	return &Retriever{
 		ctx:    ctx,
 		client: client,


Test patch:
diff --git a/pkg/controller/servicebindingrequest/planner_test.go b/pkg/controller/servicebindingrequest/planner/planner_test.go
similarity index 98%
rename from pkg/controller/servicebindingrequest/planner_test.go
rename to pkg/controller/servicebindingrequest/planner/planner_test.go
index a006a948..e6ec4eaf 100644
--- a/pkg/controller/servicebindingrequest/planner_test.go
+++ b/pkg/controller/servicebindingrequest/planner/planner_test.go
@@ -1,4 +1,4 @@
-package servicebindingrequest
+package planner
 
 import (
 	"context"
diff --git a/pkg/controller/servicebindingrequest/retriever_test.go b/pkg/controller/servicebindingrequest/retriever_test.go
index 0f4c9ce1..7643d66d 100644
--- a/pkg/controller/servicebindingrequest/retriever_test.go
+++ b/pkg/controller/servicebindingrequest/retriever_test.go
@@ -11,6 +11,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client/fake"
 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
 
+	"github.com/redhat-developer/service-binding-operator/pkg/controller/servicebindingrequest/planner"
 	"github.com/redhat-developer/service-binding-operator/test/mocks"
 )
 
@@ -27,7 +28,7 @@ func TestRetriever(t *testing.T) {
 	genericCR, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&cr)
 	require.Nil(t, err)
 
-	plan := &Plan{
+	plan := &planner.Plan{
 		Ns:             ns,
 		Name:           "retriever",
 		CRDDescription: &crdDescription,
@@ -116,7 +117,7 @@ func TestRetrieverNestedCRDKey(t *testing.T) {
 	genericCR, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&cr)
 	require.Nil(t, err)
 
-	plan := &Plan{
+	plan := &planner.Plan{
 		Ns:             ns,
 		Name:           "retriever",
 		CRDDescription: &crdDescription,