Skip to content

Commit 5d4c8dd

Browse files
committed
sourceFiles
1 parent ad7bf6c commit 5d4c8dd

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

internal/cmd/generate.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ func readConfig(stderr io.Writer, dir, filename string) (string, *config.Config,
131131
return configPath, &conf, nil
132132
}
133133

134-
// GenerateInputs holds in-memory config and optional file contents so generate can run
134+
// sourceFiles holds in-memory config and optional file contents so generate can run
135135
// without reading from disk (e.g. in tests). For production, Generate reads from FS and
136136
// fills FileContents before calling generate.
137-
type GenerateInputs struct {
138-
Config *config.Config
139-
ConfigPath string
140-
Dir string
137+
type sourceFiles struct {
138+
Config *config.Config
139+
ConfigPath string
140+
Dir string
141141
FileContents map[string][]byte // path -> content; keys match paths used when reading (e.g. filepath.Join(dir, "schema.sql"))
142142
}
143143

@@ -166,7 +166,7 @@ func Generate(ctx context.Context, dir, filename string, o *Options) (map[string
166166
return remoteGenerate(ctx, configPath, conf, dir, stderr)
167167
}
168168

169-
inputs := &GenerateInputs{Config: conf, ConfigPath: configPath, Dir: dir}
169+
inputs := &sourceFiles{Config: conf, ConfigPath: configPath, Dir: dir}
170170
inputs.FileContents, err = loadFileContentsFromFS(conf, dir)
171171
if err != nil {
172172
return nil, err
@@ -176,7 +176,7 @@ func Generate(ctx context.Context, dir, filename string, o *Options) (map[string
176176

177177
// generate performs codegen using in-memory inputs. It is used by Generate (with contents
178178
// loaded from disk) and by tests (with pre-filled Config and FileContents, no temp files).
179-
func generate(ctx context.Context, inputs *GenerateInputs, o *Options) (map[string]string, error) {
179+
func generate(ctx context.Context, inputs *sourceFiles, o *Options) (map[string]string, error) {
180180
g := &generator{
181181
dir: inputs.Dir,
182182
output: map[string]string{},
@@ -228,9 +228,9 @@ func loadFileContentsFromFS(conf *config.Config, dir string) (map[string][]byte,
228228
}
229229

230230
type generator struct {
231-
m sync.Mutex
232-
dir string
233-
output map[string]string
231+
m sync.Mutex
232+
dir string
233+
output map[string]string
234234
codegenHandlerOverride grpc.ClientConnInterface
235235
}
236236

internal/cmd/plugin_engine_path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var defaultCommentSyntax = metadata.CommentSyntax(source.CommentSyntax{Dash: tru
2929
// engine plugin via ParseRequest; the responses are turned into compiler.Result and
3030
// passed to ProcessResult. No AST or compiler parsing is used.
3131
// When inputs.FileContents is set, schema/query bytes are taken from it (no disk read).
32-
func runPluginQuerySet(ctx context.Context, rp ResultProcessor, name, dir string, sql OutputPair, combo config.CombinedSettings, inputs *GenerateInputs, o *Options) error {
32+
func runPluginQuerySet(ctx context.Context, rp ResultProcessor, name, dir string, sql OutputPair, combo config.CombinedSettings, inputs *sourceFiles, o *Options) error {
3333
enginePlugin, found := config.FindEnginePlugin(&combo.Global, string(combo.Package.Engine))
3434
if !found || enginePlugin.Process == nil {
3535
e := string(combo.Package.Engine)

internal/cmd/plugin_engine_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestPluginPipeline_FullPipeline(t *testing.T) {
120120
t.Fatalf("parse config: %v", err)
121121
}
122122

123-
inputs := &GenerateInputs{
123+
inputs := &sourceFiles{
124124
Config: &conf,
125125
ConfigPath: "sqlc.yaml",
126126
Dir: ".",
@@ -231,7 +231,7 @@ func TestPluginPipeline_WithoutOverride_UsesPluginPackage(t *testing.T) {
231231
if err != nil {
232232
t.Fatalf("parse config: %v", err)
233233
}
234-
inputs := &GenerateInputs{
234+
inputs := &sourceFiles{
235235
Config: &conf,
236236
ConfigPath: "sqlc.yaml",
237237
Dir: ".",

internal/cmd/process.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ func Process(ctx context.Context, rp ResultProcessor, dir, filename string, o *O
5151
return err
5252
}
5353

54-
inputs := &GenerateInputs{Config: conf, ConfigPath: configPath, Dir: dir}
54+
inputs := &sourceFiles{Config: conf, ConfigPath: configPath, Dir: dir}
5555
return processQuerySets(ctx, rp, inputs, o)
5656
}
5757

58-
func processQuerySets(ctx context.Context, rp ResultProcessor, inputs *GenerateInputs, o *Options) error {
58+
func processQuerySets(ctx context.Context, rp ResultProcessor, inputs *sourceFiles, o *Options) error {
5959
stderr := o.Stderr
6060
conf := inputs.Config
6161
dir := inputs.Dir

0 commit comments

Comments
 (0)