Skip to content

Commit

Permalink
Revert "feat(turbine): logically nest functions under applications" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
janelletavares authored Mar 8, 2022
1 parent 23b3302 commit 5fe7052
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 140 deletions.
2 changes: 2 additions & 0 deletions cmd/meroxa/root/apps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ func (*Apps) FeatureFlag() (string, error) {
func (*Apps) SubCommands() []*cobra.Command {
return []*cobra.Command{
builder.BuildCobraCommand(&Create{}),
builder.BuildCobraCommand(&Describe{}),
builder.BuildCobraCommand(&Deploy{}),
builder.BuildCobraCommand(&Init{}),
builder.BuildCobraCommand(&List{}),
builder.BuildCobraCommand(&Remove{}),
builder.BuildCobraCommand(&Run{}),
}
Expand Down
6 changes: 2 additions & 4 deletions cmd/meroxa/root/apps/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/volatiletech/null/v8"

"github.com/meroxa/cli/log"
"github.com/meroxa/cli/utils"
"github.com/meroxa/meroxa-go/pkg/meroxa"
Expand Down Expand Up @@ -117,8 +115,8 @@ func TestDescribeApplicationExecutionWithFunctions(t *testing.T) {
a := utils.GenerateApplication()
a.Name = appName
a.Functions = []meroxa.FunctionIdentifier{
{Name: null.StringFrom("fun1")},
{Name: null.StringFrom("fun2")},
{Name: "fun1"},
{Name: "fun2"},
}

client.
Expand Down
6 changes: 2 additions & 4 deletions cmd/meroxa/root/apps/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/volatiletech/null/v8"

"github.com/meroxa/cli/log"
"github.com/meroxa/cli/utils"
"github.com/meroxa/meroxa-go/pkg/meroxa"
Expand All @@ -44,8 +42,8 @@ func TestListAppsExecution(t *testing.T) {
Language: GoLang,
Status: meroxa.ApplicationStatus{State: meroxa.ApplicationStateReady},
Functions: []meroxa.FunctionIdentifier{
{Name: null.StringFrom("one")},
{Name: null.StringFrom("two")},
{Name: "one"},
{Name: "two"},
},
}

Expand Down
14 changes: 4 additions & 10 deletions cmd/meroxa/root/functions/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"strings"

"github.com/mattn/go-shellwords"
"github.com/volatiletech/null/v8"

"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/meroxa/cli/log"
"github.com/meroxa/meroxa-go/pkg/meroxa"
Expand Down Expand Up @@ -41,7 +39,6 @@ type Create struct {
Args string `long:"args" usage:"Arguments to the entrypoint"`
EnvVars []string `long:"env" usage:"List of environment variables to set in the function"`
Pipeline string `long:"pipeline" usage:"pipeline name to attach function to" required:"true"`
Application string `long:"app" usage:"application name or UUID to which this function belongs" required:"true"`
}
}

Expand All @@ -52,10 +49,10 @@ func (c *Create) Usage() string {
func (c *Create) Docs() builder.Docs {
return builder.Docs{
Short: "Create a function",
Long: "Use `functions create` to create a function to process records from an input stream (--input-stream)",
Long: "Use `functions create` to create a function to process records from an input steram (--input-stream)",
Example: `
meroxa functions create [NAME] --input-stream connector-output-stream --image myimage --app my-app
meroxa functions create [NAME] --input-stream connector-output-stream --image myimage --app my-app --env FOO=BAR --env BAR=BAZ
meroxa functions create [NAME] --input-stream connector-output-stream --image myimage --pipeline my-pipeline
meroxa functions create [NAME] --input-stream connector-output-stream --image myimage --pipeline my-pipeline --env FOO=BAR --env BAR=BAZ
`,
}
}
Expand Down Expand Up @@ -89,10 +86,7 @@ func (c *Create) Execute(ctx context.Context) error {
Name: c.args.Name,
InputStream: c.flags.InputStream,
Pipeline: meroxa.PipelineIdentifier{
Name: null.StringFrom(c.flags.Pipeline),
},
Application: meroxa.ApplicationIdentifier{
Name: null.StringFrom(c.flags.Application),
Name: c.flags.Pipeline,
},
Image: c.flags.Image,
Command: command,
Expand Down
8 changes: 2 additions & 6 deletions cmd/meroxa/root/functions/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
)

type describeFunctionClient interface {
GetFunction(ctx context.Context, appNameOrUUID, nameOrUUID string) (*meroxa.Function, error)
GetFunction(ctx context.Context, nameOrUUID string) (*meroxa.Function, error)
}

type Describe struct {
Expand All @@ -29,10 +29,6 @@ type Describe struct {
args struct {
NameOrUUID string
}

flags struct {
Application string `long:"app" usage:"application name or UUID to which this function belongs" required:"true"`
}
}

func (d *Describe) Usage() string {
Expand All @@ -46,7 +42,7 @@ func (d *Describe) Docs() builder.Docs {
}

func (d *Describe) Execute(ctx context.Context) error {
fun, err := d.client.GetFunction(ctx, d.flags.Application, d.args.NameOrUUID)
fun, err := d.client.GetFunction(ctx, d.args.NameOrUUID)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/meroxa/root/functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
_ builder.CommandWithDocs = (*Functions)(nil)
_ builder.CommandWithFeatureFlag = (*Functions)(nil)
_ builder.CommandWithSubCommands = (*Functions)(nil)
_ builder.CommandWithHidden = (*Functions)(nil) // for internal use only, will always be hidden
_ builder.CommandWithHidden = (*Functions)(nil)
)

func (*Functions) Usage() string {
Expand All @@ -26,7 +26,7 @@ func (*Functions) Hidden() bool {
}

func (*Functions) FeatureFlag() (string, error) {
return "turbine", fmt.Errorf(`no access to the Meroxa Data applications feature`)
return "functions", fmt.Errorf(`no access to the Meroxa functions feature`)
}

func (*Functions) Docs() builder.Docs {
Expand Down
29 changes: 4 additions & 25 deletions cmd/meroxa/root/functions/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,19 @@ var (
)

type listFunctionClient interface {
ListApplications(ctx context.Context) ([]*meroxa.Application, error)
ListFunctions(ctx context.Context, appNameOrUUID string) ([]*meroxa.Function, error)
ListFunctions(ctx context.Context) ([]*meroxa.Function, error)
}

type List struct {
client listFunctionClient
logger log.Logger
hideHeaders bool

flags struct {
Application string `long:"app" usage:"application name or UUID to which this function belongs"`
}
}

func (l *List) Execute(ctx context.Context) error {
var err error
funs := make([]*meroxa.Function, 0)
if l.flags.Application != "" {
funs, err = l.client.ListFunctions(ctx, l.flags.Application)
if err != nil {
return err
}
} else {
apps, err := l.client.ListApplications(ctx)
if err != nil {
return err
}
for _, app := range apps {
fs, err := l.client.ListFunctions(ctx, app.UUID)
if err != nil {
return err
}
funs = append(funs, fs...)
}
funs, err := l.client.ListFunctions(ctx)
if err != nil {
return err
}

l.logger.JSON(ctx, funs)
Expand Down
8 changes: 2 additions & 6 deletions cmd/meroxa/root/functions/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
)

type functionLogsClient interface {
GetFunctionLogs(ctx context.Context, appNameOrUUID, nameOrUUID string) (*http.Response, error)
GetFunctionLogs(ctx context.Context, nameOrUUID string) (*http.Response, error)
}

type Logs struct {
Expand All @@ -30,10 +30,6 @@ type Logs struct {
args struct {
NameOrUUID string
}

flags struct {
Application string `long:"app" usage:"application name or UUID to which this function belongs" required:"true"`
}
}

func (l *Logs) Usage() string {
Expand All @@ -47,7 +43,7 @@ func (l *Logs) Docs() builder.Docs {
}

func (l *Logs) Execute(ctx context.Context) error {
resp, err := l.client.GetFunctionLogs(ctx, l.flags.Application, l.args.NameOrUUID)
resp, err := l.client.GetFunctionLogs(ctx, l.args.NameOrUUID)

if err != nil {
return err
Expand Down
8 changes: 2 additions & 6 deletions cmd/meroxa/root/functions/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
)

type removeFunctionClient interface {
DeleteFunction(ctx context.Context, appNameOrUUID, nameOrUUID string) (*meroxa.Function, error)
DeleteFunction(ctx context.Context, nameOrUUID string) (*meroxa.Function, error)
}

type Remove struct {
Expand All @@ -30,10 +30,6 @@ type Remove struct {
args struct {
NameOrUUID string
}

flags struct {
Application string `long:"app" usage:"application name or UUID to which this function belongs" required:"true"`
}
}

func (r *Remove) Usage() string {
Expand All @@ -53,7 +49,7 @@ func (r *Remove) ValueToConfirm(_ context.Context) (wantInput string) {
func (r *Remove) Execute(ctx context.Context) error {
r.logger.Infof(ctx, "Function %q is being removed...", r.args.NameOrUUID)

e, err := r.client.DeleteFunction(ctx, r.flags.Application, r.args.NameOrUUID)
e, err := r.client.DeleteFunction(ctx, r.args.NameOrUUID)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/meroxa/meroxa-go v0.0.0-20220304141736-3e708e76b666
github.com/meroxa/meroxa-go v0.0.0-20220308155654-367a81c1e0ac
github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4
github.com/rivo/uniseg v0.2.0 // indirect
Expand All @@ -27,8 +27,7 @@ require (
require (
github.com/docker/docker v20.10.12+incompatible
github.com/mattn/go-shellwords v1.0.12
github.com/meroxa/turbine v0.0.0-20220308111836-bbbad1a4c8d2
github.com/volatiletech/null/v8 v8.1.2
github.com/meroxa/turbine v0.0.0-20220301211444-5662995ad65f
)

require github.com/cristalhq/jwt/v3 v3.1.0 // indirect
Expand Down Expand Up @@ -73,6 +72,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/null/v8 v8.1.2 // indirect
github.com/volatiletech/randomize v0.0.1 // indirect
github.com/volatiletech/strmangle v0.0.2 // indirect
go.opencensus.io v0.23.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,10 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
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-20220304141736-3e708e76b666 h1:FWwzyreRc5RXbOTVjcNNfiBwNYaqTOqfppmyNGefVDA=
github.com/meroxa/meroxa-go v0.0.0-20220304141736-3e708e76b666/go.mod h1:BsqYa9jqfyGOAgfkggfK567b2Ahkb+RCH3lXDQGgrh8=
github.com/meroxa/turbine v0.0.0-20220308111836-bbbad1a4c8d2 h1:VfPnHP4jWwxjk/mddLVMYyyWCOhTZqra3miNUD7QX8I=
github.com/meroxa/turbine v0.0.0-20220308111836-bbbad1a4c8d2/go.mod h1:4A2E9icHDi3x4Flp9CunWyRBvNkZy6h8MS8zLvWUlmw=
github.com/meroxa/meroxa-go v0.0.0-20220308155654-367a81c1e0ac h1:jOX0X0ZDEUyFmjM/8ymj8MdZHywgPDZ6p+RQxL1bG7k=
github.com/meroxa/meroxa-go v0.0.0-20220308155654-367a81c1e0ac/go.mod h1:ab2rHsqdQ25tYbIohjRGNujKHu6yGhV5ALAi4GE0Ehw=
github.com/meroxa/turbine v0.0.0-20220301211444-5662995ad65f h1:fWCA+cO4aPIzePOuz4drdOQAgUTM6UG7lRYgtbWLHv0=
github.com/meroxa/turbine v0.0.0-20220301211444-5662995ad65f/go.mod h1:4A2E9icHDi3x4Flp9CunWyRBvNkZy6h8MS8zLvWUlmw=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4=
Expand Down
14 changes: 4 additions & 10 deletions utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ func FunctionsTable(funs []*meroxa.Function, hideHeaders bool) string {
{Align: simpletable.AlignCenter, Text: "OUTPUT STREAM"},
{Align: simpletable.AlignCenter, Text: "STATE"},
{Align: simpletable.AlignCenter, Text: "PIPELINE"},
{Align: simpletable.AlignCenter, Text: "APPLICATION"},
},
}
}
Expand All @@ -521,8 +520,7 @@ func FunctionsTable(funs []*meroxa.Function, hideHeaders bool) string {
{Align: simpletable.AlignCenter, Text: p.InputStream},
{Align: simpletable.AlignCenter, Text: p.OutputStream},
{Align: simpletable.AlignCenter, Text: p.Status.State},
{Align: simpletable.AlignCenter, Text: p.Pipeline.Name.String},
{Align: simpletable.AlignCenter, Text: p.Application.Name.String},
{Align: simpletable.AlignCenter, Text: p.Pipeline.Name},
}

table.Body.Cells = append(table.Body.Cells, r)
Expand Down Expand Up @@ -574,11 +572,7 @@ func FunctionTable(fun *meroxa.Function) string {
},
{
{Align: simpletable.AlignRight, Text: "Pipeline:"},
{Text: fun.Pipeline.Name.String},
},
{
{Align: simpletable.AlignRight, Text: "Application:"},
{Text: fun.Application.Name.String},
{Text: fun.Pipeline.Name},
},
{
{Align: simpletable.AlignRight, Text: "State:"},
Expand Down Expand Up @@ -833,7 +827,7 @@ func AppsTable(apps []*meroxa.Application, hideHeaders bool) string {
for _, app := range apps {
names := make([]string, 0)
for _, f := range app.Functions {
names = append(names, f.Name.String)
names = append(names, f.Name)
}
r := []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: app.UUID},
Expand Down Expand Up @@ -890,7 +884,7 @@ func AppTable(app *meroxa.Application) string {
if len(app.Functions) != 0 {
names := make([]string, 0)
for _, f := range app.Functions {
names = append(names, f.Name.String)
names = append(names, f.Name)
}

mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
Expand Down
Loading

0 comments on commit 5fe7052

Please sign in to comment.