Fixing top level run outside repo (#1993)
This commit is contained in:
2
go.sum
2
go.sum
@@ -514,8 +514,6 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
|
|||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg=
|
|
||||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
|
||||||
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
|
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
|||||||
@@ -99,7 +99,14 @@ 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 = 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
|
return nil
|
||||||
}
|
}
|
||||||
@@ -276,6 +283,7 @@ func (r *localRuntime) Create(s *runtime.Service, opts ...runtime.CreateOption)
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := r.checkoutSourceIfNeeded(s, options.Secrets)
|
err := r.checkoutSourceIfNeeded(s, options.Secrets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package local
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -50,25 +49,6 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
|
|||||||
|
|
||||||
dir := s.Source
|
dir := s.Source
|
||||||
|
|
||||||
// For uploaded packages, we upload the whole repo
|
|
||||||
// so the correct working directory to do a `go run .`
|
|
||||||
// needs to include the relative path from the repo root
|
|
||||||
// which is the service name.
|
|
||||||
//
|
|
||||||
// Could use a better upload check.
|
|
||||||
if strings.Contains(s.Source, "uploads") {
|
|
||||||
// There are two cases to consider here:
|
|
||||||
// a., if the uploaded code comes from a repo - in this case
|
|
||||||
// the service name is the relative path.
|
|
||||||
// b., if the uploaded code comes from a non repo folder -
|
|
||||||
// in this case the service name is the folder name.
|
|
||||||
// Because of this, we only append the service name to the source in
|
|
||||||
// case `a`
|
|
||||||
if ex, err := exists(filepath.Join(s.Source, s.Name)); err == nil && ex {
|
|
||||||
dir = filepath.Join(s.Source, s.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &service{
|
return &service{
|
||||||
Service: s,
|
Service: s,
|
||||||
Process: new(proc.Process),
|
Process: new(proc.Process),
|
||||||
|
|||||||
Reference in New Issue
Block a user