Skip to content

Commit

Permalink
feat(turbine): Supply Git SHA when creating an application and displa…
Browse files Browse the repository at this point in the history
…y it (#274)
  • Loading branch information
janelletavares authored Mar 14, 2022
1 parent 86f40b3 commit a0fcd03
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/meroxa/root/apps/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"fmt"
"os"

"github.com/meroxa/meroxa-go/pkg/meroxa"
"github.com/volatiletech/null/v8"

"github.com/meroxa/cli/cmd/meroxa/builder"
turbineCLI "github.com/meroxa/cli/cmd/meroxa/turbine_cli"
"github.com/meroxa/cli/config"
"github.com/meroxa/cli/log"
"github.com/meroxa/meroxa-go/pkg/meroxa"
)

const (
Expand Down Expand Up @@ -127,6 +128,8 @@ func (d *Deploy) createApplication(ctx context.Context) error {
input := meroxa.CreateApplicationInput{
Name: appName,
Language: d.lang,
GitSha: "hardcoded",
Pipeline: meroxa.EntityIdentifier{Name: null.StringFrom("default")},
}
d.logger.Infof(ctx, "Creating application %q with language %q...", input.Name, d.lang)

Expand Down
5 changes: 5 additions & 0 deletions cmd/meroxa/root/apps/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"reflect"
"testing"

"github.com/volatiletech/null/v8"

"github.com/meroxa/meroxa-go/pkg/meroxa"
turbine "github.com/meroxa/turbine/init"

Expand Down Expand Up @@ -77,11 +79,14 @@ func TestCreateApplication(t *testing.T) {
ai := &meroxa.CreateApplicationInput{
Name: name,
Language: lang,
GitSha: "hardcoded",
Pipeline: meroxa.EntityIdentifier{Name: null.StringFrom("default")},
}

a := &meroxa.Application{
Name: name,
Language: lang,
GitSha: "hardcoded",
}

client.
Expand Down
14 changes: 10 additions & 4 deletions utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ func AppsTable(apps []*meroxa.Application, hideHeaders bool) string {
{Align: simpletable.AlignCenter, Text: "UUID"},
{Align: simpletable.AlignCenter, Text: "NAME"},
{Align: simpletable.AlignCenter, Text: "LANGUAGE"},
{Align: simpletable.AlignCenter, Text: "GIT SHA"},
{Align: simpletable.AlignCenter, Text: "STATE"},
},
}
Expand All @@ -828,6 +829,7 @@ func AppsTable(apps []*meroxa.Application, hideHeaders bool) string {
{Align: simpletable.AlignRight, Text: app.UUID},
{Align: simpletable.AlignCenter, Text: app.Name},
{Align: simpletable.AlignCenter, Text: app.Language},
{Align: simpletable.AlignCenter, Text: app.GitSha},
{Align: simpletable.AlignCenter, Text: string(app.Status.State)},
}

Expand All @@ -838,6 +840,10 @@ func AppsTable(apps []*meroxa.Application, hideHeaders bool) string {
return table.String()
}

func PrintAppsTable(apps []*meroxa.Application, hideHeaders bool) {
fmt.Println(AppsTable(apps, hideHeaders))
}

func AppTable(app *meroxa.Application) string {
mainTable := simpletable.New()
mainTable.Body.Cells = [][]*simpletable.Cell{
Expand All @@ -853,6 +859,10 @@ func AppTable(app *meroxa.Application) string {
{Align: simpletable.AlignRight, Text: "Language:"},
{Text: app.Language},
},
{
{Align: simpletable.AlignRight, Text: "Git SHA:"},
{Text: app.GitSha},
},
{
{Align: simpletable.AlignRight, Text: "Created At:"},
{Text: app.CreatedAt.String()},
Expand Down Expand Up @@ -924,10 +934,6 @@ func AppTable(app *meroxa.Application) string {
return mainTable.String()
}

func PrintAppsTable(apps []*meroxa.Application, hideHeaders bool) {
fmt.Println(AppsTable(apps, hideHeaders))
}

func truncateString(oldString string, l int) string {
str := oldString

Expand Down

0 comments on commit a0fcd03

Please sign in to comment.