Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
janelletavares committed Sep 19, 2022
1 parent 9e485a7 commit 520498a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
11 changes: 6 additions & 5 deletions cmd/meroxa/root/apps/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import (
"context"
"errors"
"fmt"
"github.com/meroxa/cli/cmd/meroxa/global"
"github.com/volatiletech/null/v8"
"net/http"
"os"
"regexp"
"strings"
"time"

"github.com/coreos/go-semver/semver"
"github.com/volatiletech/null/v8"

"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/meroxa/cli/cmd/meroxa/global"
"github.com/meroxa/cli/cmd/meroxa/turbine"
turbineGo "github.com/meroxa/cli/cmd/meroxa/turbine/golang"
turbineJS "github.com/meroxa/cli/cmd/meroxa/turbine/javascript"
Expand Down Expand Up @@ -653,7 +653,10 @@ func hasFeatureFlag(f string) bool {
return false
}

//nolint:gocyclo the specVersion conditionals are temporary
func (d *Deploy) Execute(ctx context.Context) error {
var app *meroxa.Application

if err := d.validateAppJSON(ctx); err != nil {
return err
}
Expand Down Expand Up @@ -684,7 +687,6 @@ func (d *Deploy) Execute(ctx context.Context) error {
return err
}

var app *meroxa.Application
if d.specVersion == "" {
// ⚠️ This is only until we re-deploy applications applying only the changes made
if err = d.tearDownExistingResources(ctx); err != nil {
Expand Down Expand Up @@ -714,8 +716,7 @@ func (d *Deploy) Execute(ctx context.Context) error {
return err
}

err = d.deployApp(ctx, d.fnName, gitSha, d.specVersion)
if err != nil {
if err = d.deployApp(ctx, d.fnName, gitSha, d.specVersion); err != nil {
return err
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/meroxa/turbine/golang/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func (t *turbineGoCLI) Deploy(ctx context.Context, imageName, appName, gitSha st

if specVersion != "" {
deploymentSpec, err = utils.GetTurbineResponseFromOutput(string(output))
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
if err != nil {
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
}
}
return deploymentSpec, err
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/meroxa/turbine/javascript/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (t *turbineJsCLI) NeedsToBuild(ctx context.Context, appName string) (bool,
cmd := utils.RunTurbineJS(ctx, "hasfunctions", t.appPath)
output, err := cmd.CombinedOutput()
if err != nil {
err := fmt.Errorf(
err = fmt.Errorf(
"unable to determine if the Meroxa Application at %s has a Process; %s",
t.appPath,
string(output))
Expand Down Expand Up @@ -55,10 +55,15 @@ func (t *turbineJsCLI) Deploy(ctx context.Context, imageName, appName, gitSha, s
cmd.Env = append(cmd.Env, fmt.Sprintf("MEROXA_ACCESS_TOKEN=%s", accessToken))

output, err = utils.RunCmdWithErrorDetection(ctx, cmd, t.logger)
if err != nil {
return deploymentSpec, err
}
if specVersion != "" {
deploymentSpec, err = utils.GetTurbineResponseFromOutput(output)
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
if err != nil {
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
}
}
return deploymentSpec, err
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/meroxa/turbine/python/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (t *turbinePyCLI) NeedsToBuild(ctx context.Context, appName string) (bool,
cmd := exec.Command("turbine-py", "hasFunctions", t.appPath)
output, err := cmd.CombinedOutput()
if err != nil {
err := fmt.Errorf(
err = fmt.Errorf(
"unable to determine if the Meroxa Application at %s has a Process; %s",
t.appPath,
string(output))
Expand Down Expand Up @@ -58,10 +58,15 @@ func (t *turbinePyCLI) Deploy(ctx context.Context, imageName, appName, gitSha, s
cmd.Env = append(cmd.Env, fmt.Sprintf("MEROXA_ACCESS_TOKEN=%s", accessToken))

output, err = utils.RunCmdWithErrorDetection(ctx, cmd, t.logger)
if err != nil {
return deploymentSpec, err
}
if specVersion != "" {
deploymentSpec, err = utils.GetTurbineResponseFromOutput(output)
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
if err != nil {
err = fmt.Errorf(
"unable to receive the deployment spec for the Meroxa Application at %s has a Process", t.appPath)
}
}
return deploymentSpec, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func cleanUpPythonTempBuildLocation(ctx context.Context, logger log.Logger, appP

func GetTurbineResponseFromOutput(output string) (string, error) {
r := regexp.MustCompile("^turbine-response: ([^\n]*)")
match := r.FindStringSubmatch(string(output))
match := r.FindStringSubmatch(output)
if match == nil || len(match) < 2 {
return "", fmt.Errorf("output is formatted unexpectedly")
}
Expand Down

0 comments on commit 520498a

Please sign in to comment.