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

Method SDKForModule

core/sdk/loader.go:41–81  ·  view source on GitHub ↗

SDKForModule loads an SDK module based on the given SDK configuration. If it's a builtin SDK, it will load it from the engine container. Otherwise, it will load it from the given source either from a URL or from a local path.

(
	ctx context.Context,
	query *core.Query,
	sdk *core.SDKConfig,
	parentSrc *core.ModuleSource,
)

Source from the content-addressed store, hash-verified

39// Otherwise, it will load it from the given source either from a URL
40// or from a local path.
41func (l *Loader) SDKForModule(
42 ctx context.Context,
43 query *core.Query,
44 sdk *core.SDKConfig,
45 parentSrc *core.ModuleSource,
46) (_ core.SDK, rerr error) {
47 if sdk == nil {
48 return nil, errMissingSDKRef
49 }
50
51 ctx, span := core.Tracer(ctx).Start(ctx, fmt.Sprintf("load SDK: %s", sdk.Source))
52 defer telemetry.EndWithCause(span, &rerr)
53
54 builtinSDK, builtinErr := l.namedSDK(ctx, query, sdk)
55 if builtinErr == nil {
56 return builtinSDK, nil
57 } else if !errors.Is(builtinErr, errUnknownBuiltinSDK) {
58 return nil, builtinErr
59 }
60
61 extSDK, extErr := l.externalSDKForModule(ctx, query, sdk, parentSrc)
62 if extErr == nil {
63 return extSDK, nil
64 }
65
66 stdio := telemetry.SpanStdio(ctx, "dagger.io/core/sdk")
67 fmt.Fprintf(stdio.Stderr, "Could not load SDK %q.\n", sdk.Source)
68 fmt.Fprintln(stdio.Stderr)
69 fmt.Fprintln(stdio.Stderr, "Errors:")
70 fmt.Fprintln(stdio.Stderr, "-", builtinErr)
71 fmt.Fprintln(stdio.Stderr, "-", extErr)
72 fmt.Fprintln(stdio.Stderr)
73 fmt.Fprintln(stdio.Stderr, "The available SDKs are:")
74 for _, sdk := range validInbuiltSDKs {
75 fmt.Fprintln(stdio.Stderr, "-", sdk)
76 }
77 fmt.Fprintln(stdio.Stderr, "- any git module ref, e.g. github.com/dagger/dagger/sdk/elixir@main")
78 fmt.Fprintln(stdio.Stderr, "- any local module path, e.g. ./my-sdk")
79
80 return nil, fmt.Errorf("invalid SDK: %q", sdk.Source)
81}
82
83// Load an SDK module from an external source (not builtin to the engine).
84//

Callers 7

namedSDKMethod · 0.95
initFunction · 0.80
localModuleSourceMethod · 0.80
gitModuleSourceMethod · 0.80
moduleSourceWithSDKMethod · 0.80
runClientGeneratorMethod · 0.80

Calls 5

namedSDKMethod · 0.95
externalSDKForModuleMethod · 0.95
TracerFunction · 0.92
IsMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected