Skip to content

Commit 977ac6d

Browse files
kyleconroyclaude
andauthored
Remove --remote and --no-remote flags (#4417)
Removes the --remote/--no-remote flags, the remoteGenerate() codegen path, and the now-unused internal/remote gRPC client. The cloud.* config block, SQLC_AUTH_TOKEN, QuickDB, and managed databases are unaffected. Co-authored-by: Claude <noreply@anthropic.com>
1 parent f1da958 commit 977ac6d

8 files changed

Lines changed: 0 additions & 587 deletions

File tree

docs/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Flags:
2121
-f, --file string specify an alternate config file (default: sqlc.yaml)
2222
-h, --help help for sqlc
2323
--no-database disable database connections (default: false)
24-
--no-remote disable remote execution (default: false)
2524

2625
Use "sqlc [command] --help" for more information about a command.
2726
```

internal/cmd/cmd.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ func init() {
3737
func Do(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int {
3838
rootCmd := &cobra.Command{Use: "sqlc", SilenceUsage: true}
3939
rootCmd.PersistentFlags().StringP("file", "f", "", "specify an alternate config file (default: sqlc.yaml)")
40-
rootCmd.PersistentFlags().Bool("no-remote", false, "disable remote execution (default: false)")
41-
rootCmd.PersistentFlags().Bool("remote", false, "enable remote execution (default: false)")
4240

4341
rootCmd.AddCommand(checkCmd)
4442
rootCmd.AddCommand(createDBCmd)
@@ -141,20 +139,14 @@ type Env struct {
141139
DryRun bool
142140
Debug opts.Debug
143141
Experiment opts.Experiment
144-
Remote bool
145-
NoRemote bool
146142
}
147143

148144
func ParseEnv(c *cobra.Command) Env {
149145
dr := c.Flag("dry-run")
150-
r := c.Flag("remote")
151-
nr := c.Flag("no-remote")
152146
return Env{
153147
DryRun: dr != nil && dr.Changed,
154148
Debug: opts.DebugFromEnv(),
155149
Experiment: opts.ExperimentFromEnv(),
156-
Remote: r != nil && r.Value.String() == "true",
157-
NoRemote: nr != nil && nr.Value.String() == "true",
158150
}
159151
}
160152

internal/cmd/generate.go

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3531
const 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-
296224
func 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)

internal/endtoend/endtoend_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ func TestReplay(t *testing.T) {
265265
Env: cmd.Env{
266266
Debug: opts.DebugFromString(args.Env["SQLCDEBUG"]),
267267
Experiment: opts.ExperimentFromString(args.Env["SQLCEXPERIMENT"]),
268-
NoRemote: true,
269268
},
270269
Stderr: &stderr,
271270
MutateConfig: testctx.Mutate(t, path),

0 commit comments

Comments
 (0)