Fixing top level run outside repo (#1993)

This commit is contained in:
Janos Dobronszki
2020-09-10 14:36:36 +02:00
committed by GitHub
parent b8f79a3fc6
commit 04d2aa4696
3 changed files with 9 additions and 23 deletions

View File

@@ -99,7 +99,14 @@ func (r *localRuntime) checkoutSourceIfNeeded(s *runtime.Service, secrets map[st
fullp := append([]string{uncompressPath}, sourceParts[1:]...)
s.Source = filepath.Join(append(fullp, lastFolderPart)...)
} else {
s.Source = filepath.Join(uncompressPath, tarName)
// The tar name is 'helloworld' for both
// the case when the code is uploaded from `$REPO/helloworld`
// and when it's uploaded from outside a repo ie `~/helloworld`.
if _, err := Entrypoint(filepath.Join(s.Source, tarName)); err == nil {
s.Source = filepath.Join(uncompressPath, tarName)
} else {
s.Source = uncompressPath
}
}
return nil
}
@@ -276,6 +283,7 @@ func (r *localRuntime) Create(s *runtime.Service, opts ...runtime.CreateOption)
for _, o := range opts {
o(&options)
}
err := r.checkoutSourceIfNeeded(s, options.Secrets)
if err != nil {
return err