Skip to content

Commit 03a990d

Browse files
author
Sarah Sicard
committed
add support for conduit version 13
1 parent 921f573 commit 03a990d

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

internal/conduit/version.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,29 @@ func NewFlags(fns ...func(*Args)) *Flags {
2626
}
2727

2828
func (f *Flags) ForVersion(ver string) []string {
29-
verConstraint, _ := semver.NewConstraint("< 0.12.0")
29+
constraints := map[string]string{
30+
"v011": "< 0.12.0",
31+
"v012": ">= 0.12.0, < 0.13.0",
32+
}
33+
3034
sanitized, _ := strings.CutPrefix(ver, "v")
3135
v, _ := semver.NewVersion(sanitized)
3236

33-
if verConstraint.Check(v) {
34-
return f.version011()
37+
for key, rule := range constraints {
38+
c, _ := semver.NewConstraint(rule)
39+
if c.Check(v) {
40+
switch key {
41+
case "v011":
42+
return f.v011()
43+
case "v012":
44+
return f.v012()
45+
}
46+
}
3547
}
36-
return f.version012()
48+
return f.v013()
3749
}
3850

39-
func (f *Flags) version011() []string {
51+
func (f *Flags) v011() []string {
4052
return []string{
4153
"/app/conduit",
4254
"-pipelines.path", f.args.PipelineFile,
@@ -48,7 +60,7 @@ func (f *Flags) version011() []string {
4860
}
4961
}
5062

51-
func (f *Flags) version012() []string {
63+
func (f *Flags) v012() []string {
5264
return []string{
5365
"/app/conduit",
5466
"--pipelines.path", f.args.PipelineFile,
@@ -60,6 +72,18 @@ func (f *Flags) version012() []string {
6072
}
6173
}
6274

75+
func (f *Flags) v013() []string {
76+
return []string{
77+
"/app/conduit run",
78+
"--pipelines.path", f.args.PipelineFile,
79+
"--connectors.path", f.args.ConnectorsPath,
80+
"--db.type", "sqlite",
81+
"--db.sqlite.path", f.args.DBPath,
82+
"--pipelines.exit-on-degraded",
83+
"--processors.path", f.args.ProcessorsPath,
84+
}
85+
}
86+
6387
func WithPipelineFile(file string) func(*Args) {
6488
return func(a *Args) {
6589
a.PipelineFile = file

internal/conduit/version_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Test_ForVersion(t *testing.T) {
2828
},
2929
},
3030
{
31-
name: "with version more than 0.12",
31+
name: "with version of 0.12",
3232
version: "v0.12.0",
3333
want: []string{
3434
"/app/conduit",
@@ -40,6 +40,19 @@ func Test_ForVersion(t *testing.T) {
4040
"--processors.path", "/conduit.storage/processors",
4141
},
4242
},
43+
{
44+
name: "with version greater than 0.12",
45+
version: "v0.13.0",
46+
want: []string{
47+
"/app/conduit run",
48+
"--pipelines.path", "/conduit.pipelines/pipeline.yaml",
49+
"--connectors.path", "/conduit.storage/connectors",
50+
"--db.type", "sqlite",
51+
"--db.sqlite.path", "/conduit.storage/db",
52+
"--pipelines.exit-on-degraded",
53+
"--processors.path", "/conduit.storage/processors",
54+
},
55+
},
4356
}
4457

4558
for _, tc := range tests {

0 commit comments

Comments
 (0)