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 }