(
ctx context.Context,
src *core.ModuleSource,
args struct {
Patterns []string
},
)
| 1256 | } |
| 1257 | |
| 1258 | func (s *moduleSourceSchema) moduleSourceWithIncludes( |
| 1259 | ctx context.Context, |
| 1260 | src *core.ModuleSource, |
| 1261 | args struct { |
| 1262 | Patterns []string |
| 1263 | }, |
| 1264 | ) (*core.ModuleSource, error) { |
| 1265 | if len(args.Patterns) == 0 { |
| 1266 | return src, nil |
| 1267 | } |
| 1268 | |
| 1269 | src = src.Clone() |
| 1270 | src.IncludePaths = append(src.IncludePaths, args.Patterns...) |
| 1271 | rebasedIncludes, err := rebasePatterns(args.Patterns, src.SourceRootSubpath) |
| 1272 | if err != nil { |
| 1273 | return nil, fmt.Errorf("failed to rebase include paths: %w", err) |
| 1274 | } |
| 1275 | src.RebasedIncludePaths = append(src.RebasedIncludePaths, rebasedIncludes...) |
| 1276 | |
| 1277 | // reload context in case includes have changed it |
| 1278 | err = s.loadModuleSourceContext(ctx, src) |
| 1279 | switch { |
| 1280 | case err == nil: |
| 1281 | case codes.NotFound == status.Code(err) && src.Kind == core.ModuleSourceKindLocal: |
| 1282 | // corner case: dagger init can be called on a context dir that doesn't exist yet |
| 1283 | // (e.g. called outside a .git context and the source root dir doesn't exist because |
| 1284 | // it's expected to be created when exporting the generated context dir) |
| 1285 | // we tolerate a not found error in this case |
| 1286 | default: |
| 1287 | return nil, fmt.Errorf("failed to reload module source context: %w", err) |
| 1288 | } |
| 1289 | |
| 1290 | return src, nil |
| 1291 | } |
| 1292 | |
| 1293 | func (s *moduleSourceSchema) moduleSourceWithSDK( |
| 1294 | ctx context.Context, |
nothing calls this directly
no test coverage detected