Skip to content

Commit 37adb79

Browse files
author
Phani Raj
authored
Merge pull request #53 from planetscale/set_AIRBYTE_ENTRYPOINT
Set AIRBYTE_ENTRYPOINT for docker images generated by goreleaser
2 parents 4913b8c + 303535e commit 37adb79

11 files changed

Lines changed: 26 additions & 42 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.18rc1
3+
ARG GO_VERSION=1.19.2
44
FROM golang:${GO_VERSION}-bullseye AS build
55

66
WORKDIR /airbyte-source
@@ -16,4 +16,5 @@ RUN apt-get update && apt-get upgrade -y && \
1616
rm -rf /var/lib/apt/lists/*
1717

1818
COPY --from=build /connect /usr/local/bin/
19+
ENV AIRBYTE_ENTRYPOINT "/usr/local/bin/connect"
1920
ENTRYPOINT ["/usr/local/bin/connect"]

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.18rc1
3+
ARG GO_VERSION=1.19.2
44
FROM golang:${GO_VERSION}-bullseye AS build
55

66
RUN apt-get update && apt-get upgrade -y && \

Dockerfile.goreleaser

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ RUN apt-get update && apt-get upgrade -y && \
66
rm -rf /var/lib/apt/lists/*
77

88
COPY connect /usr/local/bin/
9+
ENV AIRBYTE_ENTRYPOINT "/usr/local/bin/connect"
910
ENTRYPOINT ["/usr/local/bin/connect"]

cmd/airbyte-source/check_test.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"testing"
109

@@ -20,9 +19,7 @@ func TestCheckFailsWithoutConfig(t *testing.T) {
2019
b := bytes.NewBufferString("")
2120
checkCommand.SetOut(b)
2221
checkCommand.Execute()
23-
out, err := ioutil.ReadAll(b)
24-
assert.NoError(t, err)
25-
assert.Equal(t, "Please provide path to a valid configuration file\n", string(out))
22+
assert.Equal(t, "Please provide path to a valid configuration file\n", b.String())
2623
}
2724

2825
func TestCheckInvalidCatalogJSON(t *testing.T) {
@@ -35,15 +32,13 @@ func TestCheckInvalidCatalogJSON(t *testing.T) {
3532
Logger: internal.NewLogger(os.Stdout),
3633
})
3734
b := bytes.NewBufferString("")
38-
3935
checkCommand.SetArgs([]string{"config source.json"})
4036
checkCommand.SetOut(b)
4137
checkCommand.Flag("config").Value.Set("catalog.json")
4238
checkCommand.Execute()
43-
out, err := ioutil.ReadAll(b)
44-
assert.NoError(t, err)
39+
4540
var amsg internal.AirbyteMessage
46-
err = json.Unmarshal(out, &amsg)
41+
err := json.NewDecoder(b).Decode(&amsg)
4742
assert.NoError(t, err)
4843
assert.Equal(t, internal.CONNECTION_STATUS, amsg.Type)
4944
require.NotNil(t, amsg.ConnectionStatus)
@@ -70,10 +65,9 @@ func TestCheckCredentialsInvalid(t *testing.T) {
7065
checkCommand.SetOut(b)
7166
checkCommand.Flag("config").Value.Set("catalog.json")
7267
checkCommand.Execute()
73-
out, err := ioutil.ReadAll(b)
74-
assert.NoError(t, err)
68+
7569
var amsg internal.AirbyteMessage
76-
err = json.Unmarshal(out, &amsg)
70+
err := json.NewDecoder(b).Decode(&amsg)
7771
require.NoError(t, err)
7872
assert.Equal(t, internal.CONNECTION_STATUS, amsg.Type)
7973
assert.NotNil(t, amsg.ConnectionStatus)
@@ -102,10 +96,9 @@ func TestCheckExecuteSuccessful(t *testing.T) {
10296

10397
checkCommand.Flag("config").Value.Set("catalog.json")
10498
checkCommand.Execute()
105-
out, err := ioutil.ReadAll(b)
106-
assert.NoError(t, err)
99+
107100
var amsg internal.AirbyteMessage
108-
err = json.Unmarshal(out, &amsg)
101+
err := json.NewDecoder(b).Decode(&amsg)
109102
require.NoError(t, err)
110103
assert.Equal(t, internal.CONNECTION_STATUS, amsg.Type)
111104
assert.NotNil(t, amsg.ConnectionStatus)

cmd/airbyte-source/discover_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"testing"
98

109
"github.com/planetscale/airbyte-source/cmd/internal"
@@ -33,10 +32,9 @@ func TestDiscoverInvalidSource(t *testing.T) {
3332
discover.SetOut(b)
3433
discover.Flag("config").Value.Set("catalog.json")
3534
discover.Execute()
36-
out, err := ioutil.ReadAll(b)
37-
assert.NoError(t, err)
35+
3836
var amsg internal.AirbyteMessage
39-
err = json.Unmarshal(out, &amsg)
37+
err := json.NewDecoder(b).Decode(&amsg)
4038
require.NoError(t, err)
4139
assert.Equal(t, internal.CONNECTION_STATUS, amsg.Type)
4240
assert.NotNil(t, amsg.ConnectionStatus)
@@ -67,10 +65,8 @@ func TestDiscoverFailed(t *testing.T) {
6765
discover.SetOut(b)
6866
discover.Flag("config").Value.Set("catalog.json")
6967
discover.Execute()
70-
out, err := ioutil.ReadAll(b)
71-
assert.NoError(t, err)
7268
var amsg internal.AirbyteMessage
73-
err = json.Unmarshal(out, &amsg)
69+
err := json.NewDecoder(b).Decode(&amsg)
7470
require.NoError(t, err)
7571
assert.Equal(t, internal.LOG, amsg.Type)
7672
require.NotNil(t, amsg.Log)

cmd/airbyte-source/helper.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package airbyte_source
22

33
import (
4-
"io"
5-
"io/ioutil"
6-
74
"github.com/planetscale/airbyte-source/cmd/internal"
5+
"io"
6+
"os"
87
)
98

109
type Helper struct {
@@ -20,7 +19,7 @@ type FileReader interface {
2019
type fileReader struct{}
2120

2221
func (f fileReader) ReadFile(path string) ([]byte, error) {
23-
return ioutil.ReadFile(path)
22+
return os.ReadFile(path)
2423
}
2524

2625
func DefaultHelper(w io.Writer) *Helper {

cmd/airbyte-source/read.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"os"
98

109
"github.com/planetscale/airbyte-source/cmd/internal"
@@ -75,7 +74,7 @@ func ReadCommand(ch *Helper) *cobra.Command {
7574

7675
state := ""
7776
if stateFilePath != "" {
78-
b, err := ioutil.ReadFile(stateFilePath)
77+
b, err := os.ReadFile(stateFilePath)
7978
if err != nil {
8079
ch.Logger.Error(fmt.Sprintf("Unable to read state : %v", err))
8180
os.Exit(1)
@@ -173,7 +172,7 @@ func readState(state string, psc internal.PlanetScaleSource, streams []internal.
173172
}
174173

175174
func readCatalog(path string) (c internal.ConfiguredCatalog, err error) {
176-
b, err := ioutil.ReadFile(path)
175+
b, err := os.ReadFile(path)
177176
if err != nil {
178177
return c, err
179178
}

cmd/airbyte-source/spec_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package airbyte_source
33
import (
44
"bytes"
55
"encoding/json"
6-
"io/ioutil"
76
"testing"
87

98
"github.com/planetscale/airbyte-source/cmd/internal"
@@ -15,10 +14,8 @@ func TestSpecExecute(t *testing.T) {
1514
b := bytes.NewBufferString("")
1615
specCommand.SetOut(b)
1716
specCommand.Execute()
18-
out, err := ioutil.ReadAll(b)
19-
assert.NoError(t, err)
2017
var specMessage internal.SpecMessage
21-
err = json.Unmarshal(out, &specMessage)
18+
err := json.NewDecoder(b).Decode(&specMessage)
2219
assert.Nil(t, err, "should unmarshal spec JSON")
2320
assert.Equal(t, "SPEC", specMessage.Type)
2421
assert.NotNil(t, specMessage.Spec)

cmd/e2e/e2e_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package e2e
33
import (
44
"bytes"
55
"encoding/json"
6-
"io/ioutil"
76
"os"
87
"testing"
98

@@ -25,10 +24,8 @@ func TestCheck(t *testing.T) {
2524
b := bytes.NewBufferString("")
2625
checkCommand.SetOut(b)
2726
checkCommand.Execute()
28-
out, err := ioutil.ReadAll(b)
29-
assert.NoError(t, err)
3027
var msg internal.AirbyteMessage
31-
err = json.Unmarshal(out, &msg)
28+
err := json.NewDecoder(b).Decode(&msg)
3229
assert.NoError(t, err)
3330
assert.Equal(t, internal.CONNECTION_STATUS, msg.Type)
3431
require.NotNil(t, msg.ConnectionStatus)
@@ -46,16 +43,14 @@ func TestDiscover(t *testing.T) {
4643
b := bytes.NewBufferString("")
4744
discover.SetOut(b)
4845
discover.Execute()
49-
out, err := ioutil.ReadAll(b)
50-
assert.NoError(t, err)
5146
var msg internal.AirbyteMessage
52-
err = json.Unmarshal(out, &msg)
47+
err := json.NewDecoder(b).Decode(&msg)
5348
assert.NoError(t, err)
5449
assert.Equal(t, internal.CATALOG, msg.Type)
5550
require.NotNil(t, msg.Catalog)
5651
s, err := json.Marshal(msg.Catalog)
5752
assert.NoError(t, err)
58-
fullCatalog, err := ioutil.ReadFile("../../fixture/sakila-db/full_catalog.json")
53+
fullCatalog, err := os.ReadFile("../../fixture/sakila-db/full_catalog.json")
5954
assert.NoError(t, err)
6055
assert.Equal(t, string(fullCatalog), string(s))
6156
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ require (
5050
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
5151
github.com/opentracing/opentracing-go v1.2.0 // indirect
5252
github.com/philhofer/fwd v1.1.1 // indirect
53+
github.com/pires/go-proxyproto v0.6.2 // indirect
5354
github.com/pmezard/go-difflib v1.0.0 // indirect
5455
github.com/prometheus/client_golang v1.12.1 // indirect
5556
github.com/prometheus/client_model v0.2.0 // indirect

0 commit comments

Comments
 (0)