MCPcopy Index your code
hub / github.com/dagger/dagger / externalSDKForModule

Method externalSDKForModule

core/sdk/loader.go:87–122  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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.
87func (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
124func (l *Loader) namedSDK(
125 ctx context.Context,

Callers 1

SDKForModuleMethod · 0.95

Calls 8

ResolveDepToSourceFunction · 0.92
OptFunction · 0.92
BooleanTypeAlias · 0.92
newModuleSDKFunction · 0.85
SelfMethod · 0.80
EngineMethod · 0.65
ServerMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected