Skip to content

Commit 725bf81

Browse files
absorb new meroxa-go interface; small doc changes (#217)
* Small doc changes * absord new meroxa-go interface * very subtle type mismatches * formatting * lint and updated interface * tests * try different version of linter * lint * latest interface changes * feedback, formatting * no flag changes * test connector metadata * no doc changes * lint * lint * lint * lint again * chore: Use latest meroxa-go and update docs Co-authored-by: Raúl Barroso <ra.barroso@gmail.com>
1 parent 80d8ac9 commit 725bf81

File tree

238 files changed

+3166
-2658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+3166
-2658
lines changed

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
- name: golangci-lint
1111
uses: golangci/golangci-lint-action@v2
1212
with:
13-
version: v1.42.0
13+
version: v1.43.0

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ make gomod
5555
make build
5656
```
5757

58+
### Development Configuration
59+
The [meroxa-dev CLI](https://github.com/meroxa/meroxa-dev#install) makes it convenient to set the necessary env vars for different dev environments.
60+
5861
## Release
5962

6063
A [goreleaser](https://github.com/goreleaser/goreleaser) GitHub Action is
@@ -123,4 +126,4 @@ Verify the correct setup, by running ` cat ~/.gitconfig`. You should see the fol
123126
insteadOf = https://github.com
124127
```
125128

126-
Run the `make gomod` command again, and you should see all depedencies being downloaded successfully.
129+
Run the `make gomod` command again, and you should see all dependencies being downloaded successfully.

cmd/meroxa/builder/builder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"github.com/meroxa/cli/cmd/meroxa/global"
3434
"github.com/meroxa/cli/config"
3535
"github.com/meroxa/cli/log"
36-
"github.com/meroxa/meroxa-go"
36+
"github.com/meroxa/meroxa-go/pkg/meroxa"
3737
)
3838

3939
type Command interface {
@@ -64,7 +64,7 @@ type CommandWithArgs interface {
6464
type CommandWithClient interface {
6565
Command
6666
// Client provides the meroxa client to the command.
67-
Client(*meroxa.Client)
67+
Client(meroxa.Client)
6868
}
6969

7070
type CommandWithConfig interface {

cmd/meroxa/global/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"time"
2626

2727
"github.com/spf13/viper"
28-
29-
"github.com/meroxa/meroxa-go"
3028
"golang.org/x/oauth2"
29+
30+
"github.com/meroxa/meroxa-go/pkg/meroxa"
3131
)
3232

3333
func noUserInfo(actor, actorUUID string) bool {
@@ -118,7 +118,7 @@ func GetUserToken() (accessToken, refreshToken string, err error) {
118118
return accessToken, refreshToken, nil
119119
}
120120

121-
func NewClient() (*meroxa.Client, error) {
121+
func NewClient() (meroxa.Client, error) {
122122
accessToken, refreshToken, err := GetUserToken()
123123

124124
if err != nil {

cmd/meroxa/global/logger.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package global
1818

1919
import (
20-
"io/ioutil"
20+
"io"
2121
"os"
2222

2323
"github.com/meroxa/cli/log"
@@ -27,7 +27,7 @@ func NewLogger() log.Logger {
2727
var (
2828
logLevel = log.Info
2929
leveledLoggerOut = os.Stdout
30-
jsonLoggerOut = ioutil.Discard
30+
jsonLoggerOut = io.Discard
3131
)
3232

3333
if flagJSON {

cmd/meroxa/root/api/api.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import (
2121
"context"
2222
"encoding/json"
2323
"errors"
24-
"io/ioutil"
24+
"io"
2525
"net/http"
2626
"net/url"
2727
"strings"
2828

2929
"github.com/meroxa/cli/log"
30-
"github.com/meroxa/meroxa-go"
30+
"github.com/meroxa/meroxa-go/pkg/meroxa"
3131

3232
"github.com/meroxa/cli/cmd/meroxa/builder"
3333
)
@@ -68,7 +68,7 @@ meroxa api POST /v1/endpoints '{"protocol": "HTTP", "stream": "resource-2-499379
6868
}
6969
}
7070

71-
func (a *API) Client(client *meroxa.Client) {
71+
func (a *API) Client(client meroxa.Client) {
7272
a.client = client
7373
}
7474

@@ -98,7 +98,7 @@ func (a *API) Execute(ctx context.Context) error {
9898
}
9999
defer resp.Body.Close()
100100

101-
b, err := ioutil.ReadAll(resp.Body)
101+
b, err := io.ReadAll(resp.Body)
102102
if err != nil {
103103
return err
104104
}

cmd/meroxa/root/api/api_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import (
2121
"context"
2222
"errors"
2323
"fmt"
24-
"io/ioutil"
24+
"io"
2525
"net/http"
2626
"strings"
2727
"testing"
2828

2929
"github.com/golang/mock/gomock"
3030
"github.com/meroxa/cli/log"
31-
mock "github.com/meroxa/cli/mock-cmd"
31+
"github.com/meroxa/meroxa-go/pkg/mock"
3232
)
3333

3434
func TestDescribeAPIArgs(t *testing.T) {
@@ -92,7 +92,7 @@ func TestDescribeAPIArgs(t *testing.T) {
9292
func TestAPIExecution(t *testing.T) {
9393
ctx := context.Background()
9494
ctrl := gomock.NewController(t)
95-
client := mock.NewMockAPIClient(ctrl)
95+
client := mock.NewMockClient(ctrl)
9696
logger := log.NewTestLogger()
9797

9898
a := &API{
@@ -107,7 +107,7 @@ func TestAPIExecution(t *testing.T) {
107107
var httpResponse = &http.Response{
108108
Status: "200 OK",
109109
StatusCode: 200,
110-
Body: ioutil.NopCloser(bytes.NewReader([]byte(bodyResponse))),
110+
Body: io.NopCloser(bytes.NewReader([]byte(bodyResponse))),
111111
}
112112

113113
client.

cmd/meroxa/root/auth/login.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"io"
24-
"io/ioutil"
2524
"net"
2625
"net/http"
2726
"net/url"
@@ -232,7 +231,7 @@ func (l *Login) getAccessTokenAuth(
232231
// process the response
233232
defer res.Body.Close()
234233
var responseData map[string]interface{}
235-
body, _ := ioutil.ReadAll(res.Body)
234+
body, _ := io.ReadAll(res.Body)
236235

237236
// unmarshal the json into a string map
238237
err = json.Unmarshal(body, &responseData)

cmd/meroxa/root/auth/whoami.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/meroxa/cli/cmd/meroxa/builder"
2727
"github.com/meroxa/cli/config"
2828
"github.com/meroxa/cli/log"
29-
"github.com/meroxa/meroxa-go"
29+
"github.com/meroxa/meroxa-go/pkg/meroxa"
3030
)
3131

3232
type getUserClient interface {
@@ -58,7 +58,7 @@ func (w *WhoAmI) Docs() builder.Docs {
5858
}
5959
}
6060

61-
func (w *WhoAmI) Client(client *meroxa.Client) {
61+
func (w *WhoAmI) Client(client meroxa.Client) {
6262
w.client = client
6363
}
6464

cmd/meroxa/root/auth/whoami_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import (
1111

1212
"github.com/meroxa/cli/config"
1313
"github.com/meroxa/cli/log"
14-
"github.com/meroxa/meroxa-go"
14+
"github.com/meroxa/meroxa-go/pkg/meroxa"
1515

1616
"github.com/golang/mock/gomock"
17-
mock "github.com/meroxa/cli/mock-cmd"
17+
"github.com/meroxa/meroxa-go/pkg/mock"
1818
)
1919

2020
func TestWhoAmIExecution(t *testing.T) {
2121
ctx := context.Background()
2222
ctrl := gomock.NewController(t)
23-
client := mock.NewMockGetUserClient(ctrl)
23+
client := mock.NewMockClient(ctrl)
2424
logger := log.NewTestLogger()
2525

2626
cfg := config.NewInMemoryConfig()

cmd/meroxa/root/connectors/connect.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package connectors
1919
import (
2020
"context"
2121

22-
"github.com/meroxa/meroxa-go"
22+
"github.com/meroxa/meroxa-go/pkg/meroxa"
2323

2424
"github.com/meroxa/cli/cmd/meroxa/builder"
2525
"github.com/meroxa/cli/log"
@@ -37,7 +37,7 @@ type Connect struct {
3737
}
3838
}
3939

40-
func (c *Connect) Client(client *meroxa.Client) {
40+
func (c *Connect) Client(client meroxa.Client) {
4141
c.client = client
4242
}
4343

cmd/meroxa/root/connectors/connect_test.go

+19-20
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import (
2424
"testing"
2525

2626
"github.com/golang/mock/gomock"
27-
"github.com/meroxa/cli/log"
28-
mock "github.com/meroxa/cli/mock-cmd"
29-
"github.com/meroxa/meroxa-go"
3027

3128
"github.com/meroxa/cli/cmd/meroxa/builder"
29+
"github.com/meroxa/cli/log"
3230
"github.com/meroxa/cli/utils"
31+
"github.com/meroxa/meroxa-go/pkg/meroxa"
32+
"github.com/meroxa/meroxa-go/pkg/mock"
3333
)
3434

3535
func TestConnectFlags(t *testing.T) {
@@ -67,7 +67,7 @@ func TestConnectFlags(t *testing.T) {
6767
func TestConnectExecution(t *testing.T) {
6868
ctx := context.Background()
6969
ctrl := gomock.NewController(t)
70-
client := mock.NewMockCreateConnectorClient(ctrl)
70+
client := mock.NewMockClient(ctrl)
7171
logger := log.NewTestLogger()
7272

7373
c := &Connect{
@@ -85,15 +85,15 @@ func TestConnectExecution(t *testing.T) {
8585
c.flags.Pipeline = "my-pipeline"
8686

8787
cSource := utils.GenerateConnector(0, "")
88-
cSource.Metadata = map[string]interface{}{"mx:connectorType": "source"}
88+
cSource.Type = meroxa.ConnectorTypeSource
8989

9090
cDestination := utils.GenerateConnector(0, "")
91-
cDestination.Metadata = map[string]interface{}{"mx:connectorType": "destination"}
91+
cDestination.Type = meroxa.ConnectorTypeDestination
9292

9393
// Create source
9494
client.
9595
EXPECT().
96-
GetResourceByName(
96+
GetResourceByNameOrID(
9797
ctx,
9898
rSource.Name,
9999
).
@@ -103,45 +103,44 @@ func TestConnectExecution(t *testing.T) {
103103
EXPECT().
104104
CreateConnector(
105105
ctx,
106-
meroxa.CreateConnectorInput{
106+
&meroxa.CreateConnectorInput{
107107
Name: "",
108108
ResourceID: rSource.ID,
109109
Configuration: map[string]interface{}{
110-
"key": "value",
111-
"input": "my-resource.Table",
112-
},
113-
Metadata: map[string]interface{}{
114-
"mx:connectorType": "source",
110+
"key": "value",
115111
},
112+
Metadata: map[string]interface{}{},
116113
PipelineName: c.flags.Pipeline,
114+
Input: "my-resource.Table",
115+
Type: meroxa.ConnectorTypeSource,
117116
},
118117
).
119118
Return(&cSource, nil)
120119

121120
// Create destination
122121
client.
123122
EXPECT().
124-
GetResourceByName(
123+
GetResourceByNameOrID(
125124
ctx,
126125
rDestination.Name,
127126
).
127+
AnyTimes().
128128
Return(&rDestination, nil)
129129

130130
client.
131131
EXPECT().
132132
CreateConnector(
133133
ctx,
134-
meroxa.CreateConnectorInput{
134+
&meroxa.CreateConnectorInput{
135135
Name: "",
136136
ResourceID: rDestination.ID,
137137
Configuration: map[string]interface{}{
138-
"key": "value",
139-
"input": "my-resource.Table",
140-
},
141-
Metadata: map[string]interface{}{
142-
"mx:connectorType": "destination",
138+
"key": "value",
143139
},
140+
Metadata: map[string]interface{}{},
144141
PipelineName: c.flags.Pipeline,
142+
Input: "my-resource.Table",
143+
Type: meroxa.ConnectorTypeDestination,
145144
},
146145
).
147146
Return(&cDestination, nil)

0 commit comments

Comments
 (0)