(ctx context.Context, dag *dagger.Client, source *dagger.ModuleSource)
| 190 | var loadTypeDefsQuery string |
| 191 | |
| 192 | func 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, |
no test coverage detected