@@ -17,7 +17,6 @@ package instance
1717import (
1818 "context"
1919 "fmt"
20- "strings"
2120 "time"
2221
2322 "github.com/go-logr/logr"
@@ -109,11 +108,9 @@ func NewController(
109108
110109// Reconcile is a handler function that reconciles the instance and its sub-resources.
111110func (c * Controller ) Reconcile (ctx context.Context , req ctrl.Request ) error {
112- namespace , name := getNamespaceName ( req )
111+ log := c . log . WithValues ( "namespace" , req . Namespace , "name" , req . Name )
113112
114- log := c .log .WithValues ("namespace" , namespace , "name" , name )
115-
116- instance , err := c .clientSet .Dynamic ().Resource (c .gvr ).Namespace (namespace ).Get (ctx , name , metav1.GetOptions {})
113+ instance , err := c .clientSet .Dynamic ().Resource (c .gvr ).Namespace (req .Namespace ).Get (ctx , req .Name , metav1.GetOptions {})
117114 if err != nil {
118115 if apierrors .IsNotFound (err ) {
119116 log .Info ("Instance not found, it may have been deleted" )
@@ -152,14 +149,3 @@ func (c *Controller) Reconcile(ctx context.Context, req ctrl.Request) error {
152149 }
153150 return instanceGraphReconciler .reconcile (ctx )
154151}
155-
156- // getNamespaceName extracts the namespace and name from the request.
157- func getNamespaceName (req ctrl.Request ) (string , string ) {
158- parts := strings .Split (req .Name , "/" )
159- name := parts [len (parts )- 1 ]
160- namespace := parts [0 ]
161- if namespace == "" {
162- namespace = metav1 .NamespaceDefault
163- }
164- return namespace , name
165- }
0 commit comments