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

Method Initialize

cmd/dagger/shell.go:195–263  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

193}
194
195func (h *shellCallHandler) Initialize(ctx context.Context) error {
196 r, err := interp.New(
197 interp.Params("-e", "-u", "-o", "pipefail"),
198 interp.CallHandler(h.Call),
199 interp.ExecHandlers(h.Exec),
200
201 // The "Interactive" option is useful even when not running dagger shell
202 // in interactive mode. It expands aliases and maybe more in the future.
203 interp.Interactive(true),
204 )
205 if err != nil {
206 return err
207 }
208 h.runner = r
209
210 // collect initial env + vars
211 h.runner.Reset()
212
213 h.state = NewStateStore(h.runner)
214
215 // TODO: use `--workdir` and `--no-workdir` flags
216 var def *moduleDef
217 var cfg *configuredModule
218
219 if !h.noModule {
220 def, cfg, err = h.maybeLoadModule(ctx, h.moduleURL, dagger.ModuleServeOpts{Entrypoint: true})
221 if err != nil {
222 return err
223 }
224 }
225
226 // Could be `--no-mod` or module not found from current dir
227 if def == nil {
228 def, err = initializeCore(ctx, h.dag)
229 if err != nil {
230 return err
231 }
232 h.modDefs.Store("", def)
233 }
234
235 subpath := h.moduleURL
236 if cfg != nil {
237 subpath = cfg.Subpath
238 }
239
240 wd, err := h.newWorkdir(ctx, def, subpath)
241 if err != nil {
242 return fmt.Errorf("initial context: %w", err)
243 }
244
245 h.initwd = *wd
246 h.wd = h.initwd
247
248 // not h.Debug() on purpose because it's only set from within an interpreter run
249 if debugFlag {
250 slog := slog.SpanLogger(ctx, InstrumentationLibrary)
251 slog.Debug("initial workdir",
252 "context", h.initwd.Context,

Callers 4

RunAllMethod · 0.95
startMCPClientFunction · 0.80
TestLLMFileSyncingMethod · 0.80

Calls 11

maybeLoadModuleMethod · 0.95
newWorkdirMethod · 0.95
debugLoadedModulesMethod · 0.95
registerCommandsMethod · 0.95
SpanLoggerFunction · 0.92
DebugFunction · 0.92
NewStateStoreFunction · 0.85
initializeCoreFunction · 0.85
NewMethod · 0.65
ResetMethod · 0.45
StoreMethod · 0.45

Tested by 2

startMCPClientFunction · 0.64
TestLLMFileSyncingMethod · 0.64