From c92e39698521672f1cdba9a4d6673237b109b880 Mon Sep 17 00:00:00 2001 From: riccardo <106812074+riccardo-gnosis@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:25:49 +0200 Subject: [PATCH] update: support tls and native protocol for higher level driver when url is from clickhouse.cloud --- pkg/db/high_level_driver.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/db/high_level_driver.go b/pkg/db/high_level_driver.go index 7c06b24b..0c9249a1 100644 --- a/pkg/db/high_level_driver.go +++ b/pkg/db/high_level_driver.go @@ -2,6 +2,7 @@ package db import ( "context" + "crypto/tls" "fmt" "net" @@ -48,7 +49,7 @@ func ParseChUrlIntoOptionsHighLevel(url string) clickhouse.Options { password = strings.Split(credentials, ":")[1] var dialCount int - return clickhouse.Options{ + options := clickhouse.Options{ Addr: []string{fqdn}, Auth: clickhouse.Auth{ Database: database, @@ -85,6 +86,12 @@ func ParseChUrlIntoOptionsHighLevel(url string) clickhouse.Options { {Name: utils.CliName, Version: utils.Version}, }, }} + if strings.Contains(fqdn, "clickhouse.cloud") { + options.Addr = []string{fmt.Sprintf("https://%s", fqdn)} + options.Protocol = clickhouse.Native + options.TLS = &tls.Config{} + } + return options } func (p *DBService) Delete(obj DeletableObject) error {