MCPcopy Create free account
hub / github.com/dagger/dagger / loadContextFromEnv

Method loadContextFromEnv

core/modulesource.go:1277–1313  ·  view source on GitHub ↗
(
	ctx context.Context,
	dag *dagql.Server,
	env dagql.ObjectResult[*Env],
	path string,
	filterInputs []dagql.NamedInput,
)

Source from the content-addressed store, hash-verified

1275}
1276
1277func (src *ModuleSource) loadContextFromEnv(
1278 ctx context.Context,
1279 dag *dagql.Server,
1280 env dagql.ObjectResult[*Env],
1281 path string,
1282 filterInputs []dagql.NamedInput,
1283) (inst dagql.ObjectResult[*Directory], err error) {
1284 // If path is not absolute, it's relative to the module root directory.
1285 // If path is absolute, it's relative to the context directory.
1286 if !filepath.IsAbs(path) {
1287 path = filepath.Join(src.SourceRootSubpath, path)
1288 }
1289 sels := []dagql.Selector{
1290 {
1291 Field: "workspace",
1292 },
1293 }
1294 if path != "." {
1295 sels = append(sels, dagql.Selector{
1296 Field: "directory",
1297 Args: []dagql.NamedInput{
1298 {Name: "path", Value: dagql.String(path)},
1299 },
1300 })
1301 }
1302 if len(filterInputs) > 0 {
1303 sels = append(sels, dagql.Selector{
1304 Field: "filter",
1305 Args: filterInputs,
1306 })
1307 }
1308 err = dag.Select(ctx, env, &inst, sels...)
1309 if err != nil {
1310 return inst, fmt.Errorf("failed to select env directory: %w", err)
1311 }
1312 return inst, nil
1313}
1314
1315func (src *ModuleSource) loadContextFromSource(
1316 ctx context.Context,

Callers 1

LoadContextDirMethod · 0.95

Calls 2

StringTypeAlias · 0.92
SelectMethod · 0.65

Tested by

no test coverage detected