Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug where plan phase was not using the customizations folder #1195

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Exiting.`, outpath, overwriteFlag, outputFlag)
func getCustomMappingFilePath() (qaenginetypes.QAMappings, error) {
// Read the QA categories from the QA mapping file
var qaMapping qaenginetypes.QAMappings
customizationsDir := filepath.Join(common.AssetsPath, "custom")
customizationsDir := filepath.Join(common.AssetsPath, common.AssetsCustomizationsDir)
_, err := os.Stat(customizationsDir)
if err == nil {
yamlPaths, err := common.GetFilesByExt(customizationsDir, []string{".yml", ".yaml"})
Expand All @@ -113,7 +113,7 @@ func getCustomMappingFilePath() (qaenginetypes.QAMappings, error) {
}
}
logrus.Infof("Using the default QA mappings file")
qaMappingFilepath := filepath.Join("built-in/qa", "qamappings.yaml")
qaMappingFilepath := filepath.Join("built-in", "qa", "qamappings.yaml")
file, err := assets.AssetsDir.ReadFile(qaMappingFilepath)
if err != nil {
return qaMapping, fmt.Errorf("failed to read the mappings file metadata from the yaml file at path '%s' . Error: %w", qaMappingFilepath, err)
Expand Down
3 changes: 3 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const (
ShExt = ".sh"
// BatExt is the extension of bat file
BatExt = ".bat"
// AssetsCustomizationsDir is a directory inside the assets directory
// where the user given customizations are copied to.
AssetsCustomizationsDir = "custom"
// RemoteSourcesFolder stores remote sources
RemoteSourcesFolder = "m2ksources"
// RemoteCustomizationsFolder stores remote customizations
Expand Down
5 changes: 5 additions & 0 deletions lib/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func CreatePlan(ctx context.Context, inputPath, outputPath string, customization
if remoteOutputFSPath != "" {
outputFSPath = remoteOutputFSPath
}
if customizationsPath != "" {
if err := CheckAndCopyCustomizations(customizationsPath); err != nil {
return plan, fmt.Errorf("failed to check and copy the customizations. Error: %w", err)
}
}
transformerSelectorObj, err := metav1.ParseToLabelSelector(transformerSelector)
if err != nil {
return plan, fmt.Errorf("failed to parse the string '%s' as a transformer selector. Error: %w", transformerSelector, err)
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func CopyCustomizationsAssetsData(customizationsPath string) (err error) {
if err != nil {
return fmt.Errorf("failed to make the assets path '%s' absolute. Error: %w", assetsPath, err)
}
customizationsAssetsPath := filepath.Join(assetsPath, "custom")
customizationsAssetsPath := filepath.Join(assetsPath, common.AssetsCustomizationsDir)

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