Skip to content

Commit 6f2f325

Browse files
authored
Merge pull request #6857 from devtron-labs/main-sync-4nov-1
sync: Main sync
2 parents ac9affc + 1ee821c commit 6f2f325

File tree

13 files changed

+108
-82
lines changed

13 files changed

+108
-82
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
all: fetch-all-env build
44

5-
TARGET_BRANCH?=main
5+
TARGET_BRANCH?=develop
66
TAG?=$(shell bash -c 'git log --pretty=format:'%h' -n 1')
77
FLAGS=
88
ENVVAR=

cmd/external-app/wire_gen.go

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

env_gen.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

env_gen.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
| ENABLE_ASYNC_ARGO_CD_INSTALL_DEVTRON_CHART | bool |false | To enable async installation of gitops application | | false |
189189
| ENABLE_ASYNC_INSTALL_DEVTRON_CHART | bool |false | To enable async installation of no-gitops application | | false |
190190
| ENABLE_LINKED_CI_ARTIFACT_COPY | bool |false | Enable copying artifacts from parent CI pipeline to linked CI pipeline during creation | | false |
191+
| ENABLE_PASSWORD_ENCRYPTION | bool |true | enable password encryption | | false |
191192
| EPHEMERAL_SERVER_VERSION_REGEX | string |v[1-9]\.\b(2[3-9]\|[3-9][0-9])\b.* | ephemeral containers support version regex that is compared with k8sServerVersion | | false |
192193
| EVENT_URL | string |http://localhost:3000/notify | Notifier service url | | false |
193194
| EXECUTE_WIRE_NIL_CHECKER | bool |false | checks for any nil pointer in wire.go | | false |

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ require (
338338
replace (
339339
github.com/argoproj/argo-workflows/v3 v3.5.13 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
340340
github.com/cyphar/filepath-securejoin v0.4.1 => github.com/cyphar/filepath-securejoin v0.3.6 // indirect
341-
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251027071349-2031d8107953
342-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251027071349-2031d8107953
341+
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251104083107-f40094ec69d7
342+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251104083107-f40094ec69d7
343343
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 => go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1
344344
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
237237
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
238238
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
239239
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
240-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251027071349-2031d8107953 h1:LE08yoM+m/HgSXr8/aLwWUr0S6FBmC/853qpkZtrrkY=
241-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251027071349-2031d8107953/go.mod h1:9LCkYfiWaEKIBkmxw9jX1GujvEMyHwmDtVsatffAkeU=
242-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251027071349-2031d8107953 h1:gKhFrhn+XVAunhJdZHrpQF6Q6HR81kux1ugqlcsyJRA=
243-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251027071349-2031d8107953/go.mod h1:BPvuxIUW9TNYZ3+9r39nMzeORMcLqTwNkakirqp9AzU=
240+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251104083107-f40094ec69d7 h1:YkFQOE+l+ei//+HesxWQV1bxUr2tNNZSN31DkDFbtts=
241+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20251104083107-f40094ec69d7/go.mod h1:9LCkYfiWaEKIBkmxw9jX1GujvEMyHwmDtVsatffAkeU=
242+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251104083107-f40094ec69d7 h1:IsgreAJRCpycvA7of0j0VZa9nXWXKOiTzDrH92149Zc=
243+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20251104083107-f40094ec69d7/go.mod h1:+CUhxuWB8uMYIoiXwofuLIXPyiNnwmoZlH90KWAE5Ew=
244244
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
245245
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
246246
github.com/devtron-labs/protos v0.0.3-0.20250323220609-ecf8a0f7305e h1:U6UdYbW8a7xn5IzFPd8cywjVVPfutGJCudjePAfL/Hs=

internal/sql/repository/GitOpsConfigRepository.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package repository
1919
import (
2020
"github.com/devtron-labs/common-lib/securestore"
2121
"github.com/devtron-labs/devtron/pkg/sql"
22+
globalUtil "github.com/devtron-labs/devtron/util"
2223
"github.com/go-pg/pg"
2324
"go.uber.org/zap"
2425
)
@@ -37,8 +38,9 @@ type GitOpsConfigRepository interface {
3738
}
3839

3940
type GitOpsConfigRepositoryImpl struct {
40-
dbConnection *pg.DB
41-
logger *zap.SugaredLogger
41+
dbConnection *pg.DB
42+
logger *zap.SugaredLogger
43+
GlobalEnvVariables *globalUtil.GlobalEnvVariables
4244
}
4345

4446
type GitOpsConfig struct {
@@ -63,8 +65,8 @@ type GitOpsConfig struct {
6365
sql.AuditLog
6466
}
6567

66-
func NewGitOpsConfigRepositoryImpl(logger *zap.SugaredLogger, dbConnection *pg.DB) *GitOpsConfigRepositoryImpl {
67-
return &GitOpsConfigRepositoryImpl{dbConnection: dbConnection, logger: logger}
68+
func NewGitOpsConfigRepositoryImpl(logger *zap.SugaredLogger, dbConnection *pg.DB, variables *globalUtil.EnvironmentVariables) *GitOpsConfigRepositoryImpl {
69+
return &GitOpsConfigRepositoryImpl{dbConnection: dbConnection, logger: logger, GlobalEnvVariables: variables.GlobalEnvVariables}
6870
}
6971

7072
func (impl *GitOpsConfigRepositoryImpl) GetConnection() *pg.DB {
@@ -73,9 +75,11 @@ func (impl *GitOpsConfigRepositoryImpl) GetConnection() *pg.DB {
7375

7476
func (impl *GitOpsConfigRepositoryImpl) CreateGitOpsConfig(model *GitOpsConfig, tx *pg.Tx) (*GitOpsConfig, error) {
7577
var err error
76-
model.Token, err = securestore.EncryptString(model.Token.String())
77-
if err != nil {
78-
return model, err
78+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
79+
model.Token, err = securestore.EncryptString(model.Token.String())
80+
if err != nil {
81+
return model, err
82+
}
7983
}
8084
err = tx.Insert(model)
8185
if err != nil {
@@ -85,9 +89,11 @@ func (impl *GitOpsConfigRepositoryImpl) CreateGitOpsConfig(model *GitOpsConfig,
8589
return model, nil
8690
}
8791
func (impl *GitOpsConfigRepositoryImpl) UpdateGitOpsConfig(model *GitOpsConfig, tx *pg.Tx) (err error) {
88-
model.Token, err = securestore.EncryptString(model.Token.String())
89-
if err != nil {
90-
return err
92+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
93+
model.Token, err = securestore.EncryptString(model.Token.String())
94+
if err != nil {
95+
return err
96+
}
9197
}
9298
err = tx.Update(model)
9399
if err != nil {

internal/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,30 @@ type DockerArtifactStoreRepository interface {
9999
FindInactive(storeId string) (bool, error)
100100
}
101101
type DockerArtifactStoreRepositoryImpl struct {
102-
dbConnection *pg.DB
102+
dbConnection *pg.DB
103+
GlobalEnvVariables *util.GlobalEnvVariables
103104
}
104105

105-
func NewDockerArtifactStoreRepositoryImpl(dbConnection *pg.DB) *DockerArtifactStoreRepositoryImpl {
106-
return &DockerArtifactStoreRepositoryImpl{dbConnection: dbConnection}
106+
func NewDockerArtifactStoreRepositoryImpl(dbConnection *pg.DB, environmentVariables *util.EnvironmentVariables) *DockerArtifactStoreRepositoryImpl {
107+
return &DockerArtifactStoreRepositoryImpl{dbConnection: dbConnection, GlobalEnvVariables: environmentVariables.GlobalEnvVariables}
107108
}
108109

109110
func (impl DockerArtifactStoreRepositoryImpl) GetConnection() *pg.DB {
110111
return impl.dbConnection
111112
}
112113

113114
func (impl DockerArtifactStoreRepositoryImpl) Save(artifactStore *DockerArtifactStore, tx *pg.Tx) (err error) {
114-
artifactStore.Password, err = securestore.EncryptString(artifactStore.Password.String())
115-
if err != nil {
116-
return err
117-
}
118-
artifactStore.AWSSecretAccessKey, err = securestore.EncryptString(artifactStore.AWSSecretAccessKey.String())
119-
if err != nil {
120-
return err
121-
}
122115

116+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
117+
artifactStore.Password, err = securestore.EncryptString(artifactStore.Password.String())
118+
if err != nil {
119+
return err
120+
}
121+
artifactStore.AWSSecretAccessKey, err = securestore.EncryptString(artifactStore.AWSSecretAccessKey.String())
122+
if err != nil {
123+
return err
124+
}
125+
}
123126
if util.IsBaseStack() {
124127
return tx.Insert(artifactStore)
125128
}
@@ -246,13 +249,15 @@ func (impl DockerArtifactStoreRepositoryImpl) FindOneInactive(storeId string) (*
246249
}
247250

248251
func (impl DockerArtifactStoreRepositoryImpl) Update(artifactStore *DockerArtifactStore, tx *pg.Tx) (err error) {
249-
artifactStore.Password, err = securestore.EncryptString(artifactStore.Password.String())
250-
if err != nil {
251-
return err
252-
}
253-
artifactStore.AWSSecretAccessKey, err = securestore.EncryptString(artifactStore.AWSSecretAccessKey.String())
254-
if err != nil {
255-
return err
252+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
253+
artifactStore.Password, err = securestore.EncryptString(artifactStore.Password.String())
254+
if err != nil {
255+
return err
256+
}
257+
artifactStore.AWSSecretAccessKey, err = securestore.EncryptString(artifactStore.AWSSecretAccessKey.String())
258+
if err != nil {
259+
return err
260+
}
256261
}
257262
//TODO check for unique default
258263
//there can be only one default

pkg/build/git/gitProvider/repository/GitProviderRepository.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/devtron-labs/common-lib/securestore"
2121
"github.com/devtron-labs/devtron/internal/sql/constants"
2222
"github.com/devtron-labs/devtron/pkg/sql"
23+
globalUtil "github.com/devtron-labs/devtron/util"
2324
"github.com/go-pg/pg"
2425
)
2526

@@ -56,15 +57,16 @@ type GitProviderRepository interface {
5657
}
5758

5859
type GitProviderRepositoryImpl struct {
59-
dbConnection *pg.DB
60+
GlobalEnvVariables *globalUtil.GlobalEnvVariables
61+
dbConnection *pg.DB
6062
}
6163

62-
func NewGitProviderRepositoryImpl(dbConnection *pg.DB) *GitProviderRepositoryImpl {
63-
return &GitProviderRepositoryImpl{dbConnection: dbConnection}
64+
func NewGitProviderRepositoryImpl(dbConnection *pg.DB, envVariables *globalUtil.EnvironmentVariables) *GitProviderRepositoryImpl {
65+
return &GitProviderRepositoryImpl{dbConnection: dbConnection, GlobalEnvVariables: envVariables.GlobalEnvVariables}
6466
}
6567

6668
func (impl GitProviderRepositoryImpl) Save(gitProvider *GitProvider) error {
67-
err := encryptFieldsInGitProvider(gitProvider)
69+
err := impl.encryptFieldsInGitProvider(gitProvider)
6870
if err != nil {
6971
return err
7072
}
@@ -120,7 +122,7 @@ func (impl GitProviderRepositoryImpl) FindByUrl(providerUrl string) (GitProvider
120122
}
121123

122124
func (impl GitProviderRepositoryImpl) Update(gitProvider *GitProvider) error {
123-
err := encryptFieldsInGitProvider(gitProvider)
125+
err := impl.encryptFieldsInGitProvider(gitProvider)
124126
if err != nil {
125127
return err
126128
}
@@ -133,19 +135,21 @@ func (impl GitProviderRepositoryImpl) MarkProviderDeleted(gitProvider *GitProvid
133135
return impl.dbConnection.Update(gitProvider)
134136
}
135137

136-
func encryptFieldsInGitProvider(gitProvider *GitProvider) error {
138+
func (impl GitProviderRepositoryImpl) encryptFieldsInGitProvider(gitProvider *GitProvider) error {
137139
var err error
138-
gitProvider.Password, err = securestore.EncryptString(gitProvider.Password.String())
139-
if err != nil {
140-
return err
141-
}
142-
gitProvider.AccessToken, err = securestore.EncryptString(gitProvider.AccessToken.String())
143-
if err != nil {
144-
return err
145-
}
146-
gitProvider.SshPrivateKey, err = securestore.EncryptString(gitProvider.SshPrivateKey.String())
147-
if err != nil {
148-
return err
140+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
141+
gitProvider.Password, err = securestore.EncryptString(gitProvider.Password.String())
142+
if err != nil {
143+
return err
144+
}
145+
gitProvider.AccessToken, err = securestore.EncryptString(gitProvider.AccessToken.String())
146+
if err != nil {
147+
return err
148+
}
149+
gitProvider.SshPrivateKey, err = securestore.EncryptString(gitProvider.SshPrivateKey.String())
150+
if err != nil {
151+
return err
152+
}
149153
}
150154
return nil
151155
}

pkg/cluster/repository/ClusterRepository.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package repository
1919
import (
2020
"github.com/devtron-labs/common-lib/securestore"
2121
"github.com/devtron-labs/devtron/pkg/sql"
22+
globalUtil "github.com/devtron-labs/devtron/util"
2223
"github.com/go-pg/pg"
2324
"go.uber.org/zap"
2425
"time"
@@ -74,22 +75,26 @@ type ClusterRepository interface {
7475
FindByClusterURL(clusterURL string) (*Cluster, error)
7576
}
7677

77-
func NewClusterRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *ClusterRepositoryImpl {
78+
func NewClusterRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger, variables *globalUtil.EnvironmentVariables) *ClusterRepositoryImpl {
7879
return &ClusterRepositoryImpl{
79-
dbConnection: dbConnection,
80-
logger: logger,
80+
dbConnection: dbConnection,
81+
logger: logger,
82+
GlobalEnvVariables: variables.GlobalEnvVariables,
8183
}
8284
}
8385

8486
type ClusterRepositoryImpl struct {
85-
dbConnection *pg.DB
86-
logger *zap.SugaredLogger
87+
dbConnection *pg.DB
88+
logger *zap.SugaredLogger
89+
GlobalEnvVariables *globalUtil.GlobalEnvVariables
8790
}
8891

8992
func (impl ClusterRepositoryImpl) Save(model *Cluster) (err error) {
90-
model.Config, err = securestore.EncryptMap(model.Config)
91-
if err != nil {
92-
return err
93+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
94+
model.Config, err = securestore.EncryptMap(model.Config)
95+
if err != nil {
96+
return err
97+
}
9398
}
9499
return impl.dbConnection.Insert(model)
95100
}
@@ -106,9 +111,11 @@ func (impl ClusterRepositoryImpl) FindOne(clusterName string) (*Cluster, error)
106111
}
107112
func (impl ClusterRepositoryImpl) SaveAll(models []*Cluster) (err error) {
108113
for i := range models {
109-
models[i].Config, err = securestore.EncryptMap(models[i].Config)
110-
if err != nil {
111-
return err
114+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
115+
models[i].Config, err = securestore.EncryptMap(models[i].Config)
116+
if err != nil {
117+
return err
118+
}
112119
}
113120
}
114121
return impl.dbConnection.Insert(models)
@@ -191,9 +198,11 @@ func (impl ClusterRepositoryImpl) FindByIds(id []int) ([]Cluster, error) {
191198
}
192199

193200
func (impl ClusterRepositoryImpl) Update(model *Cluster) (err error) {
194-
model.Config, err = securestore.EncryptMap(model.Config)
195-
if err != nil {
196-
return err
201+
if impl.GlobalEnvVariables.EnablePasswordEncryption {
202+
model.Config, err = securestore.EncryptMap(model.Config)
203+
if err != nil {
204+
return err
205+
}
197206
}
198207
return impl.dbConnection.Update(model)
199208
}

0 commit comments

Comments
 (0)