diff --git a/controllers/installation_controller.go b/controllers/installation_controller.go index 8b701e7c..8224d292 100644 --- a/controllers/installation_controller.go +++ b/controllers/installation_controller.go @@ -156,9 +156,6 @@ func (r *InstallationReconciler) Reconcile(ctx context.Context, req ctrl.Request } log.V(Log4Debug).Info("Reconciliation complete: A porter agent has been dispatched to apply changes to the installation.") - // TODO: make this one function (not a fan of doing this) and call when - // connection has been established. Add annotation about installation output - // being true. if r.PorterGRPCClient != nil { return r.CheckOrCreateInstallationOutputsCR(ctx, log, inst) } diff --git a/main.go b/main.go index aae20f20..4446410e 100644 --- a/main.go +++ b/main.go @@ -66,17 +66,19 @@ func main() { setupLog.Error(err, "unable to start manager") os.Exit(1) } - // TODO: Set this with credentials on the server side - // TODO: This needs to be set so we don't fail when instantiating client + // NOTE: Pass in nil client if connection isn't established + var client controllers.PorterClient conn, err := grpc.DialContext(context.Background(), "porter-grpc-service:3001", grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { setupLog.Error(err, "unable to set up listener") - os.Exit(1) } defer conn.Close() + if conn != nil { + client = porterv1alpha1.NewPorterClient(conn) + } if err = (&controllers.InstallationReconciler{ Client: mgr.GetClient(), - PorterGRPCClient: porterv1alpha1.NewPorterClient(conn), + PorterGRPCClient: client, Log: ctrl.Log.WithName("controllers").WithName("Installation"), Scheme: mgr.GetScheme(), }).SetupWithManager(mgr); err != nil {