WE DO NOT FILTER IF WE ALREADY FILTERED ON BUILDING OF A WORKSPACE Also, paths are still external paths at this point if this came from a workspace TODO FUTURE: redo functionOptions, this is a mess
( image bufimage.Image, functionOptions *functionOptions, imageCameFromAWorkspace bool, )
| 1423 | // Also, paths are still external paths at this point if this came from a workspace |
| 1424 | // TODO FUTURE: redo functionOptions, this is a mess |
| 1425 | func filterImage( |
| 1426 | image bufimage.Image, |
| 1427 | functionOptions *functionOptions, |
| 1428 | imageCameFromAWorkspace bool, |
| 1429 | ) (bufimage.Image, error) { |
| 1430 | newImage := image |
| 1431 | var err error |
| 1432 | if functionOptions.imageExcludeImports { |
| 1433 | newImage = bufimage.ImageWithoutImports(newImage) |
| 1434 | } |
| 1435 | includeTypes := functionOptions.imageIncludeTypes |
| 1436 | excludeTypes := functionOptions.imageExcludeTypes |
| 1437 | if len(includeTypes) > 0 || len(excludeTypes) > 0 { |
| 1438 | newImage, err = bufimageutil.FilterImage( |
| 1439 | newImage, |
| 1440 | bufimageutil.WithIncludeTypes(includeTypes...), |
| 1441 | bufimageutil.WithExcludeTypes(excludeTypes...), |
| 1442 | bufimageutil.WithMutateInPlace(), |
| 1443 | ) |
| 1444 | if err != nil { |
| 1445 | return nil, err |
| 1446 | } |
| 1447 | } |
| 1448 | if !imageCameFromAWorkspace { |
| 1449 | if len(functionOptions.targetPaths) > 0 || len(functionOptions.targetExcludePaths) > 0 { |
| 1450 | // bufimage expects normalized paths, so we need to normalize the paths |
| 1451 | // from functionOptions before passing them through. |
| 1452 | normalizedTargetPaths := make([]string, 0, len(functionOptions.targetPaths)) |
| 1453 | normalizedExcludePaths := make([]string, 0, len(functionOptions.targetExcludePaths)) |
| 1454 | for _, targetPath := range functionOptions.targetPaths { |
| 1455 | normalizedTargetPaths = append(normalizedTargetPaths, normalpath.Normalize(targetPath)) |
| 1456 | } |
| 1457 | for _, excludePath := range functionOptions.targetExcludePaths { |
| 1458 | normalizedExcludePaths = append(normalizedExcludePaths, normalpath.Normalize(excludePath)) |
| 1459 | } |
| 1460 | // TODO FUTURE: allowNotExist? Also, does this affect lint or breaking? |
| 1461 | newImage, err = bufimage.ImageWithOnlyPathsAllowNotExist( |
| 1462 | newImage, |
| 1463 | normalizedTargetPaths, |
| 1464 | normalizedExcludePaths, |
| 1465 | ) |
| 1466 | if err != nil { |
| 1467 | return nil, err |
| 1468 | } |
| 1469 | } |
| 1470 | } |
| 1471 | return newImage, nil |
| 1472 | } |
| 1473 | |
| 1474 | func newStorageosProvider(disableSymlinks bool) storageos.Provider { |
| 1475 | var options []storageos.ProviderOption |
no test coverage detected
searching dependent graphs…