treewide: replace deprecated grpc.Dial with grpc.NewClient
Change-Id: I925912ca1ee01d547fd9c1813eb083a2cd9a590a
Reviewed-on: https://review.monogon.dev/c/monogon/+/3858
Reviewed-by: Jan Schär <jan@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/rpc.go b/metropolis/cli/metroctl/rpc.go
index ec3a4e4..b3a9819 100644
--- a/metropolis/cli/metroctl/rpc.go
+++ b/metropolis/cli/metroctl/rpc.go
@@ -20,9 +20,9 @@
"source.monogon.dev/metropolis/node/core/rpc/resolver"
)
-func dialAuthenticated(ctx context.Context) (*grpc.ClientConn, error) {
- // Collect credentials, validate command parameters, and try dialing the
- // cluster.
+func newAuthenticatedClient(ctx context.Context) (*grpc.ClientConn, error) {
+ // Collect credentials, validate command parameters, and create the grpc
+ // client.
ocert, opkey, err := core.GetOwnerCredentials(flags.configPath)
if errors.Is(err, core.ErrNoCredentials) {
return nil, fmt.Errorf("you have to take ownership of the cluster first: %w", err)
@@ -50,23 +50,23 @@
}
opts = append(opts, grpc.WithTransportCredentials(creds))
- cc, err := grpc.Dial(resolver.MetropolisControlAddress, opts...)
+ cc, err := grpc.NewClient(resolver.MetropolisControlAddress, opts...)
if err != nil {
- return nil, fmt.Errorf("while dialing cluster: %w", err)
+ return nil, fmt.Errorf("while creating client: %w", err)
}
return cc, nil
}
-func dialAuthenticatedNode(ctx context.Context, id, address string, cacert *x509.Certificate) (*grpc.ClientConn, error) {
- // Collect credentials, validate command parameters, and try dialing the
- // cluster.
+func newAuthenticatedNodeClient(ctx context.Context, id, address string, cacert *x509.Certificate) (*grpc.ClientConn, error) {
+ // Collect credentials, validate command parameters, and create the grpc
+ // client.
ocert, opkey, err := core.GetOwnerCredentials(flags.configPath)
if errors.Is(err, core.ErrNoCredentials) {
return nil, fmt.Errorf("you have to take ownership of the cluster first: %w", err)
}
- cc, err := core.DialNode(ctx, opkey, ocert, cacert, flags.proxyAddr, id, address)
+ cc, err := core.NewNodeClient(ctx, opkey, ocert, cacert, flags.proxyAddr, id, address)
if err != nil {
- return nil, fmt.Errorf("while dialing node: %w", err)
+ return nil, fmt.Errorf("while creating client: %w", err)
}
return cc, nil
}