Skip to content

Commit e02fdfb

Browse files
fix: bug where plan phase was not using the customizations folder (#1195)
fix: bug where forward slash "/" was hardcoded in the path of the default qamappings file, causing file not exist error and a crash on Windows (Windows uses back slash) Signed-off-by: Harikrishnan Balagopal <[email protected]>
1 parent c1a0f8a commit e02fdfb

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

cmd/utils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Exiting.`, outpath, overwriteFlag, outputFlag)
8989
func getCustomMappingFilePath() (qaenginetypes.QAMappings, error) {
9090
// Read the QA categories from the QA mapping file
9191
var qaMapping qaenginetypes.QAMappings
92-
customizationsDir := filepath.Join(common.AssetsPath, "custom")
92+
customizationsDir := filepath.Join(common.AssetsPath, common.AssetsCustomizationsDir)
9393
_, err := os.Stat(customizationsDir)
9494
if err == nil {
9595
yamlPaths, err := common.GetFilesByExt(customizationsDir, []string{".yml", ".yaml"})
@@ -113,7 +113,7 @@ func getCustomMappingFilePath() (qaenginetypes.QAMappings, error) {
113113
}
114114
}
115115
logrus.Infof("Using the default QA mappings file")
116-
qaMappingFilepath := filepath.Join("built-in/qa", "qamappings.yaml")
116+
qaMappingFilepath := filepath.Join("built-in", "qa", "qamappings.yaml")
117117
file, err := assets.AssetsDir.ReadFile(qaMappingFilepath)
118118
if err != nil {
119119
return qaMapping, fmt.Errorf("failed to read the mappings file metadata from the yaml file at path '%s' . Error: %w", qaMappingFilepath, err)

common/constants.go

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ const (
6060
ShExt = ".sh"
6161
// BatExt is the extension of bat file
6262
BatExt = ".bat"
63+
// AssetsCustomizationsDir is a directory inside the assets directory
64+
// where the user given customizations are copied to.
65+
AssetsCustomizationsDir = "custom"
6366
// RemoteSourcesFolder stores remote sources
6467
RemoteSourcesFolder = "m2ksources"
6568
// RemoteCustomizationsFolder stores remote customizations

lib/planner.go

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func CreatePlan(ctx context.Context, inputPath, outputPath string, customization
5454
if remoteOutputFSPath != "" {
5555
outputFSPath = remoteOutputFSPath
5656
}
57+
if customizationsPath != "" {
58+
if err := CheckAndCopyCustomizations(customizationsPath); err != nil {
59+
return plan, fmt.Errorf("failed to check and copy the customizations. Error: %w", err)
60+
}
61+
}
5762
transformerSelectorObj, err := metav1.ParseToLabelSelector(transformerSelector)
5863
if err != nil {
5964
return plan, fmt.Errorf("failed to parse the string '%s' as a transformer selector. Error: %w", transformerSelector, err)

lib/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func CopyCustomizationsAssetsData(customizationsPath string) (err error) {
8484
if err != nil {
8585
return fmt.Errorf("failed to make the assets path '%s' absolute. Error: %w", assetsPath, err)
8686
}
87-
customizationsAssetsPath := filepath.Join(assetsPath, "custom")
87+
customizationsAssetsPath := filepath.Join(assetsPath, common.AssetsCustomizationsDir)
8888

8989
// Create the subdirectory and copy the assets into it.
9090
if err = os.MkdirAll(customizationsAssetsPath, common.DefaultDirectoryPermission); err != nil {

0 commit comments

Comments
 (0)