@@ -22,10 +22,10 @@ import (
2222)
2323
2424// Valid source types (must match connectors/factory.go).
25- var validSourceTypes = map [string ]bool {"kafka" : true , "postgresql" : true , "trino" : true }
25+ var validSourceTypes = map [string ]bool {"kafka" : true , "postgresql" : true , "trino" : true , "clickhouse" : true }
2626
2727// Valid sink types (must match connectors/factory.go).
28- var validSinkTypes = map [string ]bool {"kafka" : true , "postgresql" : true , "trino" : true }
28+ var validSinkTypes = map [string ]bool {"kafka" : true , "postgresql" : true , "trino" : true , "clickhouse" : true }
2929
3030// Valid transformation types (must match transformers/factory.go).
3131var validTransformationTypes = map [string ]bool {
@@ -61,7 +61,7 @@ func validateSource(s *SourceSpec, f *field.Path) field.ErrorList {
6161 return all
6262 }
6363 if ! validSourceTypes [s .Type ] {
64- all = append (all , field .NotSupported (f .Child ("type" ), s .Type , []string {"kafka" , "postgresql" , "trino" }))
64+ all = append (all , field .NotSupported (f .Child ("type" ), s .Type , []string {"kafka" , "postgresql" , "trino" , "clickhouse" }))
6565 return all
6666 }
6767 switch s .Type {
@@ -83,6 +83,12 @@ func validateSource(s *SourceSpec, f *field.Path) field.ErrorList {
8383 } else {
8484 all = append (all , validateTrinoSource (s .Trino , f .Child ("trino" ))... )
8585 }
86+ case "clickhouse" :
87+ if s .ClickHouse == nil {
88+ all = append (all , field .Required (f .Child ("clickhouse" ), "clickhouse source configuration is required" ))
89+ } else {
90+ all = append (all , validateClickHouseSource (s .ClickHouse , f .Child ("clickhouse" ))... )
91+ }
8692 }
8793 return all
8894}
@@ -169,7 +175,7 @@ func validateSink(s *SinkSpec, f *field.Path) field.ErrorList {
169175 return all
170176 }
171177 if ! validSinkTypes [s .Type ] {
172- all = append (all , field .NotSupported (f .Child ("type" ), s .Type , []string {"kafka" , "postgresql" , "trino" }))
178+ all = append (all , field .NotSupported (f .Child ("type" ), s .Type , []string {"kafka" , "postgresql" , "trino" , "clickhouse" }))
173179 return all
174180 }
175181 switch s .Type {
@@ -191,6 +197,12 @@ func validateSink(s *SinkSpec, f *field.Path) field.ErrorList {
191197 } else {
192198 all = append (all , validateTrinoSink (s .Trino , f .Child ("trino" ))... )
193199 }
200+ case "clickhouse" :
201+ if s .ClickHouse == nil {
202+ all = append (all , field .Required (f .Child ("clickhouse" ), "clickhouse sink configuration is required" ))
203+ } else {
204+ all = append (all , validateClickHouseSink (s .ClickHouse , f .Child ("clickhouse" ))... )
205+ }
194206 }
195207 return all
196208}
@@ -266,6 +278,44 @@ func validateTrinoSink(t *TrinoSinkSpec, f *field.Path) field.ErrorList {
266278 return all
267279}
268280
281+ func validateClickHouseSource (c * ClickHouseSourceSpec , f * field.Path ) field.ErrorList {
282+ var all field.ErrorList
283+ hasConn := c .ConnectionString != "" || c .ConnectionStringSecretRef != nil
284+ if ! hasConn {
285+ all = append (all , field .Required (f .Child ("connectionString" ), "connectionString or connectionStringSecretRef is required" ))
286+ }
287+ hasTable := c .Table != "" || c .TableSecretRef != nil
288+ if ! hasTable {
289+ all = append (all , field .Required (f .Child ("table" ), "table or tableSecretRef is required" ))
290+ }
291+ if c .ConnectionStringSecretRef != nil {
292+ all = append (all , validateSecretRef (c .ConnectionStringSecretRef , f .Child ("connectionStringSecretRef" ))... )
293+ }
294+ if c .TableSecretRef != nil {
295+ all = append (all , validateSecretRef (c .TableSecretRef , f .Child ("tableSecretRef" ))... )
296+ }
297+ return all
298+ }
299+
300+ func validateClickHouseSink (c * ClickHouseSinkSpec , f * field.Path ) field.ErrorList {
301+ var all field.ErrorList
302+ hasConn := c .ConnectionString != "" || c .ConnectionStringSecretRef != nil
303+ if ! hasConn {
304+ all = append (all , field .Required (f .Child ("connectionString" ), "connectionString or connectionStringSecretRef is required" ))
305+ }
306+ hasTable := c .Table != "" || c .TableSecretRef != nil
307+ if ! hasTable {
308+ all = append (all , field .Required (f .Child ("table" ), "table or tableSecretRef is required" ))
309+ }
310+ if c .ConnectionStringSecretRef != nil {
311+ all = append (all , validateSecretRef (c .ConnectionStringSecretRef , f .Child ("connectionStringSecretRef" ))... )
312+ }
313+ if c .TableSecretRef != nil {
314+ all = append (all , validateSecretRef (c .TableSecretRef , f .Child ("tableSecretRef" ))... )
315+ }
316+ return all
317+ }
318+
269319func validateSecretRef (r * SecretRef , f * field.Path ) field.ErrorList {
270320 var all field.ErrorList
271321 if r == nil {
0 commit comments