Skip to content

Commit 0beba30

Browse files
Merge pull request #393 from devtron-labs/feat-postgres-ssl
feat: postgres ssl support
2 parents 0fbc453 + 6bd7a3a commit 0beba30

51 files changed

Lines changed: 1321 additions & 59 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chart-sync/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/devtron-labs/chart-sync
22

33
go 1.25.0
44

5-
replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
5+
replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc
66

77
require (
88
github.com/caarlos0/env v3.5.0+incompatible

chart-sync/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
4141
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4242
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
4343
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6 h1:TdSTr402uQpelYxrX+FsLOXx7g1OoYJe1PyO/oOv700=
45-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6/go.mod h1:pehekzNkt2KRGZ3VC1b274Qq3iPBh27vGTby88T6KtI=
44+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc h1:vUG3Va+7UGT36MPJL1l/VckJUVj36YG6aX6HimNGluY=
45+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc/go.mod h1:pehekzNkt2KRGZ3VC1b274Qq3iPBh27vGTby88T6KtI=
4646
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
4747
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
4848
github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN6UX90KJc4HjyM=

chart-sync/internals/sql/connection.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/caarlos0/env"
55
"github.com/devtron-labs/common-lib/utils"
66
"github.com/devtron-labs/common-lib/utils/bean"
7+
commonSql "github.com/devtron-labs/common-lib/utils/sql"
78
"github.com/go-pg/pg"
89
"go.uber.org/zap"
910
"reflect"
@@ -16,6 +17,8 @@ type Config struct {
1617
Password string `env:"PG_PASSWORD" envDefault:"password" secretData:"-"`
1718
Database string `env:"PG_DATABASE" envDefault:"orchestrator"`
1819
ApplicationName string `env:"APP" envDefault:"chart-sync"`
20+
SslMode string `env:"PG_SSL_MODE" envDefault:""`
21+
SslRootCert string `env:"PG_SSL_ROOT_CERT" envDefault:""`
1922
bean.PgQueryMonitoringConfig
2023
}
2124

@@ -34,17 +37,23 @@ func GetConfig() (*Config, error) {
3437
}
3538

3639
func NewDbConnection(cfg *Config, logger *zap.SugaredLogger) (*pg.DB, error) {
40+
tlsConfig, err := commonSql.BuildTLSConfig(cfg.SslMode, cfg.SslRootCert, cfg.Addr)
41+
if err != nil {
42+
logger.Errorw("error in building tls config for db connection", "err", err)
43+
return nil, err
44+
}
3745
options := pg.Options{
3846
Addr: cfg.Addr + ":" + cfg.Port,
3947
User: cfg.User,
4048
Password: cfg.Password,
4149
Database: cfg.Database,
4250
ApplicationName: cfg.ApplicationName,
51+
TLSConfig: tlsConfig,
4352
}
4453
dbConnection := pg.Connect(&options)
4554
//check db connection
4655
var test string
47-
_, err := dbConnection.QueryOne(&test, `SELECT 1`)
56+
_, err = dbConnection.QueryOne(&test, `SELECT 1`)
4857

4958
if err != nil {
5059
logger.Errorw("error in connecting db ", "db", obfuscateSecretTags(cfg), "err", err)

chart-sync/vendor/github.com/devtron-labs/common-lib/securestore/AttributesRepoDBConnection.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart-sync/vendor/github.com/devtron-labs/common-lib/utils/sql/connection.go

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart-sync/vendor/github.com/devtron-labs/common-lib/utils/sql/ssl.go

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart-sync/vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ github.com/containerd/platforms
9595
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
9696
## explicit
9797
github.com/davecgh/go-spew/spew
98-
# github.com/devtron-labs/common-lib v0.19.1 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
98+
# github.com/devtron-labs/common-lib v0.19.1 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc
9999
## explicit; go 1.25.0
100100
github.com/devtron-labs/common-lib/constants
101101
github.com/devtron-labs/common-lib/fetchAllEnv
@@ -951,5 +951,5 @@ sigs.k8s.io/structured-merge-diff/v6/value
951951
## explicit; go 1.22
952952
sigs.k8s.io/yaml
953953
sigs.k8s.io/yaml/kyaml
954-
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
954+
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc
955955
# github.com/containerd/containerd v1.7.27 => github.com/containerd/containerd v1.7.29

ci-runner/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/devtron-labs/ci-runner
22

33
go 1.25.0
44

5-
replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
5+
replace github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc
66

77
require (
88
github.com/Knetic/govaluate v3.0.0+incompatible

ci-runner/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
114114
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
115115
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
116116
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
117-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6 h1:TdSTr402uQpelYxrX+FsLOXx7g1OoYJe1PyO/oOv700=
118-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6/go.mod h1:pehekzNkt2KRGZ3VC1b274Qq3iPBh27vGTby88T6KtI=
117+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc h1:vUG3Va+7UGT36MPJL1l/VckJUVj36YG6aX6HimNGluY=
118+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc/go.mod h1:pehekzNkt2KRGZ3VC1b274Qq3iPBh27vGTby88T6KtI=
119119
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
120120
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
121121
github.com/docker/cli v29.2.0+incompatible h1:9oBd9+YM7rxjZLfyMGxjraKBKE4/nVyvVfN4qNl9XRM=

ci-runner/vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ github.com/cncf/xds/go/xds/type/v3
298298
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
299299
## explicit
300300
github.com/davecgh/go-spew/spew
301-
# github.com/devtron-labs/common-lib v0.19.1 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
301+
# github.com/devtron-labs/common-lib v0.19.1 => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc
302302
## explicit; go 1.25.0
303303
github.com/devtron-labs/common-lib/blob-storage
304304
github.com/devtron-labs/common-lib/constants
@@ -1213,4 +1213,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
12131213
## explicit; go 1.22
12141214
sigs.k8s.io/yaml
12151215
sigs.k8s.io/yaml/goyaml.v2
1216-
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260415113300-e49850611af6
1216+
# github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20260707131338-7cbce898d5fc

0 commit comments

Comments
 (0)