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

bug: running Move2Kube transform on Windows machine throws an error about qamapping file not being present #1192

Closed
HarikrishnanBalagopal opened this issue Oct 17, 2024 · 3 comments · Fixed by #1195 or #1198
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. hacktoberfest kind/bug Categorizes issue or PR as related to a bug.

Comments

@HarikrishnanBalagopal
Copy link
Contributor

HarikrishnanBalagopal commented Oct 17, 2024

Overview

Running the Move2Kube CLI in a Windows 11 machine (inside Cygwin and Powershell) causes a crash.

move2kube/cmd/utils.go

Lines 89 to 125 in c1a0f8a

func getCustomMappingFilePath() (qaenginetypes.QAMappings, error) {
// Read the QA categories from the QA mapping file
var qaMapping qaenginetypes.QAMappings
customizationsDir := filepath.Join(common.AssetsPath, "custom")
_, err := os.Stat(customizationsDir)
if err == nil {
yamlPaths, err := common.GetFilesByExt(customizationsDir, []string{".yml", ".yaml"})
if err != nil {
return qaMapping, fmt.Errorf("failed to look for yaml files in the directory '%s' . Error: %w", customizationsDir, err)
}
for _, yamlPath := range yamlPaths {
if err := common.ReadMove2KubeYaml(yamlPath, &qaMapping); err != nil {
logrus.Debugf("failed to read the mappings file metadata from the yaml file at path '%s' . Error: %q", yamlPath, err)
continue
}
if qaMapping.Kind != qaenginetypes.QAMappingsKind {
logrus.Debugf(
"the file at path '%s' is not a valid cluster metadata. Expected kind: '%s' Actual kind: '%s'",
yamlPath, qaenginetypes.QAMappingsKind, qaMapping.Kind,
)
continue
}
logrus.Infof("Found custom QA mappings file '%s' at path '%s'", qaMapping.ObjectMeta.Name, yamlPath)
return qaMapping, nil
}
}
logrus.Infof("Using the default QA mappings file")
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)
}
if err := yaml.Unmarshal(file, &qaMapping); err != nil {
return qaMapping, fmt.Errorf("failed to decode qa-mapping file. Error: %w", err)
}
return qaMapping, nil
}

Steps to reproduce

  1. Run move2kube transform

Actual behavior

Crash saying the qamappings.yaml file doesn't exist.

Expected behavior

Should print the usage info

Environment

@HarikrishnanBalagopal HarikrishnanBalagopal added hacktoberfest good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. labels Oct 17, 2024
@HarikrishnanBalagopal
Copy link
Contributor Author

@Akash-Nayak
Copy link
Contributor

The error could be due to this hard coded path built-in/qa

qaMappingFilepath := filepath.Join("built-in/qa", "qamappings.yaml")

@HarikrishnanBalagopal
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. hacktoberfest kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
2 participants