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

Function inspectModule

cmd/dagger/module_inspect.go:192–289  ·  view source on GitHub ↗
(ctx context.Context, dag *dagger.Client, source *dagger.ModuleSource)

Source from the content-addressed store, hash-verified

190var loadTypeDefsQuery string
191
192func inspectModule(ctx context.Context, dag *dagger.Client, source *dagger.ModuleSource) (rdef *moduleDef, rerr error) {
193 ctx, span := Tracer().Start(ctx, "inspecting module metadata", telemetry.Encapsulate())
194 defer telemetry.EndWithCause(span, &rerr)
195
196 // NB: All we need most of the time is the name of the dependencies.
197 // We need the descriptions when listing the dependencies, and the source
198 // ref if we need to load a specific dependency. However getting the refs
199 // and descriptions here, at module load, doesn't add much overhead and
200 // makes it easier (and faster) later.
201
202 var res struct {
203 Source struct {
204 Kind dagger.ModuleSourceKind
205 Digest string
206 AsString string
207 SourceRootSubpath string
208 Commit string
209 Version string
210 HTMLRepoURL string
211 Module struct {
212 Name string
213 Description string
214 Dependencies []struct {
215 Name string
216 Description string
217 Source struct {
218 ID dagger.ID
219 AsString string
220 Digest string
221 }
222 }
223 }
224 }
225 }
226
227 id, err := source.ID(ctx)
228 if err != nil {
229 return nil, err
230 }
231
232 err = dag.Do(ctx, &dagger.Request{
233 Query: loadModConfQuery,
234 Variables: map[string]any{
235 "source": id,
236 },
237 }, &dagger.Response{
238 Data: &res,
239 })
240 if err != nil {
241 return nil, fmt.Errorf("query module metadata: %w", err)
242 }
243
244 deps := make([]*moduleDef, 0, len(res.Source.Module.Dependencies))
245 for _, dep := range res.Source.Module.Dependencies {
246 deps = append(deps, &moduleDef{
247 Name: dep.Name,
248 Description: dep.Description,
249 SourceRoot: dep.Source.AsString,

Callers 2

initializeModuleFunction · 0.70
loadToolchainInfoFunction · 0.70

Calls 8

EncapsulateMethod · 0.80
SetAttributesMethod · 0.80
TracerFunction · 0.70
StartMethod · 0.65
IDMethod · 0.65
StringMethod · 0.65
DoMethod · 0.45
RefMethod · 0.45

Tested by

no test coverage detected