diff --git a/cmd/meroxa/root/apps/deploy.go b/cmd/meroxa/root/apps/deploy.go index a39040e4c..23c5572a4 100644 --- a/cmd/meroxa/root/apps/deploy.go +++ b/cmd/meroxa/root/apps/deploy.go @@ -429,7 +429,7 @@ func (d *Deploy) Execute(ctx context.Context) error { case GoLang: deployOutput, err = d.deploy(ctx, d.path, d.logger) case "js", JavaScript, NodeJs: - err = turbineJS.Deploy(ctx, d.path, d.logger) + deployOutput, err = turbineJS.Deploy(ctx, d.path, d.logger) default: return fmt.Errorf("language %q not supported. %s", d.lang, LanguageNotSupportedError) } @@ -437,7 +437,10 @@ func (d *Deploy) Execute(ctx context.Context) error { return err } - pipelineUUID := turbineCLI.GetPipelineUUID(deployOutput) + pipelineUUID, err := turbineCLI.GetPipelineUUID(deployOutput) + if err != nil { + return err + } gitSha, err := turbineCLI.GetGitSha(d.path) if err != nil { return err diff --git a/cmd/meroxa/turbine_cli/javascript/deploy.go b/cmd/meroxa/turbine_cli/javascript/deploy.go index b22d4aab8..d61979480 100644 --- a/cmd/meroxa/turbine_cli/javascript/deploy.go +++ b/cmd/meroxa/turbine_cli/javascript/deploy.go @@ -13,18 +13,17 @@ import ( // npx turbine whatever path => CLI could carry on with creating the tar.zip, post source, build... // once that's complete, it's when we'd call `npx turbine deploy path`. -func Deploy(ctx context.Context, path string, l log.Logger) error { +func Deploy(ctx context.Context, path string, l log.Logger) (string, error) { cmd := exec.Command("npx", "turbine", "deploy", path) accessToken, _, err := global.GetUserToken() if err != nil { - return err + return "", err } cmd.Env = os.Environ() cmd.Env = append(cmd.Env, fmt.Sprintf("MEROXA_ACCESS_TOKEN=%s", accessToken)) - _, err = turbinecli.RunCmdWithErrorDetection(ctx, cmd, l) - return err + return turbinecli.RunCmdWithErrorDetection(ctx, cmd, l) } // 1. we build binary (Go) // we set up the app structure (JS/Python) <- CLI could do this diff --git a/cmd/meroxa/turbine_cli/utils.go b/cmd/meroxa/turbine_cli/utils.go index ac0a9ca2e..8e9a8eb60 100644 --- a/cmd/meroxa/turbine_cli/utils.go +++ b/cmd/meroxa/turbine_cli/utils.go @@ -177,13 +177,15 @@ func GitChecks(ctx context.Context, l log.Logger, appPath string) error { } // GetPipelineUUID parses the deploy output when it was successful to determine the pipeline UUID to create. -func GetPipelineUUID(output string) string { +func GetPipelineUUID(output string) (string, error) { // Example output: // 2022/03/16 13:21:36 pipeline created: "turbine-pipeline-simple" ("049760a8-a3d2-44d9-b326-0614c09a3f3e"). re := regexp.MustCompile(`pipeline:."turbine-pipeline-[a-z0-9-]+".(\([^)]*\))`) - res := re.FindStringSubmatch(output)[1] - res = strings.Trim(res, "()\"") - return res + matches := re.FindStringSubmatch(output) + if len(matches) < 2 { //nolint:gomnd + return "", fmt.Errorf("pipeline UUID not found") + } + return strings.Trim(matches[1], "()\""), nil } // ValidateBranch validates the deployment is being performed from one of the allowed branches.