@@ -13,7 +13,6 @@ import (
1313 "sync"
1414
1515 "google.golang.org/grpc"
16- "google.golang.org/grpc/status"
1716
1817 "github.com/sqlc-dev/sqlc/internal/codegen/golang"
1918 genjson "github.com/sqlc-dev/sqlc/internal/codegen/json"
@@ -24,12 +23,9 @@ import (
2423 "github.com/sqlc-dev/sqlc/internal/ext"
2524 "github.com/sqlc-dev/sqlc/internal/ext/process"
2625 "github.com/sqlc-dev/sqlc/internal/ext/wasm"
27- "github.com/sqlc-dev/sqlc/internal/info"
2826 "github.com/sqlc-dev/sqlc/internal/multierr"
2927 "github.com/sqlc-dev/sqlc/internal/opts"
3028 "github.com/sqlc-dev/sqlc/internal/plugin"
31- "github.com/sqlc-dev/sqlc/internal/remote"
32- "github.com/sqlc-dev/sqlc/internal/sql/sqlpath"
3329)
3430
3531const errMessageNoVersion = `The configuration file must have a version number.
@@ -151,11 +147,6 @@ func Generate(ctx context.Context, dir, filename string, o *Options) (map[string
151147 return nil , err
152148 }
153149
154- // Comment on why these two methods exist
155- if conf .Cloud .Project != "" && e .Remote && ! e .NoRemote {
156- return remoteGenerate (ctx , configPath , conf , dir , stderr )
157- }
158-
159150 g := & generator {
160151 dir : dir ,
161152 output : map [string ]string {},
@@ -230,69 +221,6 @@ func (g *generator) ProcessResult(ctx context.Context, combo config.CombinedSett
230221 return nil
231222}
232223
233- func remoteGenerate (ctx context.Context , configPath string , conf * config.Config , dir string , stderr io.Writer ) (map [string ]string , error ) {
234- rpcClient , err := remote .NewClient (conf .Cloud )
235- if err != nil {
236- fmt .Fprintf (stderr , "error creating rpc client: %s\n " , err )
237- return nil , err
238- }
239-
240- configBytes , err := os .ReadFile (configPath )
241- if err != nil {
242- fmt .Fprintf (stderr , "error reading config file %s: %s\n " , configPath , err )
243- return nil , err
244- }
245-
246- rpcReq := remote.GenerateRequest {
247- Version : info .Version ,
248- Inputs : []* remote.File {{Path : filepath .Base (configPath ), Bytes : configBytes }},
249- }
250-
251- for _ , pkg := range conf .SQL {
252- for _ , paths := range []config.Paths {pkg .Schema , pkg .Queries } {
253- for i , relFilePath := range paths {
254- paths [i ] = filepath .Join (dir , relFilePath )
255- }
256- files , err := sqlpath .Glob (paths )
257- if err != nil {
258- fmt .Fprintf (stderr , "error globbing paths: %s\n " , err )
259- return nil , err
260- }
261- for _ , filePath := range files {
262- fileBytes , err := os .ReadFile (filePath )
263- if err != nil {
264- fmt .Fprintf (stderr , "error reading file %s: %s\n " , filePath , err )
265- return nil , err
266- }
267- fileRelPath , _ := filepath .Rel (dir , filePath )
268- rpcReq .Inputs = append (rpcReq .Inputs , & remote.File {Path : fileRelPath , Bytes : fileBytes })
269- }
270- }
271- }
272-
273- rpcResp , err := rpcClient .Generate (ctx , & rpcReq )
274- if err != nil {
275- rpcStatus , ok := status .FromError (err )
276- if ! ok {
277- return nil , err
278- }
279- fmt .Fprintf (stderr , "rpc error: %s" , rpcStatus .Message ())
280- return nil , rpcStatus .Err ()
281- }
282-
283- if rpcResp .ExitCode != 0 {
284- fmt .Fprintf (stderr , "%s" , rpcResp .Stderr )
285- return nil , errors .New ("remote execution returned with non-zero exit code" )
286- }
287-
288- output := map [string ]string {}
289- for _ , file := range rpcResp .Outputs {
290- output [filepath .Join (dir , file .Path )] = string (file .Bytes )
291- }
292-
293- return output , nil
294- }
295-
296224func parse (ctx context.Context , name , dir string , sql config.SQL , combo config.CombinedSettings , parserOpts opts.Parser , stderr io.Writer ) (* compiler.Result , bool ) {
297225 defer trace .StartRegion (ctx , "parse" ).End ()
298226 c , err := compiler .NewCompiler (sql , combo , parserOpts )
0 commit comments