(cloudConfig config.Cloud)
| 14 | const defaultHostname = "remote.sqlc.dev" |
| 15 | |
| 16 | func NewClient(cloudConfig config.Cloud) (GenClient, error) { |
| 17 | authID := cloudConfig.Organization + "/" + cloudConfig.Project |
| 18 | opts := []grpc.DialOption{ |
| 19 | grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), |
| 20 | grpc.WithPerRPCCredentials(basic.NewPerRPCCredentials(authID, cloudConfig.AuthToken)), |
| 21 | grpc.WithUnaryInterceptor(rpc.UnaryInterceptor), |
| 22 | } |
| 23 | |
| 24 | hostname := cloudConfig.Hostname |
| 25 | if hostname == "" { |
| 26 | hostname = defaultHostname |
| 27 | } |
| 28 | |
| 29 | conn, err := grpc.Dial(hostname+":443", opts...) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | |
| 34 | return NewGenClient(conn), nil |
| 35 | } |
no test coverage detected