Skip to content

Commit

Permalink
feat: Makes pipeline name required when creating connectors (#189)
Browse files Browse the repository at this point in the history
* feat: Make pipeline required creating connectors

Fixes meroxa/product#128

It also makes ID to be a valid input when creating pipelines

* fix: Accept pipeline names only for now

I believe this should be changed everywhere so users know accurately when it can be an ID or not.
  • Loading branch information
raulb authored Sep 7, 2021
1 parent 3e6660a commit a84d31e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
26 changes: 14 additions & 12 deletions cmd/meroxa/root/connectors/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ type Create struct {
}

flags struct {
Input string `long:"input" short:"" usage:"command delimited list of input streams"`
Config string `long:"config" short:"c" usage:"connector configuration"`
Metadata string `long:"metadata" short:"m" usage:"connector metadata" hidden:"true"`
Source string `long:"from" short:"" usage:"resource name to use as source"`
Destination string `long:"to" short:"" usage:"resource name to use as destination"`
Pipeline string `long:"pipeline" short:"" usage:"pipeline name to attach connector to"`
Input string `long:"input" usage:"command delimited list of input streams"`
Config string `long:"config" short:"c" usage:"connector configuration"`
Metadata string `long:"metadata" short:"m" usage:"connector metadata" hidden:"true"`
Source string `long:"from" usage:"resource name to use as source"`
Destination string `long:"to" usage:"resource name to use as destination"`
Pipeline string `long:"pipeline" usage:"pipeline name to attach connector to" required:"true"`
}
}

Expand All @@ -66,10 +66,10 @@ func (c *Create) Usage() string {
func (c *Create) Docs() builder.Docs {
return builder.Docs{
Short: "Create a connector",
Long: "Use `connectors create` to create a connector from a source (--from) or to a destination (--to)",
Long: "Use `connectors create` to create a connector from a source (--from) or to a destination (--to) within a pipeline (--pipeline)",
Example: "\n" +
"meroxa connectors create [NAME] --from pg2kafka --input accounts \n" +
"meroxa connectors create [NAME] --to pg2redshift --input orders # --input will be the desired stream \n" +
"meroxa connectors create [NAME] --from pg2kafka --input accounts --pipeline my-pipeline\n" +
"meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline # --input will be the desired stream\n" +
"meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline\n",
}
}
Expand Down Expand Up @@ -123,13 +123,15 @@ func (c *Create) CreateConnector(ctx context.Context) (*meroxa.Connector, error)
c.logger.Infof(ctx, "Creating connector to destination %q...\n", resourceName)
}

return c.client.CreateConnector(ctx, meroxa.CreateConnectorInput{
ci := meroxa.CreateConnectorInput{
Name: c.args.Name,
ResourceID: res.ID,
PipelineName: c.flags.Pipeline,
Configuration: config,
Metadata: metadata,
})
PipelineName: c.flags.Pipeline,
}

return c.client.CreateConnector(ctx, ci)
}

func (c *Create) Execute(ctx context.Context) error {
Expand Down
9 changes: 5 additions & 4 deletions cmd/meroxa/root/connectors/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ func TestCreateConnectorFlags(t *testing.T) {
shorthand string
hidden bool
}{
{name: "input", required: false, shorthand: "", hidden: false},
{name: "config", required: false, shorthand: "c", hidden: false},
{name: "from", required: false, shorthand: "", hidden: false},
{name: "to", required: false, shorthand: "", hidden: false},
{name: "input", required: false},
{name: "config", required: false, shorthand: "c"},
{name: "from", required: false},
{name: "to", required: false},
{name: "metadata", required: false, shorthand: "m", hidden: true},
{name: "pipeline", required: true},
}

c := builder.BuildCobraCommand(&Create{})
Expand Down
6 changes: 3 additions & 3 deletions docs/cmd/md/meroxa_connectors_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Create a connector

### Synopsis

Use `connectors create` to create a connector from a source (--from) or to a destination (--to)
Use `connectors create` to create a connector from a source (--from) or to a destination (--to) within a pipeline (--pipeline)

```
meroxa connectors create [NAME] [flags]
Expand All @@ -14,8 +14,8 @@ meroxa connectors create [NAME] [flags]

```
meroxa connectors create [NAME] --from pg2kafka --input accounts
meroxa connectors create [NAME] --to pg2redshift --input orders # --input will be the desired stream
meroxa connectors create [NAME] --from pg2kafka --input accounts --pipeline my-pipeline
meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline # --input will be the desired stream
meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline
```
Expand Down
6 changes: 3 additions & 3 deletions docs/cmd/www/meroxa-connectors-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Create a connector

### Synopsis

Use `connectors create` to create a connector from a source (--from) or to a destination (--to)
Use `connectors create` to create a connector from a source (--from) or to a destination (--to) within a pipeline (--pipeline)

```
meroxa connectors create [NAME] [flags]
Expand All @@ -21,8 +21,8 @@ meroxa connectors create [NAME] [flags]

```
meroxa connectors create [NAME] --from pg2kafka --input accounts
meroxa connectors create [NAME] --to pg2redshift --input orders # --input will be the desired stream
meroxa connectors create [NAME] --from pg2kafka --input accounts --pipeline my-pipeline
meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline # --input will be the desired stream
meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pipeline
```
Expand Down
1 change: 1 addition & 0 deletions etc/completion/meroxa.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ _meroxa_connectors_create()
two_word_flags+=("--timeout")

must_have_one_flag=()
must_have_one_flag+=("--pipeline=")
must_have_one_noun=()
noun_aliases=()
}
Expand Down
6 changes: 3 additions & 3 deletions etc/man/man1/meroxa-connectors-create.1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ meroxa\-connectors\-create \- Create a connector

.SH DESCRIPTION
.PP
Use \fB\fCconnectors create\fR to create a connector from a source (\-\-from) or to a destination (\-\-to)
Use \fB\fCconnectors create\fR to create a connector from a source (\-\-from) or to a destination (\-\-to) within a pipeline (\-\-pipeline)


.SH OPTIONS
Expand Down Expand Up @@ -62,8 +62,8 @@ Use \fB\fCconnectors create\fR to create a connector from a source (\-\-from) or

.nf

meroxa connectors create [NAME] \-\-from pg2kafka \-\-input accounts
meroxa connectors create [NAME] \-\-to pg2redshift \-\-input orders # \-\-input will be the desired stream
meroxa connectors create [NAME] \-\-from pg2kafka \-\-input accounts \-\-pipeline my\-pipeline
meroxa connectors create [NAME] \-\-to pg2redshift \-\-input orders \-\-pipeline my\-pipeline # \-\-input will be the desired stream
meroxa connectors create [NAME] \-\-to pg2redshift \-\-input orders \-\-pipeline my\-pipeline


Expand Down

0 comments on commit a84d31e

Please sign in to comment.