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

Method serveModule

engine/server/session.go:1569–1581  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1567//
1568// Not threadsafe: client.stateMu must be held when calling.
1569func (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.

Callers 2

ServeModuleMethod · 0.95

Calls 7

isSameModuleReferenceFunction · 0.85
NameMethod · 0.65
GetSourceMethod · 0.65
LookupMethod · 0.45
AsStringMethod · 0.45
PinMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected