Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
display script output
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlacy committed Aug 31, 2021
1 parent 66ba0ff commit 512bb70
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/monokube/monokube.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ OUTER:
color.Cyan("running pre-build tasks")
applyManifests(packages, "pre-build")
scripts := "{pre-build.sh}" // Glob patern
err := runScripts(packages, scripts)
err := runScripts(packages, scripts, true)
if err != nil {
color.Red("error running pre-build %e", err.Error())
}
Expand Down Expand Up @@ -265,7 +265,7 @@ OUTER:
color.Cyan("running pre-deployment tasks")
applyManifests(packages, "pre-deploy")
scripts := "{pre-deploy.sh}" // Glob patern
err := runScripts(packages, scripts)
err := runScripts(packages, scripts, false)
if err != nil {
color.Red("error running pre-deploy %e", err.Error())
}
Expand All @@ -281,7 +281,7 @@ OUTER:
color.Cyan("running post-deployment tasks")
applyManifests(packages, "post-deploy")
scripts := "{post-deploy.sh}" // Glob patern
err := runScripts(packages, scripts)
err := runScripts(packages, scripts, false)
if err != nil {
color.Red("error running post-deploy %e", err.Error())
}
Expand Down Expand Up @@ -346,17 +346,21 @@ func applyManifests(packages []Package, runCondition string) {
}

// runScripts takes a glob pattern as the second argument for `scripts`, {"script.sh,run.sh"}
func runScripts(packages []Package, scripts string) error {
func runScripts(packages []Package, scripts string, runInBackground bool) error {
for _, pkg := range packages {
pglob := parseGlobs([]string{pkg.Path + "/kube/" + scripts}, false)
for _, pth := range pglob {
color.Cyan("running: " + pth)
output, err := runPackageOutput(pkg, pth)
if *flagOutput != "" {
fmt.Println(output)
}
if err != nil {
return err
if runInBackground {
runBackground(pkg, pth)
} else {
output, err := runPackageOutput(pkg, pth)
if *flagOutput != "" {
fmt.Println(output)
}
if err != nil {
return err
}
}
}
}
Expand Down

0 comments on commit 512bb70

Please sign in to comment.