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

Mdpx Conduit Application Changes #878

Open
wants to merge 9 commits into
base: mdpx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
160 changes: 0 additions & 160 deletions cmd/meroxa/flink/deploy.go

This file was deleted.

2 changes: 0 additions & 2 deletions cmd/meroxa/global/basic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ func (c *client) newRequestMultiPart(
req.Header.Set("Authorization", accessToken)

}
fmt.Println("Content-Type header already set.")
}

req.Header.Set("User-Agent", c.userAgent)
Expand Down Expand Up @@ -313,7 +312,6 @@ func (c *client) newRequest(
req.Header.Set("Authorization", accessToken)

}
fmt.Println("Content-Type header already set.")
}
req.Header.Add("Content-Type", jsonContentType)
req.Header.Add("Accept", jsonContentType)
Expand Down
79 changes: 29 additions & 50 deletions cmd/meroxa/root/apps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ import (
"strconv"
"time"

"github.com/meroxa/turbine-core/v2/pkg/ir"

"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"
turbinePY "github.com/meroxa/cli/cmd/meroxa/turbine/python"
turbineRb "github.com/meroxa/cli/cmd/meroxa/turbine/ruby"
pb "github.com/pocketbase/pocketbase/tools/types"

"github.com/meroxa/cli/log"
"github.com/meroxa/cli/utils/display"
"github.com/spf13/cobra"
)
Expand All @@ -50,27 +43,36 @@ const (
ApplicationStateDegraded ApplicationState = "degraded"
ApplicationStateFailed ApplicationState = "failed"

collectionName = "apps"
deploymentCollection = "conduitdeployments"
applicationCollection = "conduitapps"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can wait til having the full deployment functionality in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

)

var displayDetails = display.Details{
"Name": "name",
"State": "state",
"SpecVersion": "specVersion",
"Created": "created",
"Updated": "updated",
"Name": "name",
"State": "state",
"ApplicationSpec": "stream_tech",
"Config": "config",
"PipelineFilenames": "pipelines_filenames",
// "PipelineEnriched": "pipeline_enriched",
// "PipelineOriginal": "pipeline_original",
"Created": "created",
"Updated": "updated",
}

// Application represents the Meroxa Application type within the Meroxa API.
type Application struct {
ID string `json:"id"`
Name string `json:"name"`
State ApplicationState `json:"state"`
Spec map[string]interface{} `json:"spec"`
SpecVersion string `json:"specVersion"`
Created AppTime `json:"created"`
Updated AppTime `json:"updated"`
Image string `json:"imageArchive"`
ID string `json:"id"`
Name string `json:"name"`
State string `json:"state"`
ApplicationSpec string `json:"stream_tech"`
Config string `json:"config"`
PipelineFilenames string `json:"pipeline_filenames"`
PipelineEnriched string `json:"pipeline_enriched"`
PipelineOriginal string `json:"pipeline_original"`

Created AppTime `json:"created"`
Updated AppTime `json:"updated"`
Archive string `json:"archive"`
}

type Applications struct {
Expand Down Expand Up @@ -126,7 +128,7 @@ func (*Apps) Usage() string {

func (*Apps) Docs() builder.Docs {
return builder.Docs{
Short: "Manage Turbine Data Applications",
Short: "Manage Conduit Data Applications",
}
}

Expand All @@ -142,51 +144,28 @@ func (*Apps) SubCommands() []*cobra.Command {
}
}

// getTurbineCLIFromLanguage will return the appropriate turbine.CLI based on language.
func getTurbineCLIFromLanguage(logger log.Logger, lang ir.Lang, path string) (turbine.CLI, error) {
switch lang {
case "go", turbine.GoLang:
return turbineGo.New(logger, path), nil
case "js", turbine.JavaScript, turbine.NodeJs:
return turbineJS.New(logger, path), nil
case "py", turbine.Python3, turbine.Python:
return turbinePY.New(logger, path), nil
case "rb", turbine.Ruby:
return turbineRb.New(logger, path), nil
}
return nil, newLangUnsupportedError(lang)
}

type appsClient interface {
AddHeader(string, string)
}

func addTurbineHeaders(c appsClient, lang ir.Lang, version string) {
c.AddHeader("Meroxa-CLI-App-Lang", string(lang))
if lang == ir.JavaScript {
version = fmt.Sprintf("%s:cli%s", version, turbineJS.TurbineJSVersion)
}
c.AddHeader("Meroxa-CLI-App-Version", version)
}

func RetrieveApplicationByNameOrID(ctx context.Context, client global.BasicClient, nameOrID, path string) (*Applications, error) {
var getPath string
apps := Applications{}
if path != "" {
var err error
if getPath, err = turbine.GetPath(path); err != nil {
if getPath, err = GetPath(path); err != nil {
return nil, err
}

config, err := turbine.ReadConfigFile(getPath)
config, err := ReadConfigFile(getPath)
if err != nil {
return nil, err
}

a := &url.Values{}
a.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", config.Name, config.Name))

response, err := client.CollectionRequest(ctx, "GET", collectionName, "", nil, *a)
response, err := client.CollectionRequest(ctx, "GET", applicationCollection, "", nil, *a)
if err != nil {
return nil, err
}
Expand All @@ -198,7 +177,7 @@ func RetrieveApplicationByNameOrID(ctx context.Context, client global.BasicClien
a := &url.Values{}
a.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", nameOrID, nameOrID))

response, err := client.CollectionRequest(ctx, "GET", collectionName, "", nil, *a)
response, err := client.CollectionRequest(ctx, "GET", applicationCollection, "", nil, *a)
if err != nil {
return nil, err
}
Expand Down
Loading