Skip to content

Commit

Permalink
Merge pull request #314 from meroxa/james/harden-ouput-capturing
Browse files Browse the repository at this point in the history
Define contract for turbine response and capture
  • Loading branch information
jmar910 authored Apr 15, 2022
2 parents 8cb828f + 1943e97 commit 497afc4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cmd/meroxa/turbine_cli/javascript/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"os"
"os/exec"
"regexp"
"strconv"
"strings"

"github.com/meroxa/cli/cmd/meroxa/global"
turbinecli "github.com/meroxa/cli/cmd/meroxa/turbine_cli"
Expand All @@ -23,7 +23,17 @@ func NeedsToBuild(path string) (bool, error) {
string(output))
return false, err
}
return strconv.ParseBool(strings.TrimSpace(string(output)))

r := regexp.MustCompile("\nturbine-response: (true|false)\n")
match := r.FindStringSubmatch(string(output))
if match == nil || len(match) < 2 {
err := fmt.Errorf(
"unable to determine if the Meroxa Application at %s has a Process; %s",
path,
string(output))
return false, err
}
return strconv.ParseBool(match[1])
}

func BuildApp(path string) (string, error) {
Expand All @@ -32,7 +42,13 @@ func BuildApp(path string) (string, error) {
if err != nil {
return "", fmt.Errorf("unable to build Meroxa Application at %s; %s", path, string(output))
}
return strings.TrimSpace(string(output)), err

r := regexp.MustCompile("\nturbine-response: (.*)\n")
match := r.FindStringSubmatch(string(output))
if match == nil || len(match) < 2 {
return "", fmt.Errorf("unable to build Meroxa Application at %s; %s", path, string(output))
}
return match[1], err
}

func RunDeployApp(ctx context.Context, l log.Logger, path, imageName string) (string, error) {
Expand Down

0 comments on commit 497afc4

Please sign in to comment.