Skip to content

Commit 7f42451

Browse files
committed
Merge branch 'develop' into approval-bypass-v2-oss
# Conflicts: # api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go # env_gen.json # env_gen.md # pkg/deployment/deployedApp/DeployedAppService.go # pkg/deployment/trigger/devtronApps/deployStageHandlerCode.go # pkg/eventProcessor/in/CDPipelineEventProcessorService.go
2 parents d5ff588 + fc44e3c commit 7f42451

File tree

158 files changed

+5616
-4500
lines changed

Some content is hidden

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

158 files changed

+5616
-4500
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
.env
55
/cmd/external-app/devtron-ea
66
devtron
7+
8+
.qodo

App.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"github.com/devtron-labs/common-lib/middlewares"
2525
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
26+
posthogTelemetry "github.com/devtron-labs/common-lib/telemetry"
2627
"github.com/devtron-labs/devtron/pkg/eventProcessor"
2728
"github.com/devtron-labs/devtron/pkg/eventProcessor/in"
2829
"log"
@@ -31,7 +32,6 @@ import (
3132
"time"
3233

3334
"github.com/devtron-labs/devtron/api/util"
34-
"github.com/devtron-labs/devtron/client/telemetry"
3535
"github.com/devtron-labs/devtron/otel"
3636
"github.com/devtron-labs/devtron/pkg/auth/user"
3737

@@ -55,7 +55,7 @@ type App struct {
5555
EnforcerV2 *casbinv2.SyncedEnforcer
5656
server *http.Server
5757
db *pg.DB
58-
posthogClient *telemetry.PosthogClient
58+
posthogClient *posthogTelemetry.PosthogClient
5959
// eventProcessor.CentralEventProcessor is used to register event processors
6060
centralEventProcessor *eventProcessor.CentralEventProcessor // do not remove this.
6161
// used for local dev only
@@ -73,7 +73,7 @@ func NewApp(router *router.MuxRouter,
7373
enforcer *casbin.SyncedEnforcer,
7474
db *pg.DB,
7575
sessionManager2 *authMiddleware.SessionManager,
76-
posthogClient *telemetry.PosthogClient,
76+
posthogClient *posthogTelemetry.PosthogClient,
7777
loggingMiddleware util.LoggingMiddleware,
7878
centralEventProcessor *eventProcessor.CentralEventProcessor,
7979
pubSubClient *pubsub.PubSubClientServiceImpl,

Wire.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ package main
2222
import (
2323
"github.com/devtron-labs/authenticator/middleware"
2424
cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier"
25-
pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib"
25+
pubSub "github.com/devtron-labs/common-lib/pubsub-lib"
26+
posthogTelemetry "github.com/devtron-labs/common-lib/telemetry"
2627
util4 "github.com/devtron-labs/common-lib/utils/k8s"
2728
"github.com/devtron-labs/devtron/api/apiToken"
2829
appStoreRestHandler "github.com/devtron-labs/devtron/api/appStore"
@@ -144,6 +145,7 @@ import (
144145
"github.com/devtron-labs/devtron/pkg/deploymentGroup"
145146
"github.com/devtron-labs/devtron/pkg/dockerRegistry"
146147
"github.com/devtron-labs/devtron/pkg/eventProcessor"
148+
"github.com/devtron-labs/devtron/pkg/executor"
147149
"github.com/devtron-labs/devtron/pkg/generateManifest"
148150
"github.com/devtron-labs/devtron/pkg/gitops"
149151
"github.com/devtron-labs/devtron/pkg/imageDigestPolicy"
@@ -165,6 +167,7 @@ import (
165167
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
166168
"github.com/devtron-labs/devtron/pkg/resourceQualifiers"
167169
"github.com/devtron-labs/devtron/pkg/sql"
170+
"github.com/devtron-labs/devtron/pkg/ucid"
168171
util3 "github.com/devtron-labs/devtron/pkg/util"
169172
"github.com/devtron-labs/devtron/pkg/variables"
170173
"github.com/devtron-labs/devtron/pkg/variables/parsers"
@@ -219,7 +222,7 @@ func InitializeApp() (*App, error) {
219222
userResource.UserResourceWireSet,
220223
policyGovernance.PolicyGovernanceWireSet,
221224
resourceScan.ScanningResultWireSet,
222-
225+
executor.ExecutorWireSet,
223226
// -------wireset end ----------
224227
// -------
225228
gitSensor.GetConfig,
@@ -478,9 +481,6 @@ func InitializeApp() (*App, error) {
478481
util.IntValidator,
479482
types.GetCiCdConfig,
480483

481-
pipeline.NewWorkflowServiceImpl,
482-
wire.Bind(new(pipeline.WorkflowService), new(*pipeline.WorkflowServiceImpl)),
483-
484484
pipeline.NewCiServiceImpl,
485485
wire.Bind(new(pipeline.CiService), new(*pipeline.CiServiceImpl)),
486486

@@ -501,7 +501,7 @@ func InitializeApp() (*App, error) {
501501
pipeline.NewCiLogServiceImpl,
502502
wire.Bind(new(pipeline.CiLogService), new(*pipeline.CiLogServiceImpl)),
503503

504-
pubsub1.NewPubSubClientServiceImpl,
504+
pubSub.NewPubSubClientServiceImpl,
505505

506506
rbac.NewEnforcerUtilImpl,
507507
wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)),
@@ -696,7 +696,8 @@ func InitializeApp() (*App, error) {
696696
wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)),
697697
restHandler.NewTelemetryRestHandlerImpl,
698698
wire.Bind(new(restHandler.TelemetryRestHandler), new(*restHandler.TelemetryRestHandlerImpl)),
699-
telemetry.NewPosthogClient,
699+
posthogTelemetry.NewPosthogClient,
700+
ucid.WireSet,
700701

701702
cloudProviderIdentifier.NewProviderIdentifierServiceImpl,
702703
wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)),

api/argoApplication/wire_argoApplication.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package argoApplication
1818

1919
import (
20-
"github.com/devtron-labs/devtron/pkg/argoApplication"
20+
argoApplication3 "github.com/devtron-labs/devtron/pkg/argoApplication"
2121
"github.com/devtron-labs/devtron/pkg/argoApplication/read"
2222
"github.com/devtron-labs/devtron/pkg/argoApplication/read/config"
2323
"github.com/google/wire"
@@ -30,9 +30,9 @@ var ArgoApplicationWireSetFull = wire.NewSet(
3030
config.NewArgoApplicationConfigServiceImpl,
3131
wire.Bind(new(config.ArgoApplicationConfigService), new(*config.ArgoApplicationConfigServiceImpl)),
3232

33-
argoApplication.NewArgoApplicationServiceImpl,
34-
argoApplication.NewArgoApplicationServiceExtendedServiceImpl,
35-
wire.Bind(new(argoApplication.ArgoApplicationService), new(*argoApplication.ArgoApplicationServiceExtendedImpl)),
33+
argoApplication3.NewArgoApplicationServiceImpl,
34+
argoApplication3.NewArgoApplicationServiceExtendedServiceImpl,
35+
wire.Bind(new(argoApplication3.ArgoApplicationService), new(*argoApplication3.ArgoApplicationServiceExtendedImpl)),
3636

3737
NewArgoApplicationRestHandlerImpl,
3838
wire.Bind(new(ArgoApplicationRestHandler), new(*ArgoApplicationRestHandlerImpl)),
@@ -48,8 +48,8 @@ var ArgoApplicationWireSetEA = wire.NewSet(
4848
config.NewArgoApplicationConfigServiceImpl,
4949
wire.Bind(new(config.ArgoApplicationConfigService), new(*config.ArgoApplicationConfigServiceImpl)),
5050

51-
argoApplication.NewArgoApplicationServiceImpl,
52-
wire.Bind(new(argoApplication.ArgoApplicationService), new(*argoApplication.ArgoApplicationServiceImpl)),
51+
argoApplication3.NewArgoApplicationServiceImpl,
52+
wire.Bind(new(argoApplication3.ArgoApplicationService), new(*argoApplication3.ArgoApplicationServiceImpl)),
5353

5454
NewArgoApplicationRestHandlerImpl,
5555
wire.Bind(new(ArgoApplicationRestHandler), new(*ArgoApplicationRestHandlerImpl)),

api/bean/AutocompleteConfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
package bean
1818

1919
type Config struct {
20-
IgnoreAuthCheck bool `env:"IGNORE_AUTOCOMPLETE_AUTH_CHECK" envDefault:"false"`
20+
IgnoreAuthCheck bool `env:"IGNORE_AUTOCOMPLETE_AUTH_CHECK" envDefault:"false" description:"flag for ignoring auth check in autocomplete apis."`
2121
}

api/cluster/EnvironmentRestHandler.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const ENV_DELETE_SUCCESS_RESP = "Environment deleted successfully."
5151
type EnvironmentRestHandler interface {
5252
Create(w http.ResponseWriter, r *http.Request)
5353
Get(w http.ResponseWriter, r *http.Request)
54+
GetDataSourceName(w http.ResponseWriter, r *http.Request)
5455
GetAll(w http.ResponseWriter, r *http.Request)
5556
GetAllActive(w http.ResponseWriter, r *http.Request)
5657
Update(w http.ResponseWriter, r *http.Request)
@@ -167,6 +168,34 @@ func (impl EnvironmentRestHandlerImpl) Get(w http.ResponseWriter, r *http.Reques
167168
common.WriteJsonResp(w, err, bean, http.StatusOK)
168169
}
169170

171+
func (impl EnvironmentRestHandlerImpl) GetDataSourceName(w http.ResponseWriter, r *http.Request) {
172+
vars := mux.Vars(r)
173+
environmentName := vars["environmentName"]
174+
175+
bean, err := impl.environmentClusterMappingsService.FindOne(environmentName)
176+
if err != nil {
177+
impl.logger.Errorw("service err, Get", "err", err, "payload", bean)
178+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
179+
return
180+
}
181+
182+
// RBAC enforcer applying
183+
token := r.Header.Get("token")
184+
if ok := impl.enforcer.Enforce(token, casbin.ResourceGlobalEnvironment, casbin.ActionGet, bean.EnvironmentIdentifier); !ok {
185+
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
186+
return
187+
}
188+
//RBAC enforcer Ends
189+
190+
resp, err := impl.environmentClusterMappingsService.GetDataSourceName(bean)
191+
if err != nil {
192+
impl.logger.Errorw("service err, Get", "err", err, "env", environmentName)
193+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
194+
return
195+
}
196+
common.WriteJsonResp(w, err, resp, http.StatusOK)
197+
}
198+
170199
func (impl EnvironmentRestHandlerImpl) GetAll(w http.ResponseWriter, r *http.Request) {
171200
environments, err := impl.environmentReadService.GetAll()
172201
if err != nil {

api/cluster/EnvironmentRouter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ func (impl EnvironmentRouterImpl) InitEnvironmentClusterMappingsRouter(environme
4141
Methods("GET").
4242
Queries("environment", "{environment}").
4343
HandlerFunc(impl.environmentClusterMappingsRestHandler.Get)
44+
environmentClusterMappingsRouter.Path("/data-source-name").
45+
Methods("GET").
46+
Queries("environmentName", "{environmentName}").
47+
HandlerFunc(impl.environmentClusterMappingsRestHandler.GetDataSourceName)
4448
environmentClusterMappingsRouter.Path("").
4549
Methods("GET").
4650
Queries("id", "{id}").

api/helm-app/gRPC/applicationClient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func NewHelmAppClientImpl(logger *zap.SugaredLogger,
7575

7676
// CATEGORY=INFRA_SETUP
7777
type HelmClientConfig struct {
78-
Url string `env:"HELM_CLIENT_URL" envDefault:"127.0.0.1:50051"`
78+
Url string `env:"HELM_CLIENT_URL" envDefault:"127.0.0.1:50051" description:"Kubelink micro-service url "`
7979
}
8080

8181
func GetConfig() (*HelmClientConfig, error) {

api/helm-app/service/HelmAppService.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ func NewHelmAppServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.Clu
159159

160160
// CATEGORY=CD
161161
type HelmReleaseConfig struct {
162-
RevisionHistoryLimitDevtronApp int `env:"REVISION_HISTORY_LIMIT_DEVTRON_APP" envDefault:"1"`
163-
RevisionHistoryLimitHelmApp int `env:"REVISION_HISTORY_LIMIT_HELM_APP" envDefault:"1"`
164-
RevisionHistoryLimitExternalHelmApp int `env:"REVISION_HISTORY_LIMIT_EXTERNAL_HELM_APP" envDefault:"0"`
162+
RevisionHistoryLimitDevtronApp int `env:"REVISION_HISTORY_LIMIT_DEVTRON_APP" envDefault:"1" description:"Count for devtron application rivision history"`
163+
RevisionHistoryLimitHelmApp int `env:"REVISION_HISTORY_LIMIT_HELM_APP" envDefault:"1" description:"To set the history limit for the helm app being deployed through devtron"`
164+
RevisionHistoryLimitExternalHelmApp int `env:"REVISION_HISTORY_LIMIT_EXTERNAL_HELM_APP" envDefault:"0" description:"Count for external helm application rivision history"`
165165
RevisionHistoryLimitLinkedHelmApp int `env:"REVISION_HISTORY_LIMIT_LINKED_HELM_APP" envDefault:"15"`
166166
}
167167

api/restHandler/CoreAppRestHandler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider"
3030
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read"
3131
pipelineBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
32+
common2 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
3233
bean3 "github.com/devtron-labs/devtron/pkg/chart/bean"
3334
read5 "github.com/devtron-labs/devtron/pkg/chart/read"
3435
"github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
@@ -1688,7 +1689,7 @@ func (handler CoreAppRestHandlerImpl) createCiPipeline(appId int, userId int32,
16881689
ParentCiPipeline: ciPipelineData.ParentCiPipeline,
16891690
ParentAppId: ciPipelineData.ParentAppId,
16901691
LinkedCount: ciPipelineData.LinkedCount,
1691-
PipelineType: pipelineBean.PipelineType(ciPipelineData.PipelineType),
1692+
PipelineType: common2.PipelineType(ciPipelineData.PipelineType),
16921693
},
16931694
}
16941695

0 commit comments

Comments
 (0)