buildScaleOutModuleQuery builds a query to load a module for scale-out execution. It handles all module source kinds (Local, Git, Dir) and returns a query positioned at the "asModule" selection, ready for check/generator-specific queries.
(query *querybuilder.Selection)
| 506 | // It handles all module source kinds (Local, Git, Dir) and returns a query |
| 507 | // positioned at the "asModule" selection, ready for check/generator-specific queries. |
| 508 | func (node *ModTreeNode) buildScaleOutModuleQuery(query *querybuilder.Selection) (*querybuilder.Selection, error) { |
| 509 | mod := node.Module.Self() |
| 510 | if mod == nil { |
| 511 | return nil, fmt.Errorf("build scale-out module query: missing module") |
| 512 | } |
| 513 | modSrc := mod.Source.Value.Self() |
| 514 | switch modSrc.Kind { |
| 515 | case ModuleSourceKindLocal: |
| 516 | query = query.Select("moduleSource"). |
| 517 | Arg("refString", filepath.Join( |
| 518 | modSrc.Local.ContextDirectoryPath, |
| 519 | modSrc.SourceRootSubpath, |
| 520 | )) |
| 521 | case ModuleSourceKindGit: |
| 522 | query = query.Select("moduleSource"). |
| 523 | Arg("refString", modSrc.AsString()). |
| 524 | Arg("refPin", modSrc.Git.Commit). |
| 525 | Arg("requireKind", modSrc.Kind) |
| 526 | case ModuleSourceKindDir: |
| 527 | dirID, err := modSrc.DirSrc.OriginalContextDir.ID() |
| 528 | if err != nil { |
| 529 | return nil, fmt.Errorf("get dir ID: %w", err) |
| 530 | } |
| 531 | dirIDEnc, err := dirID.Encode() |
| 532 | if err != nil { |
| 533 | return nil, fmt.Errorf("encode dir ID: %w", err) |
| 534 | } |
| 535 | query = query.Select("node").Arg("id", dirIDEnc).InlineFragment("Directory") |
| 536 | query = query.Select("asModuleSource"). |
| 537 | Arg("sourceRootPath", modSrc.DirSrc.OriginalSourceRootSubpath) |
| 538 | } |
| 539 | query = query.Select("asModule") |
| 540 | if mod.Name() != "" && mod.Name() != modSrc.ModuleName { |
| 541 | query = query.Arg("legacyNameOverride", mod.Name()) |
| 542 | } |
| 543 | if mod.LegacyDefaultPath { |
| 544 | query = query.Arg("legacyDefaultPath", true) |
| 545 | } |
| 546 | if mod.ContextSource.Valid { |
| 547 | contextSrc := mod.ContextSource.Value.Self() |
| 548 | if contextSrc != nil { |
| 549 | contextRef := contextSrc.AsString() |
| 550 | if contextRef != "" && (contextRef != modSrc.AsString() || contextSrc.Pin() != modSrc.Pin()) { |
| 551 | query = query.Arg("defaultPathContextSourceRef", contextRef) |
| 552 | if contextPin := contextSrc.Pin(); contextPin != "" { |
| 553 | query = query.Arg("defaultPathContextSourcePin", contextPin) |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | if len(mod.WorkspaceConfig) > 0 { |
| 559 | workspaceConfigJSON, err := json.Marshal(mod.WorkspaceConfig) |
| 560 | if err != nil { |
| 561 | return nil, fmt.Errorf("encode workspace config: %w", err) |
| 562 | } |
| 563 | query = query.Arg("legacyWorkspaceConfigJson", string(workspaceConfigJSON)) |
| 564 | if mod.DefaultsFromDotEnv { |
| 565 | query = query.Arg("legacyDefaultsFromDotEnv", true) |