Skip to content

Commit 0814fec

Browse files
authored
refactor: restructure for internal/service (#166)
1 parent 764b9d4 commit 0814fec

24 files changed

+518
-645
lines changed

internal/cmd/local/local/log_utils.go renamed to internal/airbyte/log_scanner.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
package local
1+
package airbyte
22

33
import (
44
"bufio"
55
"encoding/json"
66
"io"
77
)
88

9-
type logScanner struct {
9+
// LogScanner
10+
type LogScanner struct {
1011
scanner *bufio.Scanner
11-
line logLine
12+
Line logLine
1213
}
1314

14-
func newLogScanner(r io.Reader) *logScanner {
15-
return &logScanner{
15+
// NewLogScanner returns an initialized Airbyte log scanner.
16+
func NewLogScanner(r io.Reader) *LogScanner {
17+
return &LogScanner{
1618
scanner: bufio.NewScanner(r),
1719
}
1820
}
1921

20-
func (j *logScanner) Scan() bool {
22+
func (j *LogScanner) Scan() bool {
2123
for {
2224
if ok := j.scanner.Scan(); !ok {
2325
return false
@@ -27,16 +29,16 @@ func (j *logScanner) Scan() bool {
2729
err := json.Unmarshal(j.scanner.Bytes(), &data)
2830
// not all lines are JSON. don't propogate errors, just include the full line.
2931
if err != nil {
30-
j.line = logLine{Message: j.scanner.Text()}
32+
j.Line = logLine{Message: j.scanner.Text()}
3133
} else {
32-
j.line = data
34+
j.Line = data
3335
}
3436

3537
return true
3638
}
3739
}
3840

39-
func (j *logScanner) Err() error {
41+
func (j *LogScanner) Err() error {
4042
return j.scanner.Err()
4143
}
4244

internal/cmd/local/local/log_utils_test.go renamed to internal/airbyte/log_scanner_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package local
1+
package airbyte
22

33
import (
44
"strings"
@@ -11,16 +11,16 @@ nonjsonline
1111
`)
1212

1313
func TestJavaLogScanner(t *testing.T) {
14-
s := newLogScanner(strings.NewReader(testLogs))
14+
s := NewLogScanner(strings.NewReader(testLogs))
1515

1616
expectLogLine := func(level, msg string) {
1717
s.Scan()
1818

19-
if s.line.Level != level {
20-
t.Errorf("expected level %q but got %q", level, s.line.Level)
19+
if s.Line.Level != level {
20+
t.Errorf("expected level %q but got %q", level, s.Line.Level)
2121
}
22-
if s.line.Message != msg {
23-
t.Errorf("expected msg %q but got %q", msg, s.line.Message)
22+
if s.Line.Message != msg {
23+
t.Errorf("expected msg %q but got %q", msg, s.Line.Message)
2424
}
2525
if s.Err() != nil {
2626
t.Errorf("unexpected error %v", s.Err())

internal/cmd/local/command.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

internal/cmd/local/local_credentials.go renamed to internal/cmd/local/credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66

77
"github.com/airbytehq/abctl/internal/airbyte"
8-
"github.com/airbytehq/abctl/internal/cmd/local/local"
98
"github.com/airbytehq/abctl/internal/k8s"
9+
"github.com/airbytehq/abctl/internal/service"
1010
"github.com/airbytehq/abctl/internal/telemetry"
1111
"github.com/pterm/pterm"
1212
"go.opencensus.io/trace"
@@ -33,7 +33,7 @@ func (cc *CredentialsCmd) Run(ctx context.Context, provider k8s.Provider, telCli
3333
spinner := &pterm.DefaultSpinner
3434

3535
return telClient.Wrap(ctx, telemetry.Credentials, func() error {
36-
k8sClient, err := local.DefaultK8s(provider.Kubeconfig, provider.Context)
36+
k8sClient, err := service.DefaultK8s(provider.Kubeconfig, provider.Context)
3737
if err != nil {
3838
pterm.Error.Println("No existing cluster found")
3939
return nil

internal/cmd/local/local_deployments.go renamed to internal/cmd/local/deployments.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/airbytehq/abctl/internal/cmd/local/local"
87
"github.com/airbytehq/abctl/internal/k8s"
8+
"github.com/airbytehq/abctl/internal/service"
99
"github.com/airbytehq/abctl/internal/telemetry"
1010
"github.com/pterm/pterm"
1111
"go.opencensus.io/trace"
@@ -19,7 +19,7 @@ func (d *DeploymentsCmd) Run(ctx context.Context, telClient telemetry.Client, pr
1919
ctx, span := trace.StartSpan(ctx, "local deployments")
2020
defer span.End()
2121

22-
k8sClient, err := local.DefaultK8s(provider.Kubeconfig, provider.Context)
22+
k8sClient, err := service.DefaultK8s(provider.Kubeconfig, provider.Context)
2323
if err != nil {
2424
return err
2525
}

0 commit comments

Comments
 (0)