@@ -11,6 +11,7 @@ import (
1111 "github.com/prometheus/client_golang/prometheus"
1212 "google.golang.org/grpc"
1313 "google.golang.org/grpc/credentials"
14+ "google.golang.org/grpc/credentials/insecure"
1415 healthv1 "google.golang.org/grpc/health/grpc_health_v1"
1516 "google.golang.org/grpc/metadata"
1617 adminv1 "xeiaso.net/v4/gen/techaro/thoth/auth/admin/v1"
@@ -25,18 +26,26 @@ type Client struct {
2526 AdminUsers adminv1.UsersServiceClient
2627}
2728
28- func New (ctx context.Context , thothURL , apiToken string ) (* Client , error ) {
29+ func New (ctx context.Context , thothURL , apiToken string , noTLS bool ) (* Client , error ) {
2930 clMetrics := grpcprom .NewClientMetrics (
3031 grpcprom .WithClientHandlingTimeHistogram (
3132 grpcprom .WithHistogramBuckets ([]float64 {0.001 , 0.01 , 0.1 , 0.3 , 0.6 , 1 , 3 , 6 , 9 , 20 , 30 , 60 , 90 , 120 }),
3233 ),
3334 )
3435 prometheus .DefaultRegisterer .Register (clMetrics )
3536
37+ var transportCreds credentials.TransportCredentials
38+
39+ switch noTLS {
40+ case true :
41+ transportCreds = insecure .NewCredentials ()
42+ case false :
43+ transportCreds = credentials .NewTLS (& tls.Config {})
44+ }
45+
3646 conn , err := grpc .NewClient (
3747 thothURL ,
38- grpc .WithTransportCredentials (credentials .NewTLS (& tls.Config {})),
39- //grpc.WithTransportCredentials(insecure.NewCredentials()),
48+ grpc .WithTransportCredentials (transportCreds ),
4049 grpc .WithChainUnaryInterceptor (
4150 timeout .UnaryClientInterceptor (5 * time .Minute ),
4251 clMetrics .UnaryClientInterceptor (),
0 commit comments