runtime/local: fix unknown dir path (#1964)

Co-authored-by: Asim Aslam <asim@aslam.me>
Co-authored-by: Janos Dobronszki <dobronszki@gmail.com>
This commit is contained in:
ben-toogood 2020-08-24 14:23:44 +01:00 committed by GitHub
parent 21004341bf
commit 0adb469a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,8 +75,9 @@ func (r *localRuntime) checkoutSourceIfNeeded(s *runtime.Service, secrets map[st
sourceParts := strings.Split(s.Source, "/") sourceParts := strings.Split(s.Source, "/")
compressedFilepath := filepath.Join(SourceDir, sourceParts[0]) compressedFilepath := filepath.Join(SourceDir, sourceParts[0])
uncompressPath := strings.ReplaceAll(compressedFilepath, ".tar.gz", "") uncompressPath := strings.ReplaceAll(compressedFilepath, ".tar.gz", "")
tarName := strings.ReplaceAll(sourceParts[0], ".tar.gz", "")
if len(sourceParts) > 1 { if len(sourceParts) > 1 {
uncompressPath = filepath.Join(SourceDir, strings.ReplaceAll(sourceParts[0], ".tar.gz", "")) uncompressPath = filepath.Join(SourceDir, tarName)
} }
// check if the directory already exists // check if the directory already exists
@ -98,7 +99,7 @@ func (r *localRuntime) checkoutSourceIfNeeded(s *runtime.Service, secrets map[st
fullp := append([]string{uncompressPath}, sourceParts[1:]...) fullp := append([]string{uncompressPath}, sourceParts[1:]...)
s.Source = filepath.Join(append(fullp, lastFolderPart)...) s.Source = filepath.Join(append(fullp, lastFolderPart)...)
} else { } else {
s.Source = uncompressPath s.Source = filepath.Join(uncompressPath, tarName)
} }
return nil return nil
} }