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

Method loadLegacyDefaultPathArg

core/modfunc.go:1185–1252  ·  view source on GitHub ↗

loadLegacyDefaultPathArg resolves a +defaultPath argument from the workspace root instead of the module's own source directory. Used for legacy blueprints/toolchains that relied on ContextSource injection.

(
	ctx context.Context,
	dag *dagql.Server,
	arg *FunctionArg,
)

Source from the content-addressed store, hash-verified

1183// root instead of the module's own source directory. Used for legacy
1184// blueprints/toolchains that relied on ContextSource injection.
1185func (fn *ModuleFunction) loadLegacyDefaultPathArg(
1186 ctx context.Context,
1187 dag *dagql.Server,
1188 arg *FunctionArg,
1189) (dagql.IDType, error) {
1190 switch arg.TypeDef.Self().AsObject.Value.Self().Name {
1191 case "Directory":
1192 var dir dagql.ObjectResult[*Directory]
1193 err := dag.Select(ctx, dag.Root(), &dir,
1194 dagql.Selector{
1195 Field: "currentWorkspace",
1196 Args: []dagql.NamedInput{
1197 {Name: "skipMigrationCheck", Value: dagql.Boolean(true)},
1198 },
1199 },
1200 dagql.Selector{
1201 Field: "directory",
1202 Args: []dagql.NamedInput{
1203 {Name: "path", Value: dagql.String(arg.DefaultPath)},
1204 {Name: "exclude", Value: dagql.ArrayInput[dagql.String](dagql.NewStringArray(arg.Ignore...))},
1205 },
1206 },
1207 )
1208 if err != nil {
1209 return nil, fmt.Errorf("load legacy default directory %q: %w", arg.DefaultPath, err)
1210 }
1211 dirID, err := dir.ID()
1212 if err != nil {
1213 return nil, fmt.Errorf("get legacy default directory ID %q: %w", arg.DefaultPath, err)
1214 }
1215 return dagql.NewID[*Directory](dirID), nil
1216
1217 case "File":
1218 var f dagql.ObjectResult[*File]
1219 err := dag.Select(ctx, dag.Root(), &f,
1220 dagql.Selector{
1221 Field: "currentWorkspace",
1222 Args: []dagql.NamedInput{
1223 {Name: "skipMigrationCheck", Value: dagql.Boolean(true)},
1224 },
1225 },
1226 dagql.Selector{
1227 Field: "file",
1228 Args: []dagql.NamedInput{
1229 {Name: "path", Value: dagql.String(arg.DefaultPath)},
1230 },
1231 },
1232 )
1233 if err != nil {
1234 return nil, fmt.Errorf("load legacy default file %q: %w", arg.DefaultPath, err)
1235 }
1236 fileID, err := f.ID()
1237 if err != nil {
1238 return nil, fmt.Errorf("get legacy default file ID %q: %w", arg.DefaultPath, err)
1239 }
1240 return dagql.NewID[*File](fileID), nil
1241
1242 case "GitRepository", "GitRef":

Callers 1

loadContextualArgMethod · 0.95

Calls 8

loadContextualGitArgMethod · 0.95
BooleanTypeAlias · 0.92
StringTypeAlias · 0.92
NewStringArrayFunction · 0.92
SelfMethod · 0.80
SelectMethod · 0.65
IDMethod · 0.65
RootMethod · 0.45

Tested by

no test coverage detected