Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create the application if it doesn't already exist with the give… #295

Merged
merged 3 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/meroxa/root/apps/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"time"

"github.com/volatiletech/null/v8"
Expand All @@ -48,6 +49,7 @@ const (

type deployApplicationClient interface {
CreateApplication(ctx context.Context, input *meroxa.CreateApplicationInput) (*meroxa.Application, error)
GetApplication(ctx context.Context, nameOrUUID string) (*meroxa.Application, error)
CreateBuild(ctx context.Context, input *meroxa.CreateBuildInput) (*meroxa.Build, error)
CreateSource(ctx context.Context) (*meroxa.Source, error)
GetBuild(ctx context.Context, uuid string) (*meroxa.Build, error)
Expand Down Expand Up @@ -193,6 +195,18 @@ func (d *Deploy) createApplication(ctx context.Context, pipelineUUID, gitSha str

res, err := d.client.CreateApplication(ctx, &input)
if err != nil {
if strings.Contains(err.Error(), "already exists") {
// Double check that the created application has the expected pipeline.
var app *meroxa.Application
app, err = d.client.GetApplication(ctx, appName)
if err != nil {
return err
}
if app.Pipeline.UUID.String != pipelineUUID {
return fmt.Errorf("unable to finish creating the %s Application because its entities are in an"+
" unrecoverable state; try deleting and re-deploying", appName)
}
}
return err
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ require (
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/meroxa/meroxa-go => ../meroxa-go
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY=
github.com/meroxa/funtime v0.0.0-20220113012133-85e6e898fc73/go.mod h1:K2y2GvcA4Cg3dJtckcwYWnwnJzF63FDdtAQI0fToU0Q=
github.com/meroxa/meroxa-go v0.0.0-20220208195203-71ddc3133fab/go.mod h1:HDFszURCM1cOpKE699o5Hs0T2tEIXqY+vFcsur3RiwY=
github.com/meroxa/meroxa-go v0.0.0-20220330051015-d0051c2a233b h1:YSOIZ7AbtRl08XeLoP5LM+b3RJbwOVl0edeuFiQt+EM=
github.com/meroxa/meroxa-go v0.0.0-20220330051015-d0051c2a233b/go.mod h1:BsqYa9jqfyGOAgfkggfK567b2Ahkb+RCH3lXDQGgrh8=
github.com/meroxa/turbine v0.0.0-20220330190835-414127120d1e h1:C0shA5biV44pdmimKvxvX00oTtv2Y9TVsVksFnQlm2U=
github.com/meroxa/turbine v0.0.0-20220330190835-414127120d1e/go.mod h1:P8twIwKxgrxyQ8zh0v0dF89dmjKUxvaPWGKFEo1DzFM=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ github.com/mattn/go-runewidth
# github.com/mattn/go-shellwords v1.0.12
## explicit; go 1.13
github.com/mattn/go-shellwords
# github.com/meroxa/meroxa-go v0.0.0-20220330051015-d0051c2a233b
# github.com/meroxa/meroxa-go v0.0.0-20220330051015-d0051c2a233b => ../meroxa-go
## explicit; go 1.17
github.com/meroxa/meroxa-go/pkg/meroxa
github.com/meroxa/meroxa-go/pkg/mock
Expand Down Expand Up @@ -361,3 +361,4 @@ gopkg.in/ini.v1
# gopkg.in/yaml.v2 v2.4.0
## explicit; go 1.15
gopkg.in/yaml.v2
# github.com/meroxa/meroxa-go => ../meroxa-go