From ff1d236b24c947ef4ab2f8234dfd1d04c2e3cad7 Mon Sep 17 00:00:00 2001 From: Andrew Benton Date: Wed, 26 Apr 2023 11:01:05 -0700 Subject: [PATCH] default remote execution hostname is remote.sqlc.dev --- internal/cmd/generate.go | 2 +- internal/remote/rpc.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/cmd/generate.go b/internal/cmd/generate.go index 17cccd49a4..efd58d6689 100644 --- a/internal/cmd/generate.go +++ b/internal/cmd/generate.go @@ -145,7 +145,7 @@ func Generate(ctx context.Context, e Env, dir, filename string, stderr io.Writer return nil, err } - if conf.Cloud.Hostname != "" && !e.NoRemote { + if conf.Cloud.Project != "" && !e.NoRemote { return remoteGenerate(ctx, configPath, conf, dir, stderr) } diff --git a/internal/remote/rpc.go b/internal/remote/rpc.go index de150d616a..72c10cbe52 100644 --- a/internal/remote/rpc.go +++ b/internal/remote/rpc.go @@ -11,13 +11,20 @@ import ( "github.com/kyleconroy/sqlc/internal/config" ) +const defaultHostname = "remote.sqlc.dev" + func NewClient(cloudConfig config.Cloud) (GenClient, error) { opts := []grpc.DialOption{ grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), grpc.WithPerRPCCredentials(bearer.NewPerRPCCredentials(os.Getenv("SQLC_AUTH_TOKEN"))), } - conn, err := grpc.Dial(cloudConfig.Hostname+":443", opts...) + hostname := cloudConfig.Hostname + if hostname == "" { + hostname = defaultHostname + } + + conn, err := grpc.Dial(hostname+":443", opts...) if err != nil { return nil, err }