Skip to content

Commit

Permalink
No longer expose or display IDs (#282)
Browse files Browse the repository at this point in the history
* No longer expose or display IDs
  • Loading branch information
janelletavares authored Mar 25, 2022
1 parent 9b2ca91 commit db7fb1a
Show file tree
Hide file tree
Showing 29 changed files with 217 additions and 300 deletions.
12 changes: 6 additions & 6 deletions cmd/meroxa/root/connectors/connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ func TestConnectExecution(t *testing.T) {
c.flags.Destination = rDestination.Name
c.flags.Pipeline = "my-pipeline"

cSource := utils.GenerateConnector(0, "")
cSource := utils.GenerateConnector("", "")
cSource.Type = meroxa.ConnectorTypeSource

cDestination := utils.GenerateConnector(0, "")
cDestination := utils.GenerateConnector("", "")
cDestination.Type = meroxa.ConnectorTypeDestination

// Create source
Expand All @@ -104,8 +104,8 @@ func TestConnectExecution(t *testing.T) {
CreateConnector(
ctx,
&meroxa.CreateConnectorInput{
Name: "",
ResourceID: rSource.ID,
Name: "",
ResourceName: rSource.Name,
Configuration: map[string]interface{}{
"key": "value",
},
Expand All @@ -132,8 +132,8 @@ func TestConnectExecution(t *testing.T) {
CreateConnector(
ctx,
&meroxa.CreateConnectorInput{
Name: "",
ResourceID: rDestination.ID,
Name: "",
ResourceName: rDestination.Name,
Configuration: map[string]interface{}{
"key": "value",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/connectors/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *Create) CreateConnector(ctx context.Context) (*meroxa.Connector, error)

ci := &meroxa.CreateConnectorInput{
Name: c.args.Name,
ResourceID: res.ID,
ResourceName: res.Name,
PipelineName: c.flags.Pipeline,
Configuration: config,
Metadata: metadata,
Expand Down
6 changes: 3 additions & 3 deletions cmd/meroxa/root/connectors/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,23 @@ func TestCreateConnectorExecution(t *testing.T) {
c.flags.Source = sourceName
c.flags.Pipeline = "my-pipeline"

cr := utils.GenerateConnector(0, "")
cr := utils.GenerateConnector("", "")

client.
EXPECT().
GetResourceByNameOrID(
ctx,
sourceName,
).
Return(&meroxa.Resource{ID: 123}, nil)
Return(&meroxa.Resource{Name: sourceName}, nil)

client.
EXPECT().
CreateConnector(
ctx,
&meroxa.CreateConnectorInput{
Name: "",
ResourceID: 123,
ResourceName: sourceName,
PipelineName: c.flags.Pipeline,
Configuration: map[string]interface{}{
"key": "value",
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/connectors/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestDescribeConnectorExecution(t *testing.T) {

connectorName := "my-connector"

c := utils.GenerateConnector(0, connectorName)
c := utils.GenerateConnector("", connectorName)
c.State = "failed"
c.Trace = "exception goes here"
client.
Expand Down
12 changes: 2 additions & 10 deletions cmd/meroxa/root/connectors/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (

type listConnectorsClient interface {
ListConnectors(ctx context.Context) ([]*meroxa.Connector, error)
ListPipelineConnectors(ctx context.Context, pipelineID int) ([]*meroxa.Connector, error)
ListPipelineConnectors(ctx context.Context, pipelineNameOrID string) ([]*meroxa.Connector, error)
GetPipelineByName(ctx context.Context, name string) (*meroxa.Pipeline, error)
}

Expand Down Expand Up @@ -71,15 +71,7 @@ func (l *List) Execute(ctx context.Context) error {

// Filtering by pipeline name
if l.flags.Pipeline != "" {
var p *meroxa.Pipeline

p, err = l.client.GetPipelineByName(ctx, l.flags.Pipeline)

if err != nil {
return err
}

connectors, err = l.client.ListPipelineConnectors(ctx, p.ID)
connectors, err = l.client.ListPipelineConnectors(ctx, l.flags.Pipeline)

if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions cmd/meroxa/root/connectors/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ import (
"github.com/meroxa/meroxa-go/pkg/mock"
)

func getConnectors(pipelineID int) []*meroxa.Connector {
func getConnectors() []*meroxa.Connector {
var connectors []*meroxa.Connector
c := utils.GenerateConnector(pipelineID, "")
c := utils.GenerateConnector("", "")
connectors = append(connectors, &c)
return connectors
}

func getConnectorsWithEnvironment(pipelineID int) []*meroxa.Connector {
func getConnectorsWithEnvironment(pipelineName string) []*meroxa.Connector {
var connectors []*meroxa.Connector
c := utils.GenerateConnectorWithEnvironment(pipelineID, "", "my-env")
c := utils.GenerateConnectorWithEnvironment(pipelineName, "", "my-env")
connectors = append(connectors, &c)
return connectors
}
Expand Down Expand Up @@ -80,8 +80,8 @@ func TestListConnectorsExecution(t *testing.T) {
client := mock.NewMockClient(ctrl)
logger := log.NewTestLogger()

connectors := getConnectors(1)
connectors = append(connectors, getConnectorsWithEnvironment(1)...)
connectors := getConnectors()
connectors = append(connectors, getConnectorsWithEnvironment("pipeline1")...)

client.
EXPECT().
Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/connectors/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestRemoveConnectorExecution(t *testing.T) {
logger: logger,
}

c := utils.GenerateConnector(0, "")
c := utils.GenerateConnector("", "")
r.args.Name = c.Name

client.
Expand Down
6 changes: 3 additions & 3 deletions cmd/meroxa/root/connectors/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestUpdateConnectorExecutionWithNewState(t *testing.T) {
logger: logger,
}

c := utils.GenerateConnector(0, "")
c := utils.GenerateConnector("", "")
u.args.NameOrID = c.Name
u.flags.State = "pause"

Expand Down Expand Up @@ -166,7 +166,7 @@ func TestUpdateConnectorExecutionWithNewName(t *testing.T) {
logger: logger,
}

c := utils.GenerateConnector(0, "")
c := utils.GenerateConnector("", "")
u.args.NameOrID = c.Name

newName := "new-name"
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestUpdateConnectorExecutionWithNewConfig(t *testing.T) {
logger: logger,
}

c := utils.GenerateConnector(0, "")
c := utils.GenerateConnector("", "")
u.args.NameOrID = c.Name

newConfig := "{\"table.name.format\":\"public.copy\"}"
Expand Down
8 changes: 5 additions & 3 deletions cmd/meroxa/root/pipelines/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"errors"
"fmt"

"github.com/volatiletech/null/v8"

"github.com/google/uuid"

"github.com/meroxa/cli/cmd/meroxa/builder"
Expand Down Expand Up @@ -83,14 +85,14 @@ func (c *Create) Execute(ctx context.Context) error {
}

env = c.flags.Environment
p.Environment = &meroxa.EnvironmentIdentifier{}
p.Environment = &meroxa.EntityIdentifier{}

_, err = uuid.Parse(c.flags.Environment)

if err == nil {
p.Environment.UUID = c.flags.Environment
p.Environment.UUID = null.StringFrom(c.flags.Environment)
} else {
p.Environment.Name = c.flags.Environment
p.Environment.Name = null.StringFrom(c.flags.Environment)
}
} else {
env = string(meroxa.EnvironmentTypeCommon)
Expand Down
25 changes: 12 additions & 13 deletions cmd/meroxa/root/pipelines/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"reflect"
"testing"

"github.com/volatiletech/null/v8"

"github.com/golang/mock/gomock"

"github.com/meroxa/cli/cmd/meroxa/builder"
Expand Down Expand Up @@ -107,7 +109,6 @@ func TestCreatePipelineWithoutEnvironmentExecution(t *testing.T) {
}

p := &meroxa.Pipeline{
ID: 1,
Name: pName,
State: "healthy",
}
Expand Down Expand Up @@ -176,15 +177,14 @@ func TestCreatePipelineWithEnvironmentExecution(t *testing.T) {

pi := &meroxa.CreatePipelineInput{
Name: pName,
Environment: &meroxa.EnvironmentIdentifier{Name: env},
Environment: &meroxa.EntityIdentifier{Name: null.StringFrom(env)},
}

p := &meroxa.Pipeline{
ID: 1,
Name: pName,
Environment: &meroxa.EnvironmentIdentifier{
UUID: "2560fbcc-b9ee-461a-a959-fa5656422dc2",
Name: env,
Environment: &meroxa.EntityIdentifier{
UUID: null.StringFrom("2560fbcc-b9ee-461a-a959-fa5656422dc2"),
Name: null.StringFrom(env),
},
State: "healthy",
}
Expand All @@ -200,7 +200,7 @@ func TestCreatePipelineWithEnvironmentExecution(t *testing.T) {
Return(p, nil)

c.args.Name = pi.Name
c.flags.Environment = pi.Environment.Name
c.flags.Environment = pi.Environment.Name.String

// override feature flags
featureFlags := global.Config.Get(global.UserFeatureFlagsEnv)
Expand Down Expand Up @@ -260,23 +260,22 @@ func TestCreatePipelineWithEnvironmentExecutionWithoutFeatureFlag(t *testing.T)

pi := &meroxa.CreatePipelineInput{
Name: pName,
Environment: &meroxa.EnvironmentIdentifier{Name: env},
Environment: &meroxa.EntityIdentifier{Name: null.StringFrom(env)},
}

p := &meroxa.Pipeline{
ID: 1,
Name: pName,
Environment: &meroxa.EnvironmentIdentifier{
UUID: "2560fbcc-b9ee-461a-a959-fa5656422dc2",
Name: env,
Environment: &meroxa.EntityIdentifier{
UUID: null.StringFrom("2560fbcc-b9ee-461a-a959-fa5656422dc2"),
Name: null.StringFrom(env),
},
State: "healthy",
}

p.Name = pName

c.args.Name = pi.Name
c.flags.Environment = pi.Environment.Name
c.flags.Environment = pi.Environment.Name.String

err := c.Execute(ctx)

Expand Down
2 changes: 1 addition & 1 deletion cmd/meroxa/root/pipelines/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestListPipelinesExecution(t *testing.T) {
var pipelines []*meroxa.Pipeline

rP := meroxa.Pipeline{
ID: 1,
UUID: "9483768f-c384-4b4a-96bf-b80a79a23b5c",
Name: "my-pipeline",
State: "healthy",
}
Expand Down
10 changes: 2 additions & 8 deletions cmd/meroxa/root/pipelines/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

type removePipelineClient interface {
GetPipelineByName(ctx context.Context, name string) (*meroxa.Pipeline, error)
DeletePipeline(ctx context.Context, id int) error
DeletePipeline(ctx context.Context, nameOrID string) error
}

type Remove struct {
Expand Down Expand Up @@ -56,19 +56,13 @@ func (r *Remove) ValueToConfirm(_ context.Context) (wantInput string) {
func (r *Remove) Execute(ctx context.Context) error {
r.logger.Infof(ctx, "Removing pipeline %q...", r.args.Name)

p, err := r.client.GetPipelineByName(ctx, r.args.Name)
if err != nil {
return err
}

err = r.client.DeletePipeline(ctx, p.ID)
err := r.client.DeletePipeline(ctx, r.args.Name)

if err != nil {
return err
}

r.logger.Infof(ctx, "Pipeline %q successfully removed", r.args.Name)
r.logger.JSON(ctx, p)

return nil
}
Expand Down
22 changes: 1 addition & 21 deletions cmd/meroxa/root/pipelines/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ package pipelines

import (
"context"
"encoding/json"
"errors"
"fmt"
"reflect"
"testing"

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

"github.com/golang/mock/gomock"
"github.com/meroxa/cli/log"
"github.com/meroxa/cli/utils"
Expand Down Expand Up @@ -72,12 +68,7 @@ func TestRemovePipelineExecution(t *testing.T) {

client.
EXPECT().
GetPipelineByName(ctx, p.Name).
Return(&p, nil)

client.
EXPECT().
DeletePipeline(ctx, p.ID).
DeletePipeline(ctx, p.Name).
Return(nil)

err := r.Execute(ctx)
Expand All @@ -94,15 +85,4 @@ Pipeline %q successfully removed
if gotLeveledOutput != wantLeveledOutput {
t.Fatalf("expected output:\n%s\ngot:\n%s", wantLeveledOutput, gotLeveledOutput)
}

gotJSONOutput := logger.JSONOutput()
var gotPipeline meroxa.Pipeline
err = json.Unmarshal([]byte(gotJSONOutput), &gotPipeline)
if err != nil {
t.Fatalf("not expected error, got %q", err.Error())
}

if !reflect.DeepEqual(gotPipeline, p) {
t.Fatalf("expected \"%v\", got \"%v\"", p, gotPipeline)
}
}
Loading

0 comments on commit db7fb1a

Please sign in to comment.