From bd0528342b505a15e1c1d3373543577b97f56516 Mon Sep 17 00:00:00 2001
From: Fabian Seidl <fabian.seidl@h-da.de>
Date: Mon, 8 Apr 2024 10:04:36 +0200
Subject: [PATCH] fix deprecated calls

---
 application-framework/registration/registration.go          | 2 +-
 applications/arista-routing-engine/app.go                   | 2 +-
 applications/basic-interface-monitoring/app.go              | 2 +-
 applications/hostname-checker/app.go                        | 2 +-
 applications/venv-manager/venv-manager/venv-manager.go      | 2 +-
 controller/controller.go                                    | 4 ++--
 controller/northbound/client/app.go                         | 2 +-
 controller/northbound/client/configurationManagement.go     | 2 +-
 controller/northbound/client/networkElement.go              | 2 +-
 controller/northbound/client/plugin.go                      | 2 +-
 controller/northbound/client/pnd.go                         | 2 +-
 controller/northbound/client/rbac.go                        | 6 +++---
 controller/northbound/client/sbi.go                         | 2 +-
 .../integrationTestUtils/integrationTestUtils.go            | 4 ++--
 14 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/application-framework/registration/registration.go b/application-framework/registration/registration.go
index 10305ba5c..97acc4e3d 100644
--- a/application-framework/registration/registration.go
+++ b/application-framework/registration/registration.go
@@ -11,7 +11,7 @@ import (
 
 // Register registers a new app at the control plane.
 func Register(ctx context.Context, gosdnAddress, name, token string) (string, error) {
-	conn, err := grpc.Dial(gosdnAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient(gosdnAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		return "", err
 	}
diff --git a/applications/arista-routing-engine/app.go b/applications/arista-routing-engine/app.go
index 78bce8b9d..64aadaa1b 100644
--- a/applications/arista-routing-engine/app.go
+++ b/applications/arista-routing-engine/app.go
@@ -40,7 +40,7 @@ func (a *Application) Run(controllerAddress string) {
 	})
 	a.eventServiceRoutes.SetupEventReciever(a.stopChannel)
 
-	conn, err := grpc.Dial(controllerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient(controllerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		panic(err)
 	}
diff --git a/applications/basic-interface-monitoring/app.go b/applications/basic-interface-monitoring/app.go
index 9f82cca69..a2b95f1bf 100644
--- a/applications/basic-interface-monitoring/app.go
+++ b/applications/basic-interface-monitoring/app.go
@@ -31,7 +31,7 @@ func (a *Application) Run(controllerAddress string) {
 	})
 	a.eventServiceNetworkElements.SetupEventReciever(a.stopChannel)
 
-	conn, err := grpc.Dial(controllerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient(controllerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		panic(err)
 	}
diff --git a/applications/hostname-checker/app.go b/applications/hostname-checker/app.go
index b427236bf..441828a45 100644
--- a/applications/hostname-checker/app.go
+++ b/applications/hostname-checker/app.go
@@ -35,7 +35,7 @@ func (a *Application) Run() {
 	})
 	a.eventService.SetupEventReciever(a.stopChannel)
 
-	conn, err := grpc.Dial("localhost:55055", grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient("localhost:55055", grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		panic(err)
 	}
diff --git a/applications/venv-manager/venv-manager/venv-manager.go b/applications/venv-manager/venv-manager/venv-manager.go
index 5c4416f06..c1d6f6510 100644
--- a/applications/venv-manager/venv-manager/venv-manager.go
+++ b/applications/venv-manager/venv-manager/venv-manager.go
@@ -50,7 +50,7 @@ func NewVenvManager(dialConnectionURL string, dialOption grpc.DialOption, topolo
 }
 
 func (v *VenvManager) createConnection() (*grpc.ClientConn, error) {
-	conn, err := grpc.Dial(v.dialConnectionURL, v.dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
+	conn, err := grpc.NewClient(v.dialConnectionURL, v.dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/controller.go b/controller/controller.go
index ca31ed040..7a1adbc81 100644
--- a/controller/controller.go
+++ b/controller/controller.go
@@ -181,7 +181,7 @@ func initialize() error {
 
 func setupOrchestratorClient() {
 	orchestrator := viper.GetString("csbi-orchestrator")
-	conn, err := grpc.Dial(orchestrator, grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient(orchestrator, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		log.Fatal(err)
 	}
@@ -190,7 +190,7 @@ func setupOrchestratorClient() {
 
 func setupPluginRegistryClient() rpb.PluginRegistryServiceClient {
 	pluginRegistry := viper.GetString("plugin-registry")
-	conn, err := grpc.Dial(pluginRegistry, grpc.WithTransportCredentials(insecure.NewCredentials()))
+	conn, err := grpc.NewClient(pluginRegistry, grpc.WithTransportCredentials(insecure.NewCredentials()))
 	if err != nil {
 		log.Fatal(err)
 	}
diff --git a/controller/northbound/client/app.go b/controller/northbound/client/app.go
index 750af3056..48195078a 100644
--- a/controller/northbound/client/app.go
+++ b/controller/northbound/client/app.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func AppClient(addr string, opts ...grpc.DialOption) (apb.AppServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/configurationManagement.go b/controller/northbound/client/configurationManagement.go
index 8e008d173..a88cae6d7 100644
--- a/controller/northbound/client/configurationManagement.go
+++ b/controller/northbound/client/configurationManagement.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func ConfigurationManagementClient(addr string, opts ...grpc.DialOption) (cpb.ConfigurationManagementServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/networkElement.go b/controller/northbound/client/networkElement.go
index 58267f6ba..b3b71cf07 100644
--- a/controller/northbound/client/networkElement.go
+++ b/controller/northbound/client/networkElement.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func NetworkElementClient(addr string, opts ...grpc.DialOption) (mnepb.NetworkElementServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/plugin.go b/controller/northbound/client/plugin.go
index 5129e1fdb..e9adcdd42 100644
--- a/controller/northbound/client/plugin.go
+++ b/controller/northbound/client/plugin.go
@@ -6,7 +6,7 @@ import (
 )
 
 func PluginClient(addr string, opts ...grpc.DialOption) (pipb.PluginInternalServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/pnd.go b/controller/northbound/client/pnd.go
index c392566ea..c239c6c69 100644
--- a/controller/northbound/client/pnd.go
+++ b/controller/northbound/client/pnd.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func PndClient(addr string, opts ...grpc.DialOption) (ppb.PndServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/rbac.go b/controller/northbound/client/rbac.go
index c5f9a9700..1c3443f4b 100644
--- a/controller/northbound/client/rbac.go
+++ b/controller/northbound/client/rbac.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func AuthClient(addr string, opts ...grpc.DialOption) (apb.AuthServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -20,7 +20,7 @@ func AuthClient(addr string, opts ...grpc.DialOption) (apb.AuthServiceClient, er
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func UserClient(addr string, opts ...grpc.DialOption) (apb.UserServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -31,7 +31,7 @@ func UserClient(addr string, opts ...grpc.DialOption) (apb.UserServiceClient, er
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func RoleClient(addr string, opts ...grpc.DialOption) (apb.RoleServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/controller/northbound/client/sbi.go b/controller/northbound/client/sbi.go
index c89d58006..a07128b89 100644
--- a/controller/northbound/client/sbi.go
+++ b/controller/northbound/client/sbi.go
@@ -9,7 +9,7 @@ import (
 // the address of the gRPC endpoint and optional grpc.DialOption
 // as argument.
 func SbiClient(addr string, opts ...grpc.DialOption) (spb.SbiServiceClient, error) {
-	conn, err := grpc.Dial(addr, opts...)
+	conn, err := grpc.NewClient(addr, opts...)
 	if err != nil {
 		return nil, err
 	}
diff --git a/integration-tests/integrationTestUtils/integrationTestUtils.go b/integration-tests/integrationTestUtils/integrationTestUtils.go
index 7f556cb82..b3e6442e8 100644
--- a/integration-tests/integrationTestUtils/integrationTestUtils.go
+++ b/integration-tests/integrationTestUtils/integrationTestUtils.go
@@ -50,7 +50,7 @@ func CreateSecureConnection() (*grpc.ClientConn, context.Context, error) {
 	sessionContext := CreateContextWithAuthorization(loginResp)
 
 	dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
-	conn, err := grpc.Dial(controllerUrl, dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
+	conn, err := grpc.NewClient(controllerUrl, dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
 	if err != nil {
 		return nil, nil, err
 	}
@@ -65,7 +65,7 @@ func CreateConnection() (*grpc.ClientConn, context.Context, error) {
 		controllerUrl = controllerEnv
 	}
 	dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
-	conn, err := grpc.Dial(controllerUrl, dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
+	conn, err := grpc.NewClient(controllerUrl, dialOption, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(100*1024*1024)))
 	if err != nil {
 		return nil, nil, err
 	}
-- 
GitLab