Skip to content

Commit 40aff2f

Browse files
author
Phani Raj
authored
Merge pull request #59 from planetscale/fix-oneOf
Adhere to oneOf schema rules in PlanetScale source specification.
2 parents 26d5168 + 0038c85 commit 40aff2f

5 files changed

Lines changed: 6 additions & 193 deletions

File tree

cmd/airbyte-source/spec.go

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package airbyte_source
22

33
import (
4-
"encoding/json"
54
"fmt"
65

7-
"github.com/planetscale/airbyte-source/cmd/internal"
6+
_ "embed"
87
"github.com/spf13/cobra"
98
)
109

10+
//go:embed spec.json
11+
var staticSpec string
12+
1113
func init() {
1214
rootCmd.AddCommand(SpecCommand())
1315
}
@@ -17,79 +19,8 @@ func SpecCommand() *cobra.Command {
1719
Use: "spec",
1820
Short: "Describes inputs needed for connecting to PlanetScale databases",
1921
Run: func(cmd *cobra.Command, args []string) {
20-
specMessage := internal.SpecMessage{
21-
Type: "SPEC",
22-
Spec: internal.Spec{
23-
DocumentationURL: "https://planetscale.com/docs/integrations/airbyte",
24-
SupportedDestinationSyncModes: []string{
25-
"overwrite",
26-
},
27-
SupportsIncremental: true,
28-
ConnectionSpecification: internal.ConnectionSpecification{
29-
Schema: "http://json-schema.org/draft-07/schema#",
30-
Type: "object",
31-
Title: "PlanetScale Source Spec",
32-
Required: []string{"host", "database", "username", "password"},
33-
Properties: internal.ConnectionProperties{
34-
Host: internal.ConnectionProperty{
35-
Description: "The host name of the database.",
36-
Title: "Host",
37-
Type: "string",
38-
Order: 0,
39-
},
40-
Database: internal.ConnectionProperty{
41-
Title: "Database",
42-
Description: "The PlanetScale database name.",
43-
Type: "string",
44-
Order: 1,
45-
},
46-
Username: internal.ConnectionProperty{
47-
Description: "The username which is used to access the database.",
48-
Title: "Username",
49-
Type: "string",
50-
Order: 2,
51-
},
52-
Password: internal.ConnectionProperty{
53-
Description: "The password associated with the username.",
54-
Title: "Password",
55-
Type: "string",
56-
Order: 3,
57-
IsSecret: true,
58-
},
59-
Shards: internal.ConnectionProperty{
60-
Description: "Comma separated list of shards you'd like to sync, by default all shards are synced.",
61-
Title: "Shards",
62-
Type: "string",
63-
Order: 4,
64-
},
65-
Options: internal.CustomOptionsSpecification{
66-
Order: 5,
67-
Type: "object",
68-
Title: "Custom configuration options",
69-
Description: "Configuration options to customize PlanetScale source",
70-
Options: []internal.CustomOptions{
71-
{
72-
Type: "object",
73-
Title: "options",
74-
Description: "options",
75-
Properties: internal.CustomOptionsProperties{
76-
DoNotTreatTinyIntAsBoolean: internal.ConnectionProperty{
77-
Description: "If enabled, properties of type TinyInt(1) are output as TinyInt, and not boolean.",
78-
Title: "Do Not Treat TinyInt(1) as boolean",
79-
Type: "boolean",
80-
Order: 5,
81-
},
82-
},
83-
},
84-
},
85-
},
86-
},
87-
},
88-
},
89-
}
22+
fmt.Fprintf(cmd.OutOrStdout(), "%s\n", staticSpec)
9023

91-
msg, _ := json.Marshal(specMessage)
92-
fmt.Fprintf(cmd.OutOrStdout(), "%s\n", string(msg))
9324
},
9425
}
9526
}

cmd/airbyte-source/spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"SPEC","spec":{"documentationUrl":"https://planetscale.com/docs/integrations/airbyte","connectionSpecification":{"$schema":"http://json-schema.org/draft-07/schema#","title":"PlanetScale Source Spec","type":"object","required":["host","database","username","password"],"additionalProperties":false,"properties":{"host":{"description":"The host name of the database.","title":"Host","type":"string","order":0},"shards":{"description":"Comma separated list of shards you'd like to sync, by default all shards are synced.","title":"Shards","type":"string","order":4},"database":{"description":"The PlanetScale database name.","title":"Database","type":"string","order":1},"username":{"description":"The username which is used to access the database.","title":"Username","type":"string","order":2},"password":{"description":"The password associated with the username.","title":"Password","type":"string","order":3,"airbyte_secret":true},"options":{"type":"object","title":"Customize serialization","description":"The storage Provider or Location of the file(s) which should be replicated.","default":"Public Web","oneOf":[{"title":"tinyint(1) serialization","required":["do_not_treat_tiny_int_as_boolean"],"properties":{"storage":{"type":"string","const":"HTTPS"},"do_not_treat_tiny_int_as_boolean":{"type":"boolean","title":"Do not treat tinyint(1) as boolean","default":false,"description":"If enabled, properties of type TinyInt(1) are output as TinyInt, and not boolean."}}}]}}}}}

cmd/airbyte-source/spec_test.go

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

cmd/internal/logger.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ func (a *airbyteLogger) Log(level, message string) {
4242
})
4343
}
4444

45-
func (a *airbyteLogger) Spec(spec Spec) {
46-
}
47-
4845
func (a *airbyteLogger) Catalog(catalog Catalog) {
4946
a.recordEncoder.Encode(AirbyteMessage{
5047
Type: CATALOG,

cmd/internal/types.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -160,78 +160,3 @@ type AirbyteMessage struct {
160160
Record *AirbyteRecord `json:"record,omitempty"`
161161
State *AirbyteState `json:"state,omitempty"`
162162
}
163-
164-
type SpecMessage struct {
165-
Type string `json:"type"`
166-
Spec Spec `json:"spec"`
167-
}
168-
169-
type ConnectionPropertyHash struct {
170-
Description string `json:"description"`
171-
Title string `json:"title"`
172-
Type string `json:"type"`
173-
Order int `json:"order"`
174-
Options []ConnectionPropertyHashProperties `json:"oneOf"`
175-
}
176-
177-
type ConnectionPropertyHashProperties struct {
178-
DoNotTreatTinyIntAsBoolean ConnectionProperty `json:"do_not_treat_tiny_int_as_boolean"`
179-
}
180-
181-
type CustomOptionsSpecification struct {
182-
Description string `json:"description"`
183-
Title string `json:"title"`
184-
Type string `json:"type"`
185-
Order int `json:"order"`
186-
Options []CustomOptions `json:"oneOf"`
187-
}
188-
189-
type CustomOptions struct {
190-
Description string `json:"description"`
191-
Title string `json:"title"`
192-
Type string `json:"type"`
193-
Order int `json:"order"`
194-
Properties CustomOptionsProperties `json:"properties"`
195-
}
196-
197-
type CustomOptionsProperties struct {
198-
DoNotTreatTinyIntAsBoolean ConnectionProperty `json:"do_not_treat_tiny_int_as_boolean"`
199-
}
200-
201-
type ConnectionProperties struct {
202-
Host ConnectionProperty `json:"host"`
203-
Shards ConnectionProperty `json:"shards"`
204-
Database ConnectionProperty `json:"database"`
205-
Username ConnectionProperty `json:"username"`
206-
Password ConnectionProperty `json:"password"`
207-
Options CustomOptionsSpecification `json:"options"`
208-
}
209-
210-
type ConnectionProperty struct {
211-
Description string `json:"description"`
212-
Title string `json:"title"`
213-
Type string `json:"type"`
214-
Order int `json:"order"`
215-
IsSecret bool `json:"airbyte_secret,omitempty"`
216-
Minimum int `json:"minimum,omitempty"`
217-
Maximum int `json:"maximum,omitempty"`
218-
Default interface{} `json:"default,omitempty"`
219-
}
220-
221-
type ConnectionSpecification struct {
222-
Schema string `json:"$schema"`
223-
Title string `json:"title"`
224-
Type string `json:"type"`
225-
Required []string `json:"required"`
226-
AdditionalProperties bool `json:"additionalProperties"`
227-
Properties ConnectionProperties `json:"properties"`
228-
}
229-
230-
type Spec struct {
231-
DocumentationURL string `json:"documentationUrl"`
232-
ConnectionSpecification ConnectionSpecification `json:"connectionSpecification"`
233-
SupportsIncremental bool `json:"supportsIncremental"`
234-
SupportsNormalization bool `json:"supportsNormalization"`
235-
SupportsDBT bool `json:"supportsDBT"`
236-
SupportedDestinationSyncModes []string `json:"supported_destination_sync_modes"`
237-
}

0 commit comments

Comments
 (0)