Load an SDK module from an external source (not builtin to the engine). This will first resolve the path to this SDK module, either from Git or from a local path and load it as a module.
( ctx context.Context, query *core.Query, sdk *core.SDKConfig, parentSrc *core.ModuleSource, )
| 85 | // This will first resolve the path to this SDK module, either from Git |
| 86 | // or from a local path and load it as a module. |
| 87 | func (l *Loader) externalSDKForModule( |
| 88 | ctx context.Context, |
| 89 | query *core.Query, |
| 90 | sdk *core.SDKConfig, |
| 91 | parentSrc *core.ModuleSource, |
| 92 | ) (core.SDK, error) { |
| 93 | bk, err := query.Engine(ctx) |
| 94 | if err != nil { |
| 95 | return nil, fmt.Errorf("failed to get engine client for sdk %s: %w", sdk.Source, err) |
| 96 | } |
| 97 | dag, err := query.Server.Server(ctx) |
| 98 | if err != nil { |
| 99 | return nil, fmt.Errorf("failed to get dag for sdk %s: %w", sdk.Source, err) |
| 100 | } |
| 101 | |
| 102 | sdkModSrc, err := core.ResolveDepToSource(ctx, bk, dag, parentSrc, sdk.Source, "", "") |
| 103 | if err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | |
| 107 | if !sdkModSrc.Self().ConfigExists { |
| 108 | return nil, fmt.Errorf("sdk module source has no dagger.json") |
| 109 | } |
| 110 | |
| 111 | var sdkMod dagql.ObjectResult[*core.Module] |
| 112 | err = dag.Select(ctx, sdkModSrc, &sdkMod, |
| 113 | dagql.Selector{Field: "asModule", Args: []dagql.NamedInput{ |
| 114 | {Name: "forceDefaultFunctionCaching", Value: dagql.Opt(dagql.Boolean(true))}, |
| 115 | }}, |
| 116 | ) |
| 117 | if err != nil { |
| 118 | return nil, fmt.Errorf("failed to load sdk module %q: %w", sdk.Source, err) |
| 119 | } |
| 120 | |
| 121 | return newModuleSDK(ctx, query, sdkMod, dagql.ObjectResult[*core.Directory]{}, sdk.Config) |
| 122 | } |
| 123 | |
| 124 | func (l *Loader) namedSDK( |
| 125 | ctx context.Context, |
no test coverage detected