serveModule adds a module to the client's served set with the given install policy. Not threadsafe: client.stateMu must be held when calling.
(client *daggerClient, mod core.Mod, opts core.InstallOpts)
| 1567 | // |
| 1568 | // Not threadsafe: client.stateMu must be held when calling. |
| 1569 | func (srv *Server) serveModule(client *daggerClient, mod core.Mod, opts core.InstallOpts) error { |
| 1570 | existing, ok := client.servedMods.Lookup(mod.Name()) |
| 1571 | if ok { |
| 1572 | if !isSameModuleReference(existing.GetSource(), mod.GetSource()) { |
| 1573 | return fmt.Errorf("module %s (source: %s | pin: %s) already exists with different source %s (pin: %s)", |
| 1574 | mod.Name(), mod.GetSource().AsString(), mod.GetSource().Pin(), existing.GetSource().AsString(), existing.GetSource().Pin(), |
| 1575 | ) |
| 1576 | } |
| 1577 | } |
| 1578 | // With handles deduplication and promotion internally. |
| 1579 | client.servedMods = client.servedMods.With(mod, opts) |
| 1580 | return nil |
| 1581 | } |
| 1582 | |
| 1583 | // Returns true if the module source a is the same as b or they come from the |
| 1584 | // core module. |