Skip to content

Commit

Permalink
bug: component detection with context
Browse files Browse the repository at this point in the history
Fixes RHTAPBUGS-418
  • Loading branch information
stuartwdouglas committed Jul 8, 2023
1 parent 8a518ab commit b053120
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/devfile/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type AlizerClient struct {
// Map 3 returns a context to the Dockerfile uri or a matched DockerfileURL from the devfile registry if no Dockerfile is present in the context
// Map 4 returns a context to the list of ports that were detected by alizer in the source code, at that given context
func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL string, source appstudiov1alpha1.GitSource) (map[string][]byte, map[string]string, map[string]string, map[string][]int, error) {

devfileMapFromRepo := make(map[string][]byte)
devfilesURLMapFromRepo := make(map[string]string)
dockerfileContextMapFromRepo := make(map[string]string)
Expand All @@ -63,7 +62,8 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
isDevfilePresent := false
isDockerfilePresent := false
curPath := path.Join(localpath, f.Name())
context := f.Name()
dirName := f.Name()
context := path.Join(source.Context, f.Name())
files, err := ioutil.ReadDir(curPath)
if err != nil {
return nil, nil, nil, nil, err
Expand All @@ -74,7 +74,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
/* #nosec G304 -- false positive, filename is not based on user input*/
devfilePath := path.Join(curPath, f.Name())
// Set the proper devfile URL for the detected devfile
updatedLink, err := UpdateGitLink(source.URL, source.Revision, path.Join(source.Context, path.Join(context, f.Name())))
updatedLink, err := UpdateGitLink(source.URL, source.Revision, path.Join(source.Context, path.Join(dirName, f.Name())))
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
devfilePath := path.Join(hiddenDirPath, f.Name())

// Set the proper devfile URL for the detected devfile
updatedLink, err := UpdateGitLink(source.URL, source.Revision, path.Join(source.Context, path.Join(context, HiddenDevfileDir, f.Name())))
updatedLink, err := UpdateGitLink(source.URL, source.Revision, path.Join(source.Context, path.Join(dirName, HiddenDevfileDir, f.Name())))
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/devfile/devfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ func DownloadDevfileAndDockerfile(url string) ([]byte, string, []byte, string) {
// Map 3 returns a context to the Dockerfile uri or a matched DockerfileURL from the devfile registry if no Dockerfile/Containerfile is present in the context
// Map 4 returns a context to the list of ports that were detected by alizer in the source code, at that given context
func ScanRepo(log logr.Logger, a Alizer, localpath string, devfileRegistryURL string, source appstudiov1alpha1.GitSource) (map[string][]byte, map[string]string, map[string]string, map[string][]int, error) {

return search(log, a, localpath, devfileRegistryURL, source)
}

Expand Down

0 comments on commit b053120

Please sign in to comment.