loadModInfo loads the module's metadata.
(ctx context.Context, m *PythonSdk)
| 199 | |
| 200 | // loadModInfo loads the module's metadata. |
| 201 | func (d *Discovery) loadModInfo(ctx context.Context, m *PythonSdk) error { |
| 202 | eg, gctx := errgroup.WithContext(ctx) |
| 203 | |
| 204 | doneSubPath := make(chan struct{}) |
| 205 | |
| 206 | eg.Go(func() error { |
| 207 | defer close(doneSubPath) |
| 208 | p, err := m.ModSource.SourceSubpath(gctx) |
| 209 | if err != nil { |
| 210 | return fmt.Errorf("get module source subpath: %w", err) |
| 211 | } |
| 212 | d.mu.Lock() |
| 213 | m.SubPath = p |
| 214 | d.mu.Unlock() |
| 215 | return nil |
| 216 | }) |
| 217 | |
| 218 | eg.Go(func() error { |
| 219 | // m.Source() depends on SubPath |
| 220 | <-doneSubPath |
| 221 | entries, _ := m.Source().Entries(gctx) |
| 222 | d.mu.Lock() |
| 223 | for _, entry := range entries { |
| 224 | d.FileSet[entry] = struct{}{} |
| 225 | } |
| 226 | d.mu.Unlock() |
| 227 | return nil |
| 228 | }) |
| 229 | |
| 230 | eg.Go(func() error { |
| 231 | dig, err := m.ModSource.Digest(gctx) |
| 232 | if err != nil { |
| 233 | return fmt.Errorf("get module source digest: %w", err) |
| 234 | } |
| 235 | d.mu.Lock() |
| 236 | m.ContextDirPath = path.Join(ModSourceDirPath, dig) |
| 237 | d.mu.Unlock() |
| 238 | return nil |
| 239 | }) |
| 240 | |
| 241 | eg.Go(func() error { |
| 242 | modName, err := m.ModSource.ModuleOriginalName(gctx) |
| 243 | if err != nil { |
| 244 | return fmt.Errorf("get module name: %w", err) |
| 245 | } |
| 246 | d.mu.Lock() |
| 247 | m.ModName = modName |
| 248 | m.MainObjectName = NormalizeObjectName(modName) |
| 249 | m.ProjectName = NormalizeProjectNameFromModule(modName) |
| 250 | m.PackageName = NormalizePackageName(m.ProjectName) |
| 251 | d.mu.Unlock() |
| 252 | return nil |
| 253 | }) |
| 254 | |
| 255 | // TODO: Provide runtime modules with a boolean to indicate whether the |
| 256 | // module is new or not. Could be `dagger init --sdk` or `dagger develop --sdk`. |
| 257 | // |
| 258 | // With `dagger init` we can check for the presence of the dagger.json file, |
nothing calls this directly
no test coverage detected