Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate external argo cd application #6303

Open
wants to merge 165 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
dcfd98b
wip:deployment config old data migration code
iamayushm Jan 16, 2025
104e62c
Merge remote-tracking branch 'origin/develop' into link-external-argocd
iamayushm Jan 16, 2025
6864e07
updating repo url get usage
iamayushm Jan 17, 2025
abc8fea
comments
iamayushm Jan 17, 2025
ca6fda7
adding comments
iamayushm Jan 17, 2025
a18b96f
wip: adding repo name in deployment config struct
iamayushm Jan 17, 2025
81ccd3a
migration files
iamayushm Jan 17, 2025
20e0b4d
migration update
iamayushm Jan 17, 2025
7303646
Merge remote-tracking branch 'origin/link-external-argocd' into feat-…
Ash-exp Jan 20, 2025
185178e
feat: updated the target revision
Ash-exp Jan 20, 2025
ecf84f1
review changes
iamayushm Jan 20, 2025
2f76843
nil handling
iamayushm Jan 20, 2025
8cf7ea6
dev testing bug fixes
iamayushm Jan 20, 2025
4d062a5
fixes
iamayushm Jan 20, 2025
fc43af7
value file name fix
iamayushm Jan 20, 2025
f842233
fixes
iamayushm Jan 20, 2025
6a5bf44
repo url function update
iamayushm Jan 20, 2025
2ba80d3
git repo url handing using code
iamayushm Jan 20, 2025
b302417
fixing import cycle
iamayushm Jan 20, 2025
afe491b
feat: dynamic chart loaction and valuesfile path
Ash-exp Jan 21, 2025
d535a6e
CRUD operations
iamayushm Jan 22, 2025
dc4c752
repo clone and env override create flow
iamayushm Jan 22, 2025
b642d6d
wip: self review changes
iamayushm Jan 22, 2025
e3bc523
feat: trigger flows updated
Ash-exp Jan 22, 2025
74837b4
self review changes
iamayushm Jan 22, 2025
a5a2680
refactoring
iamayushm Jan 22, 2025
416d0ac
Merge remote-tracking branch 'origin/develop' into link-external-argocd
iamayushm Jan 22, 2025
bd6ddf9
Merge remote-tracking branch 'origin/develop' into crud-deployment-co…
iamayushm Jan 22, 2025
2385dd2
self review fix: env override create
iamayushm Jan 22, 2025
6d87579
skipping checks
iamayushm Jan 22, 2025
be79f0e
feat: Skip GitOps config CRUD ACD operation if argo module is not ins…
Ash-exp Jan 22, 2025
1568f16
handling for IsGitOpsConfigured
Ash-exp Jan 22, 2025
d98d85d
feat: release mode data adaptor
Ash-exp Jan 22, 2025
92905f9
Merge remote-tracking branch 'origin/link-external-argocd' into feat-…
Ash-exp Jan 22, 2025
d0e08d5
validation api
iamayushm Jan 22, 2025
c0bbbd2
deployment status changes and application filter logic change
iamayushm Jan 23, 2025
f1223ae
self review changes
iamayushm Jan 23, 2025
801c175
develop merge
iamayushm Jan 23, 2025
8d6b58f
delete acd app handling
iamayushm Jan 23, 2025
7c3e250
adding route
iamayushm Jan 23, 2025
ef70a2c
parent branch merge
iamayushm Jan 23, 2025
5d1e2e6
modifying validate link request
iamayushm Jan 24, 2025
b319b1d
pipeline crud operation
iamayushm Jan 24, 2025
49485d5
dev testing fix
iamayushm Jan 24, 2025
3062e1a
wip: release config data type fix
iamayushm Jan 24, 2025
3fd0ef6
fixing check
iamayushm Jan 27, 2025
94d9aa7
Merge remote-tracking branch 'origin/link-external-argocd' into feat-…
Ash-exp Jan 28, 2025
e49dc71
updated wire gen
Ash-exp Jan 28, 2025
35a1076
added api /environment-variables
Ash-exp Jan 28, 2025
2e271d5
Merge remote-tracking branch 'origin/develop' into link-external-argocd
Ash-exp Jan 29, 2025
190bebd
Merge remote-tracking branch 'origin/link-external-argocd' into crud-…
Ash-exp Jan 29, 2025
a3e9ca8
Merge remote-tracking branch 'origin/link-external-argocd' into feat-…
Ash-exp Jan 29, 2025
e11e5f0
added releaseMode validation
Ash-exp Jan 29, 2025
d422424
fix: isGitOpsEnable flag
Ash-exp Jan 29, 2025
de8627a
updated EnvironmentVariableList response
Ash-exp Jan 29, 2025
86ae011
Merge remote-tracking branch 'origin/crud-deployment-config' into fea…
Ash-exp Jan 29, 2025
33af0c6
updated git repo validations
Ash-exp Jan 29, 2025
563654f
updated migration number
Ash-exp Jan 30, 2025
4d03ff6
fix: skip pipeline create validation
Ash-exp Jan 30, 2025
b32db8d
panic handler for cd pipeline creation
Ash-exp Jan 30, 2025
ba13f52
updated wire dep
Ash-exp Jan 30, 2025
3fdf4f8
fix: cd trigger panic fix
Ash-exp Jan 31, 2025
ffea203
fix: validation migrate cd pipeline api
Ash-exp Jan 31, 2025
4ccb1ee
updated ValidateGitOpsRepoUrl request for custom gitops logic
Ash-exp Jan 31, 2025
64a2e6c
fix: git clone logic for validate migration request
Ash-exp Jan 31, 2025
a179894
fix: updated API key
Ash-exp Jan 31, 2025
2df5316
chart name handling for migrate release
Ash-exp Jan 31, 2025
3c37ea3
fix: chart validation
Ash-exp Jan 31, 2025
0a6eb42
fix: chart validation
Ash-exp Jan 31, 2025
abaa1e9
fix: pipeline creation
Ash-exp Feb 1, 2025
737f255
feat: is gitops repo configured flag updated
Ash-exp Feb 3, 2025
bcb6de9
wip: trigger fix
iamayushm Feb 3, 2025
5920380
feat: filter external argo app list
Ash-exp Feb 3, 2025
a0d24b4
read service for circular import
iamayushm Feb 4, 2025
a95a2ef
Merge remote-tracking branch 'origin/feat-gitops-client-refactoring' …
iamayushm Feb 4, 2025
f63027f
fix nil poniter panic
Ash-exp Feb 4, 2025
13548fc
fix: empty argo app list
Ash-exp Feb 4, 2025
2965d1b
fix empty app name
iamayushm Feb 4, 2025
8c40b19
updated dep of DeploymentConfigService instead of DeploymentConfigRea…
Ash-exp Feb 4, 2025
b202c20
minor refactorings
Ash-exp Feb 4, 2025
5ce1b1b
replaced release app name from util function
Ash-exp Feb 4, 2025
bd2f597
validation and flag if config is for external helm release
iamayushm Feb 4, 2025
68883b9
Merge remote-tracking branch 'origin/feat-gitops-client-refactoring' …
iamayushm Feb 4, 2025
238a9a0
fix migrated from flag
iamayushm Feb 4, 2025
8223283
fix: resource tree api with scoop
Ash-exp Feb 5, 2025
4112dce
fix: error handling for GetResourceTree
Ash-exp Feb 5, 2025
f668521
fixing set chart location function
iamayushm Feb 5, 2025
f6ff259
updating config type
iamayushm Feb 5, 2025
3375e8e
fix: scoop argo_cd GetResourceTree
Ash-exp Feb 5, 2025
cc0df06
fix: updated validation error
Ash-exp Feb 5, 2025
1a7e90d
fix: updated BuildDeployedAppName references
Ash-exp Feb 6, 2025
f7cd451
fix: common wire set
Ash-exp Feb 6, 2025
618ecc2
updating chart location while delete
iamayushm Feb 6, 2025
7a1bcf1
fix user id
iamayushm Feb 6, 2025
ebc2ada
common function for url already present
iamayushm Feb 6, 2025
2b4e297
removing duplicate logic for pipeline filter
iamayushm Feb 6, 2025
41e4fc6
fix: nil checker issues
Ash-exp Feb 7, 2025
d3a77b1
updated global api
Ash-exp Feb 7, 2025
a094ceb
pg no rows handling
iamayushm Feb 7, 2025
401f332
manual sync mode fix for trigger/deployment statys
iamayushm Feb 7, 2025
bde0385
fix: resource tree
Ash-exp Feb 8, 2025
ff5ce6e
fix: panic handling
Ash-exp Feb 8, 2025
d7208d7
fix default namespace
iamayushm Feb 9, 2025
2fcc06c
wip
iamayushm Feb 9, 2025
c7eb21c
fix: pipeline delete flow
Ash-exp Feb 9, 2025
3a7f0fc
fix: delete apllication object
Ash-exp Feb 10, 2025
40a271e
fix: delete application object
Ash-exp Feb 10, 2025
39696ba
chore: refactored AppDetailsReadService
Ash-exp Feb 10, 2025
9bfaac0
added: vlaidation for link external release
Ash-exp Feb 10, 2025
0c66b84
review comment incorporated
Ash-exp Feb 10, 2025
e1501e6
fix: pointer datatype
Ash-exp Feb 10, 2025
181763d
added: EnforcedPolicyViolation validation
Ash-exp Feb 10, 2025
b7602af
Merge remote-tracking branch 'origin/develop' into feat-gitops-client…
Ash-exp Feb 10, 2025
6adaf88
fix app clone
iamayushm Feb 11, 2025
4bb383c
make fix
iamayushm Feb 11, 2025
8fa26b4
fix: workflow_execution_stage cloumn
Ash-exp Feb 11, 2025
8575a6d
added gitops adapter
Ash-exp Feb 11, 2025
95a0e19
helm deployment status fix
iamayushm Feb 11, 2025
c835099
updated deployment config queries
Ash-exp Feb 11, 2025
e785cfd
fix: generate manifest diff
Ash-exp Feb 12, 2025
a74e685
wire gen updated
Ash-exp Feb 12, 2025
4d108cf
updated feature flag name
Ash-exp Feb 12, 2025
5bbe9c0
updated env_gen.md file
Ash-exp Feb 12, 2025
1e639e4
feat: argocd resource tree support
Ash-exp Feb 12, 2025
69a88d8
fix: nil handling updated
Ash-exp Feb 13, 2025
e37f8e4
fix: context handling
Ash-exp Feb 13, 2025
f44a592
Merge remote-tracking branch 'origin/develop' into feat-gitops-client…
Ash-exp Feb 13, 2025
6d156f7
review changes
iamayushm Feb 13, 2025
1585ac6
chore: deployment config refactorings
Ash-exp Feb 16, 2025
8c5eb5d
fix: on-board argocd issues
Ash-exp Feb 16, 2025
188093e
updated updateArgoAppDeleteStatus func
Ash-exp Feb 16, 2025
74ad6ad
Merge remote-tracking branch 'origin/feat-gitops-client-refactoring' …
Ash-exp Feb 16, 2025
529a935
Merge pull request #6399 from devtron-labs/chore-deployment-config-re…
Ash-exp Feb 16, 2025
eb9c8b4
review changes
iamayushm Feb 16, 2025
ad4a7c3
make fix
iamayushm Feb 16, 2025
d2c1a34
delete argo app error handling fixes
iamayushm Feb 17, 2025
b0f9e5a
payload changes
iamayushm Feb 17, 2025
0926759
argo app listing api updated
Ash-exp Feb 17, 2025
f0f8364
updated wire_gen files
Ash-exp Feb 17, 2025
e082b02
Merge remote-tracking branch 'origin/feat-gitops-client-refactoring' …
Ash-exp Feb 17, 2025
5538bf7
Merge pull request #6401 from devtron-labs/feat-resource-tree-support
Ash-exp Feb 17, 2025
7ed9631
chore: Argocd dependabot fixes (#6402)
iamayushm Feb 17, 2025
b565250
Merge pull request #6316 from devtron-labs/feat-gitops-client-refacto…
Ash-exp Feb 17, 2025
41dc355
Merge pull request #6315 from devtron-labs/crud-deployment-config
Ash-exp Feb 17, 2025
2597330
develop merge
iamayushm Feb 17, 2025
0ee8a66
fix: link request
iamayushm Feb 17, 2025
ef1cc8e
updated migration script
Ash-exp Feb 17, 2025
fdd08e8
fix: GetDeploymentConfigMinForAppAndEnv for app stage api
Ash-exp Feb 17, 2025
a53fbbf
fix: helm app gitops target revision
Ash-exp Feb 17, 2025
79df35d
fix: cd pipeline create blocked if argo module not installed
Ash-exp Feb 17, 2025
261b336
setting repo url in new deployment config also
iamayushm Feb 18, 2025
6af3d53
default branch (backward compatibility) if branch is not passed
iamayushm Feb 18, 2025
035a492
updated target revision
Ash-exp Feb 18, 2025
45ef00d
fix: release config target revision
Ash-exp Feb 18, 2025
9d29f84
updated not deployed status to degraded
Ash-exp Feb 18, 2025
d4aaa1e
feat-gitops-client branch merge
iamayushm Feb 18, 2025
ee27457
go mod tidy
iamayushm Feb 18, 2025
616574e
fix: app delete flow
Ash-exp Feb 19, 2025
17ee219
fix: git commit ref not found
Ash-exp Feb 20, 2025
70edd33
fix: git commit ref not found
Ash-exp Feb 20, 2025
df39ac0
fix: gitops branch pull error
Ash-exp Feb 20, 2025
32e5226
fix enum
iamayushm Feb 20, 2025
ba05130
Merge remote-tracking branch 'origin/develop' into link-external-argocd
Ash-exp Feb 21, 2025
fc13736
fix: removed unused import
Ash-exp Feb 21, 2025
d9eaabb
chore: func renamed
Ash-exp Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 12 additions & 8 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ import (
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
"github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate"
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
"github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig"
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup"
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/app"
read4 "github.com/devtron-labs/devtron/pkg/app/appDetails/read"
"github.com/devtron-labs/devtron/pkg/app/dbMigration"
"github.com/devtron-labs/devtron/pkg/app/status"
"github.com/devtron-labs/devtron/pkg/appClone"
Expand All @@ -128,6 +128,7 @@ import (
"github.com/devtron-labs/devtron/pkg/bulkAction/service"
"github.com/devtron-labs/devtron/pkg/chart"
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
read2 "github.com/devtron-labs/devtron/pkg/chart/read"
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
"github.com/devtron-labs/devtron/pkg/commonService"
"github.com/devtron-labs/devtron/pkg/config"
Expand Down Expand Up @@ -357,6 +358,8 @@ func InitializeApp() (*App, error) {
wire.Bind(new(gitOpsConfig.DevtronAppGitOpConfigService), new(*gitOpsConfig.DevtronAppGitOpConfigServiceImpl)),
chart.NewChartServiceImpl,
wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)),
read2.NewChartReadServiceImpl,
wire.Bind(new(read2.ChartReadService), new(*read2.ChartReadServiceImpl)),
service.NewBulkUpdateServiceImpl,
wire.Bind(new(service.BulkUpdateService), new(*service.BulkUpdateServiceImpl)),

Expand All @@ -375,6 +378,10 @@ func InitializeApp() (*App, error) {
wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)),
appList2.NewAppListingRestHandlerImpl,
wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)),

read4.NewAppDetailsReadServiceImpl,
wire.Bind(new(read4.AppDetailsReadService), new(*read4.AppDetailsReadServiceImpl)),

app.NewAppListingServiceImpl,
wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)),
repository.NewAppListingRepositoryImpl,
Expand Down Expand Up @@ -622,6 +629,7 @@ func InitializeApp() (*App, error) {
repository9.NewClusterInstalledAppsRepositoryImpl,
wire.Bind(new(repository9.ClusterInstalledAppsRepository), new(*repository9.ClusterInstalledAppsRepositoryImpl)),

commonService.NewCommonBaseServiceImpl,
commonService.NewCommonServiceImpl,
wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)),

Expand Down Expand Up @@ -659,8 +667,8 @@ func InitializeApp() (*App, error) {

router.NewCommonRouterImpl,
wire.Bind(new(router.CommonRouter), new(*router.CommonRouterImpl)),
restHandler.NewCommonRestHanlderImpl,
wire.Bind(new(restHandler.CommonRestHanlder), new(*restHandler.CommonRestHanlderImpl)),
restHandler.NewCommonRestHandlerImpl,
wire.Bind(new(restHandler.CommonRestHandler), new(*restHandler.CommonRestHandlerImpl)),

router.NewScopedVariableRouterImpl,
wire.Bind(new(router.ScopedVariableRouter), new(*router.ScopedVariableRouterImpl)),
Expand Down Expand Up @@ -941,11 +949,7 @@ func InitializeApp() (*App, error) {
cel.NewCELServiceImpl,
wire.Bind(new(cel.EvaluatorService), new(*cel.EvaluatorServiceImpl)),

deploymentConfig.NewRepositoryImpl,
wire.Bind(new(deploymentConfig.Repository), new(*deploymentConfig.RepositoryImpl)),

common.NewDeploymentConfigServiceImpl,
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),
common.WireSet,

repoCredsK8sClient.NewRepositoryCredsK8sClientImpl,
wire.Bind(new(repoCredsK8sClient.RepositoryCredsK8sClient), new(*repoCredsK8sClient.RepositoryCredsK8sClientImpl)),
Expand Down
2 changes: 2 additions & 0 deletions WiringNilCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func skipUnnecessaryFieldsForCheck(fieldName, valName string) bool {
"modulecronserviceimpl": {"cron"},
"oteltracingserviceimpl": {"traceprovider"},
"terminalaccessrepositoryimpl": {"templatescache"},
"grpcapiclientimpl": {"serviceclient"},
"serverenvconfig": {"errorencounteredongettingdevtronhelmrelease"},
}
if _, ok := fieldAndValName[valName]; ok {
for _, ignoreFieldName := range fieldAndValName[valName] {
Expand Down
6 changes: 5 additions & 1 deletion api/argoApplication/ArgoApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package argoApplication

import (
"context"
"errors"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/argoApplication"
Expand Down Expand Up @@ -89,6 +90,9 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
return
}
ctx := r.Context()
ctx = context.WithValue(ctx, "token", token)

var err error
v := r.URL.Query()
resourceName := v.Get("name")
Expand All @@ -104,7 +108,7 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
return
}
}
resp, err := handler.readService.GetAppDetail(resourceName, namespace, clusterId)
resp, err := handler.readService.GetAppDetailEA(ctx, resourceName, namespace, clusterId)
if err != nil {
handler.logger.Errorw("error in getting argo application app detail", "err", err, "resourceName", resourceName, "clusterId", clusterId)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
1 change: 1 addition & 0 deletions api/argoApplication/wire_argoApplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var ArgoApplicationWireSetFull = wire.NewSet(
config.NewArgoApplicationConfigServiceImpl,
wire.Bind(new(config.ArgoApplicationConfigService), new(*config.ArgoApplicationConfigServiceImpl)),

argoApplication.NewArgoApplicationServiceImpl,
argoApplication.NewArgoApplicationServiceExtendedServiceImpl,
wire.Bind(new(argoApplication.ArgoApplicationService), new(*argoApplication.ArgoApplicationServiceExtendedImpl)),

Expand Down
13 changes: 13 additions & 0 deletions api/bean/AppView/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,16 @@ type LinkOuts struct {
Link string `json:"link,omitempty"`
Description string `json:"description,omitempty"`
}

type AppStages struct {
AppId int `json:"app_id,omitempty" sql:"app_id"`
CiTemplateId int `json:"ci_template_id,omitempty" sql:"ci_template_id"`
CiPipelineId int `json:"ci_pipeline_id,omitempty" sql:"ci_pipeline_id"`
ChartId int `json:"chart_id,omitempty" sql:"chart_id"`
ChartGitRepoUrl string `json:"chart_git_repo_url,omitempty" sql:"chart_git_repo_url"`
PipelineId int `json:"pipeline_id,omitempty" sql:"pipeline_id"`
YamlStatus int `json:"yaml_status,omitempty" sql:"yaml_status"`
YamlReviewed bool `json:"yaml_reviewed,omitempty" sql:"yaml_reviewed"`
DeploymentConfigRepoURL string `json:"deployment_config_repo_url" sql:"-"`
GitMaterialExists int `json:"-" sql:"-"`
}
15 changes: 10 additions & 5 deletions api/bean/gitOps/GitOpsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ type GitOpsConfigDto struct {
IsTLSKeyDataPresent bool `json:"isTLSKeyDataPresent"`

// TODO refactoring: create different struct for internal fields
GitRepoName string `json:"-"`
UserEmailId string `json:"-"`
Description string `json:"-"`
UserId int32 `json:"-"`
GitRepoName string `json:"-"`
TargetRevision string `json:"-"`
UserEmailId string `json:"-"`
Description string `json:"-"`
UserId int32 `json:"-"`
}

func (dto GitOpsConfigDto) GetHostUrl() string {
return dto.Host
}

type GitRepoRequestDto struct {
Expand Down Expand Up @@ -80,5 +85,5 @@ func IsGitOpsRepoNotConfigured(gitRepoUrl string) bool {
}

func IsGitOpsRepoConfigured(gitRepoUrl string) bool {
return len(gitRepoUrl) != 0 || gitRepoUrl != GIT_REPO_NOT_CONFIGURED
return !IsGitOpsRepoNotConfigured(gitRepoUrl)
}
3 changes: 2 additions & 1 deletion api/helm-app/HelmAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
"github.com/devtron-labs/devtron/pkg/argoApplication"
"github.com/devtron-labs/devtron/pkg/argoApplication/helper"
clusterBean "github.com/devtron-labs/devtron/pkg/cluster/bean"
clientErrors "github.com/devtron-labs/devtron/pkg/errors"
"github.com/devtron-labs/devtron/pkg/fluxApplication"
bean2 "github.com/devtron-labs/devtron/pkg/k8s/application/bean"
Expand Down Expand Up @@ -467,7 +468,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter,
// validate if the devtron-operator helm release, block that for deletion
if appIdentifier.ReleaseName == handler.serverEnvConfig.DevtronHelmReleaseName &&
appIdentifier.Namespace == handler.serverEnvConfig.DevtronHelmReleaseNamespace &&
appIdentifier.ClusterId == bean.DEFAULT_CLUSTER_ID {
appIdentifier.ClusterId == clusterBean.DefaultClusterId {
common.WriteJsonResp(w, errors.New("cannot delete this default helm app"), nil, http.StatusForbidden)
return
}
Expand Down
1 change: 0 additions & 1 deletion api/helm-app/bean/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
)

const (
DEFAULT_CLUSTER_ID = 1
SOURCE_DEVTRON_APP SourceAppType = "devtron-app"
SOURCE_HELM_APP SourceAppType = "helm-app"
SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app"
Expand Down
6 changes: 4 additions & 2 deletions api/k8s/application/k8sApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
}

token := r.Header.Get("token")
ctx := r.Context()
ctx = context.WithValue(ctx, "token", token)
var k8sAppDetail AppView.AppDetailContainer
var resourceTreeResponse *gRPC.ResourceTreeResponse
var clusterId int
Expand All @@ -276,7 +278,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
return
}
//RBAC enforcer Ends
appDetail, err := handler.helmAppService.GetApplicationDetail(r.Context(), appIdentifier)
appDetail, err := handler.helmAppService.GetApplicationDetail(ctx, appIdentifier)
if err != nil {
apiError := clientErrors.ConvertToApiError(err)
if apiError != nil {
Expand All @@ -303,7 +305,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
}
//RBAC enforcer Ends

appDetail, err := handler.argoApplicationReadService.GetAppDetail(appIdentifier.AppName, appIdentifier.Namespace, appIdentifier.ClusterId)
appDetail, err := handler.argoApplicationReadService.GetAppDetailEA(r.Context(), appIdentifier.AppName, appIdentifier.Namespace, appIdentifier.ClusterId)
if err != nil {
apiError := clientErrors.ConvertToApiError(err)
if apiError != nil {
Expand Down
5 changes: 3 additions & 2 deletions api/module/ModuleRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package module
import (
"encoding/json"
"errors"
"github.com/devtron-labs/devtron/pkg/module/bean"
"net/http"

"github.com/devtron-labs/devtron/api/restHandler/common"
Expand Down Expand Up @@ -135,7 +136,7 @@ func (impl ModuleRestHandlerImpl) HandleModuleAction(w http.ResponseWriter, r *h

// decode request
decoder := json.NewDecoder(r.Body)
var moduleActionRequestDto *module.ModuleActionRequestDto
var moduleActionRequestDto *bean.ModuleActionRequestDto
err = decoder.Decode(&moduleActionRequestDto)
if err != nil {
impl.logger.Errorw("error in decoding request in HandleModuleAction", "err", err)
Expand Down Expand Up @@ -184,7 +185,7 @@ func (impl ModuleRestHandlerImpl) EnableModule(w http.ResponseWriter, r *http.Re
}
// decode request
decoder := json.NewDecoder(r.Body)
var moduleEnableRequestDto module.ModuleEnableRequestDto
var moduleEnableRequestDto bean.ModuleEnableRequestDto
err = decoder.Decode(&moduleEnableRequestDto)
if err != nil {
impl.logger.Errorw("error in decoding request in ModuleEnableRequestDto", "err", err)
Expand Down
6 changes: 5 additions & 1 deletion api/module/wire_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package module

import (
"github.com/devtron-labs/devtron/pkg/module"
"github.com/devtron-labs/devtron/pkg/module/bean"
"github.com/devtron-labs/devtron/pkg/module/read"
moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo"
moduleDataStore "github.com/devtron-labs/devtron/pkg/module/store"
"github.com/google/wire"
Expand All @@ -28,9 +30,11 @@ var ModuleWireSet = wire.NewSet(
wire.Bind(new(module.ModuleActionAuditLogRepository), new(*module.ModuleActionAuditLogRepositoryImpl)),
moduleRepo.NewModuleRepositoryImpl,
wire.Bind(new(moduleRepo.ModuleRepository), new(*moduleRepo.ModuleRepositoryImpl)),
read.NewModuleReadServiceImpl,
wire.Bind(new(read.ModuleReadService), new(*read.ModuleReadServiceImpl)),
moduleRepo.NewModuleResourceStatusRepositoryImpl,
wire.Bind(new(moduleRepo.ModuleResourceStatusRepository), new(*moduleRepo.ModuleResourceStatusRepositoryImpl)),
module.ParseModuleEnvConfig,
bean.ParseModuleEnvConfig,
moduleDataStore.InitModuleDataStore,
module.NewModuleServiceHelperImpl,
wire.Bind(new(module.ModuleServiceHelper), new(*module.ModuleServiceHelperImpl)),
Expand Down
29 changes: 23 additions & 6 deletions api/restHandler/CommonRestHanlder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ import (
"go.uber.org/zap"
)

type CommonRestHanlder interface {
type CommonRestHandler interface {
GlobalChecklist(w http.ResponseWriter, r *http.Request)
EnvironmentVariableList(w http.ResponseWriter, r *http.Request)
}

type CommonRestHanlderImpl struct {
type CommonRestHandlerImpl struct {
logger *zap.SugaredLogger
userAuthService user.UserService
commonService commonService.CommonService
}

func NewCommonRestHanlderImpl(
func NewCommonRestHandlerImpl(
logger *zap.SugaredLogger,
userAuthService user.UserService,
commonService commonService.CommonService) *CommonRestHanlderImpl {
return &CommonRestHanlderImpl{
commonService commonService.CommonService) *CommonRestHandlerImpl {
return &CommonRestHandlerImpl{
logger: logger,
userAuthService: userAuthService,
commonService: commonService,
}
}

func (impl CommonRestHanlderImpl) GlobalChecklist(w http.ResponseWriter, r *http.Request) {
func (impl CommonRestHandlerImpl) GlobalChecklist(w http.ResponseWriter, r *http.Request) {
userId, err := impl.userAuthService.GetLoggedInUser(r)
if userId == 0 || err != nil {
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
Expand All @@ -61,3 +62,19 @@ func (impl CommonRestHanlderImpl) GlobalChecklist(w http.ResponseWriter, r *http

common.WriteJsonResp(w, err, res, http.StatusOK)
}

func (impl CommonRestHandlerImpl) EnvironmentVariableList(w http.ResponseWriter, r *http.Request) {
userId, err := impl.userAuthService.GetLoggedInUser(r)
if userId == 0 || err != nil {
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
// TODO: ADD RBAC (if required)
res, err := impl.commonService.EnvironmentVariableList()
if err != nil {
impl.logger.Errorw("service err, EnvironmentVariableList", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
common.WriteJsonResp(w, err, res, http.StatusOK)
}
13 changes: 9 additions & 4 deletions api/restHandler/CoreAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider"
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read"
pipelineBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
bean3 "github.com/devtron-labs/devtron/pkg/chart/bean"
read5 "github.com/devtron-labs/devtron/pkg/chart/read"
"github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
read3 "github.com/devtron-labs/devtron/pkg/team/read"
"net/http"
Expand Down Expand Up @@ -101,6 +103,7 @@ type CoreAppRestHandlerImpl struct {
pipelineStageService pipeline.PipelineStageService
ciPipelineRepository pipelineConfig.CiPipelineRepository
teamReadService read3.TeamReadService
chartReadService read5.ChartReadService
}

func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil,
Expand All @@ -112,7 +115,8 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository,
gitProviderReadService read.GitProviderReadService,
gitMaterialReadService read2.GitMaterialReadService,
teamReadService read3.TeamReadService) *CoreAppRestHandlerImpl {
teamReadService read3.TeamReadService,
chartReadService read5.ChartReadService) *CoreAppRestHandlerImpl {
handler := &CoreAppRestHandlerImpl{
logger: logger,
userAuthService: userAuthService,
Expand All @@ -136,6 +140,7 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
pipelineStageService: pipelineStageService,
ciPipelineRepository: ciPipelineRepository,
teamReadService: teamReadService,
chartReadService: chartReadService,
}
return handler
}
Expand Down Expand Up @@ -551,7 +556,7 @@ func (handler CoreAppRestHandlerImpl) buildAppEnvironmentDeploymentTemplate(appI
return nil, err, http.StatusBadRequest
}

appDeploymentTemplate, err := handler.chartService.FindLatestChartForAppByAppId(appId)
appDeploymentTemplate, err := handler.chartReadService.FindLatestChartForAppByAppId(appId)
if err != nil {
if err != pg.ErrNoRows {
handler.logger.Errorw("service err, GetDeploymentTemplate in GetAppAllDetail", "err", err, "appId", appId, "envId", envId)
Expand Down Expand Up @@ -1365,7 +1370,7 @@ func (handler CoreAppRestHandlerImpl) createDockerConfig(appId int, dockerConfig
func (handler CoreAppRestHandlerImpl) createDeploymentTemplate(ctx context.Context, appId int, deploymentTemplate *appBean.DeploymentTemplate, userId int32) (error, int) {
handler.logger.Infow("Create App - creating deployment template", "appId", appId, "DeploymentStrategy", deploymentTemplate)

createDeploymentTemplateRequest := chart.TemplateRequest{
createDeploymentTemplateRequest := bean3.TemplateRequest{
AppId: appId,
ChartRefId: deploymentTemplate.ChartRefId,
IsAppMetricsEnabled: deploymentTemplate.ShowAppMetrics,
Expand Down Expand Up @@ -1839,7 +1844,7 @@ func (handler CoreAppRestHandlerImpl) createEnvDeploymentTemplate(appId int, use
chartEntry, err := handler.chartRepo.FindChartByAppIdAndRefId(appId, chartRefId)
if err != nil {
if pg.ErrNoRows == err {
templateRequest := chart.TemplateRequest{
templateRequest := bean3.TemplateRequest{
AppId: appId,
ChartRefId: chartRefId,
ValuesOverride: []byte("{}"),
Expand Down
Loading
Loading