Skip to content

Commit

Permalink
Merge pull request #115 from TIBCOSoftware/fix_113_114
Browse files Browse the repository at this point in the history
fix issue #113 and #114
  • Loading branch information
Frank Martinez authored Aug 1, 2018
2 parents 132fc57 + 8c6908e commit ef52c5f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
16 changes: 10 additions & 6 deletions app/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,11 @@ func doPrepare(env env.Project, options *PrepareOptions) (err error) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = env.GetAppDir()
cmd.Env = append(os.Environ(),
fmt.Sprintf("GOPATH=%s", env.GetRootDir()),
)
//cmd.Env = append(os.Environ(),
// fmt.Sprintf("GOPATH=%s", env.GetRootDir()),
//)
cmd.Env = fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", env.GetRootDir())


err = cmd.Run()
if err != nil {
Expand All @@ -278,9 +280,11 @@ func doPrepare(env env.Project, options *PrepareOptions) (err error) {
cmd := exec.Command("make", "-C", env.GetAppDir())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Env = append(os.Environ(),
fmt.Sprintf("GOPATH=%s", env.GetRootDir()),
)
//cmd.Env = append(os.Environ(),
// fmt.Sprintf("GOPATH=%s", env.GetRootDir()),
//)
cmd.Env = fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", env.GetRootDir())


err = cmd.Run()
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func ExtractAllDependencies(appjson string) ([]*Dependency, error) {
}
deps = append(deps, resourceDeps...)

deps = append(deps, ExtractDependenciesActionOld(flogoApp.Actions)...)
deps = append(deps, ExtractDependenciesSharedActions(flogoApp.Actions)...)
return deps, nil
}

Expand All @@ -187,7 +187,9 @@ func extractTrigersDependency(triggers []*trigger.Config) []*Dependency {
if t.Handlers != nil {
for _, t := range t.Handlers {
if t.Action != nil {
deps = append(deps, &Dependency{ContribType: ACTION, Ref: t.Action.Ref})
if t.Action.Ref != "" {
deps = append(deps, &Dependency{ContribType: ACTION, Ref: t.Action.Ref})
}
}
}
}
Expand Down Expand Up @@ -246,12 +248,13 @@ type depHolder struct {
}

// ExtractDependencies extracts dependencies from from application descriptor
func ExtractDependenciesActionOld(actions []*ActionDescriptor) []*Dependency {
func ExtractDependenciesSharedActions(actions []*ActionDescriptor) []*Dependency {
dh := &depHolder{}

for _, action := range actions {
dh.deps = append(dh.deps, &Dependency{ContribType: ACTION, Ref: action.Ref})

//todo remove
if action.Data != nil && action.Data.Flow != nil {
extractDepsFromTaskOld(action.Data.Flow.RootTask, dh)
//Error handle flow
Expand Down
20 changes: 11 additions & 9 deletions dep/dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (b *DepManager) Init() error {

cmd := exec.Command("dep", "init")
cmd.Dir = b.Env.GetAppDir()
newEnv := os.Environ()
newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", b.Env.GetRootDir()))
cmd.Env = newEnv
//newEnv := os.Environ()
//newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", b.Env.GetRootDir()))
cmd.Env = fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", b.Env.GetRootDir())

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down Expand Up @@ -112,9 +112,10 @@ func (b *DepManager) Ensure(args ...string) error {

cmd := exec.Command("dep", ensureArgs...)
cmd.Dir = b.Env.GetAppDir()
newEnv := os.Environ()
newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", b.Env.GetRootDir()))
cmd.Env = newEnv
//newEnv := os.Environ()
//newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", b.Env.GetRootDir()))
//cmd.Env = newEnv
cmd.Env = fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", b.Env.GetRootDir())

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down Expand Up @@ -324,9 +325,10 @@ func GetExistingConstraint(rootDir, appDir, depPath string) (*ConstraintDef, err
// Validate that the install project does not exist in Gopkg.toml
cmd := exec.Command("dep", "status", "-json")
cmd.Dir = appDir
newEnv := os.Environ()
newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", rootDir))
cmd.Env = newEnv
//newEnv := os.Environ()
//newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", rootDir))
//cmd.Env = newEnv
cmd.Env = fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", rootDir)

status, err := cmd.Output()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions env/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ func (e *FlogoProject) Build() error {

cmd := exec.Command("go", "install", "./...")
cmd.Dir = e.GetAppDir()
newEnv := os.Environ()
newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", e.GetRootDir()))
//newEnv := os.Environ()
//newEnv = append(newEnv, fmt.Sprintf("GOPATH=%s", e.GetRootDir()))
newEnv := fgutil.ReplaceEnvValue(os.Environ(), "GOPATH", e.GetRootDir())

os.Unsetenv("GOBIN")
if e.GetDockerBuild() {
fmt.Println("Setting GOOS to linux because this is a docker build")
Expand Down
15 changes: 15 additions & 0 deletions util/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fgutil

import "strings"

func ReplaceEnvValue(env []string, envKey string, newValue string) []string {
for key, entry := range env {

if strings.HasPrefix(entry, envKey + "=") {
env[key] = envKey + "=" + newValue
break
}
}

return env
}

0 comments on commit ef52c5f

Please sign in to comment.