LoadContextDir loads addition files+directories from the module source's context, including those that may have not been included in the original module source load.
( ctx context.Context, dag *dagql.Server, path string, filter CopyFilter, )
| 1202 | // LoadContextDir loads addition files+directories from the module source's context, including those that |
| 1203 | // may have not been included in the original module source load. |
| 1204 | func (src *ModuleSource) LoadContextDir( |
| 1205 | ctx context.Context, |
| 1206 | dag *dagql.Server, |
| 1207 | path string, |
| 1208 | filter CopyFilter, |
| 1209 | ) (inst dagql.ObjectResult[*Directory], err error) { |
| 1210 | filterInputs := []dagql.NamedInput{} |
| 1211 | if len(filter.Include) > 0 { |
| 1212 | filterInputs = append(filterInputs, dagql.NamedInput{ |
| 1213 | Name: "include", |
| 1214 | Value: dagql.ArrayInput[dagql.String](dagql.NewStringArray(filter.Include...)), |
| 1215 | }) |
| 1216 | } |
| 1217 | if len(filter.Exclude) > 0 { |
| 1218 | filterInputs = append(filterInputs, dagql.NamedInput{ |
| 1219 | Name: "exclude", |
| 1220 | Value: dagql.ArrayInput[dagql.String](dagql.NewStringArray(filter.Exclude...)), |
| 1221 | }) |
| 1222 | } |
| 1223 | if filter.Gitignore { |
| 1224 | filterInputs = append(filterInputs, dagql.NamedInput{ |
| 1225 | Name: "gitignore", |
| 1226 | Value: dagql.NewBoolean(true), |
| 1227 | }) |
| 1228 | } |
| 1229 | |
| 1230 | // Check if there's an Env - if so, use its workspace as the context for |
| 1231 | // defaultPath arguments. |
| 1232 | // |
| 1233 | // NOTE: this applies unilaterally, whether the module was loaded from Host, |
| 1234 | // Git, or a Directory. |
| 1235 | env, ok, envErr := EnvFromContext(ctx) |
| 1236 | if envErr != nil { |
| 1237 | return inst, envErr |
| 1238 | } |
| 1239 | if ok { |
| 1240 | inst, err = src.loadContextFromEnv(ctx, dag, env, path, filterInputs) |
| 1241 | } else { |
| 1242 | inst, err = src.loadContextFromSource(ctx, dag, path, filterInputs) |
| 1243 | } |
| 1244 | if err != nil { |
| 1245 | return inst, err |
| 1246 | } |
| 1247 | instID, err := inst.ID() |
| 1248 | if err != nil { |
| 1249 | return inst, fmt.Errorf("context directory ID: %w", err) |
| 1250 | } |
| 1251 | instCall, err := inst.ResultCall() |
| 1252 | if err != nil { |
| 1253 | return inst, fmt.Errorf("context directory call: %w", err) |
| 1254 | } |
| 1255 | if instID != nil && instCall.ContentDigest() == "" { |
| 1256 | snapshot, err := inst.Self().Snapshot.GetOrEval(ctx, inst.Result) |
| 1257 | if err != nil { |
| 1258 | return inst, fmt.Errorf("context directory snapshot: %w", err) |
| 1259 | } |
| 1260 | dirPath, err := inst.Self().Dir.GetOrEval(ctx, inst.Result) |
| 1261 | if err != nil { |
no test coverage detected