Skip to content

Commit

Permalink
Merge branch 'main' into feat/chart-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pawan-mehta-dt authored Jan 22, 2025
2 parents 6033027 + 649f6c3 commit 8facf4f
Show file tree
Hide file tree
Showing 317 changed files with 37,556 additions and 9,739 deletions.
3 changes: 2 additions & 1 deletion App.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"crypto/tls"
"errors"
"fmt"
"github.com/devtron-labs/common-lib/middlewares"
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
Expand Down Expand Up @@ -137,7 +138,7 @@ func (app *App) Start() {
err = server.ListenAndServe()
}
//err := http.ListenAndServe(fmt.Sprintf(":%d", port), auth.Authorizer(app.Enforcer, app.sessionManager)(app.MuxRouter.Router))
if err != nil {
if err != nil && !errors.Is(err, http.ErrServerClosed) {
app.Logger.Errorw("error in startup", "err", err)
os.Exit(2)
}
Expand Down
18 changes: 9 additions & 9 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ import (
"github.com/devtron-labs/devtron/client/argocdServer/certificate"
cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster"
"github.com/devtron-labs/devtron/client/argocdServer/connection"
"github.com/devtron-labs/devtron/client/argocdServer/repoCredsK8sClient"
repocreds "github.com/devtron-labs/devtron/client/argocdServer/repocreds"
repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository"
session2 "github.com/devtron-labs/devtron/client/argocdServer/session"
"github.com/devtron-labs/devtron/client/argocdServer/version"
"github.com/devtron-labs/devtron/client/cron"
"github.com/devtron-labs/devtron/client/dashboard"
eClient "github.com/devtron-labs/devtron/client/events"
Expand Down Expand Up @@ -117,7 +119,6 @@ import (
repository9 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment"
"github.com/devtron-labs/devtron/pkg/appWorkflow"
"github.com/devtron-labs/devtron/pkg/argoRepositoryCreds"
"github.com/devtron-labs/devtron/pkg/asyncProvider"
"github.com/devtron-labs/devtron/pkg/attributes"
"github.com/devtron-labs/devtron/pkg/build"
Expand Down Expand Up @@ -167,7 +168,6 @@ import (
workflow3 "github.com/devtron-labs/devtron/pkg/workflow"
"github.com/devtron-labs/devtron/pkg/workflow/dag"
util2 "github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
cron2 "github.com/devtron-labs/devtron/util/cron"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/google/wire"
Expand Down Expand Up @@ -449,8 +449,8 @@ func InitializeApp() (*App, error) {
wire.Bind(new(repository8.ImageTaggingRepository), new(*repository8.ImageTaggingRepositoryImpl)),
imageTagging.NewImageTaggingServiceImpl,
wire.Bind(new(imageTagging.ImageTaggingService), new(*imageTagging.ImageTaggingServiceImpl)),
argocdServer.NewVersionServiceImpl,
wire.Bind(new(argocdServer.VersionService), new(*argocdServer.VersionServiceImpl)),
version.NewVersionServiceImpl,
wire.Bind(new(version.VersionService), new(*version.VersionServiceImpl)),

router.NewGitProviderRouterImpl,
wire.Bind(new(router.GitProviderRouter), new(*router.GitProviderRouterImpl)),
Expand Down Expand Up @@ -801,9 +801,9 @@ func InitializeApp() (*App, error) {

connection.NewArgoCDConnectionManagerImpl,
wire.Bind(new(connection.ArgoCDConnectionManager), new(*connection.ArgoCDConnectionManagerImpl)),
argo.NewArgoUserServiceImpl,
wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)),
//util2.GetEnvironmentVariables,
//argo.NewArgoUserServiceImpl,
//wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)),
////util2.GetEnvironmentVariables,
// AuthWireSet,

cron.NewCdApplicationStatusUpdateHandlerImpl,
Expand Down Expand Up @@ -950,8 +950,8 @@ func InitializeApp() (*App, error) {
common.NewDeploymentConfigServiceImpl,
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),

argoRepositoryCreds.NewRepositorySecret,
wire.Bind(new(argoRepositoryCreds.RepositorySecret), new(*argoRepositoryCreds.RepositorySecretImpl)),
repoCredsK8sClient.NewRepositorySecret,
wire.Bind(new(repoCredsK8sClient.RepositoryCreds), new(*repoCredsK8sClient.RepositorySecretImpl)),

repocreds.NewServiceClientImpl,
wire.Bind(new(repocreds.ServiceClient), new(*repocreds.ServiceClientImpl)),
Expand Down
25 changes: 10 additions & 15 deletions api/appStore/InstalledAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ import (
"encoding/json"
"errors"
"fmt"
bean2 "github.com/devtron-labs/devtron/api/bean/AppView"
client "github.com/devtron-labs/devtron/api/helm-app/gRPC"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource"
util3 "github.com/devtron-labs/devtron/pkg/appStore/util"
"github.com/devtron-labs/devtron/pkg/bean"
"github.com/devtron-labs/devtron/pkg/cluster/read"
"gopkg.in/go-playground/validator.v9"
"net/http"
"reflect"
"strconv"
"strings"
"time"

bean2 "github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/client/argocdServer/application"
"github.com/devtron-labs/devtron/client/cron"
Expand All @@ -50,7 +51,6 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/cluster"
"github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/devtron-labs/devtron/util/response"
"github.com/go-pg/pg"
Expand Down Expand Up @@ -88,11 +88,11 @@ type InstalledAppRestHandlerImpl struct {
appStoreDeploymentService service.AppStoreDeploymentService
appStoreDeploymentDBService service.AppStoreDeploymentDBService
helmAppClient client.HelmAppClient
argoUserService argo.ArgoUserService
cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler
installedAppRepository repository.InstalledAppRepository
appCrudOperationService app2.AppCrudOperationService
installedAppDeploymentTypeChangeService deploymentTypeChange.InstalledAppDeploymentTypeChangeService
clusterReadService read.ClusterReadService
}

func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService,
Expand All @@ -102,11 +102,13 @@ func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService u
chartGroupService chartGroup.ChartGroupService, validator *validator.Validate, clusterService cluster.ClusterService,
acdServiceClient application.ServiceClient, appStoreDeploymentService service.AppStoreDeploymentService,
appStoreDeploymentDBService service.AppStoreDeploymentDBService,
helmAppClient client.HelmAppClient, argoUserService argo.ArgoUserService,
helmAppClient client.HelmAppClient,

cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler,
installedAppRepository repository.InstalledAppRepository,
appCrudOperationService app2.AppCrudOperationService,
installedAppDeploymentTypeChangeService deploymentTypeChange.InstalledAppDeploymentTypeChangeService) *InstalledAppRestHandlerImpl {
installedAppDeploymentTypeChangeService deploymentTypeChange.InstalledAppDeploymentTypeChangeService,
clusterReadService read.ClusterReadService) *InstalledAppRestHandlerImpl {
return &InstalledAppRestHandlerImpl{
Logger: Logger,
userAuthService: userAuthService,
Expand All @@ -122,11 +124,11 @@ func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService u
appStoreDeploymentService: appStoreDeploymentService,
appStoreDeploymentDBService: appStoreDeploymentDBService,
helmAppClient: helmAppClient,
argoUserService: argoUserService,
cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler,
installedAppRepository: installedAppRepository,
appCrudOperationService: appCrudOperationService,
installedAppDeploymentTypeChangeService: installedAppDeploymentTypeChangeService,
clusterReadService: clusterReadService,
}
}
func (handler *InstalledAppRestHandlerImpl) FetchAppOverview(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -550,7 +552,7 @@ func (impl *InstalledAppRestHandlerImpl) DefaultComponentInstallation(w http.Res
return
}
impl.Logger.Errorw("request payload, DefaultComponentInstallation", "clusterId", clusterId)
cluster, err := impl.clusterService.FindById(clusterId)
cluster, err := impl.clusterReadService.FindById(clusterId)
if err != nil {
impl.Logger.Errorw("service err, DefaultComponentInstallation", "error", err, "clusterId", clusterId)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -648,13 +650,6 @@ func (handler *InstalledAppRestHandlerImpl) DeleteArgoInstalledAppWithNonCascade
return
}
//rback block ends here
acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
handler.Logger.Errorw("error in getting acd token", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
ctx := context.WithValue(r.Context(), "token", acdToken)
request := &appStoreBean.InstallAppVersionDTO{}
request.InstalledAppId = installedAppId
request.AppName = installedApp.AppName
Expand All @@ -668,7 +663,7 @@ func (handler *InstalledAppRestHandlerImpl) DeleteArgoInstalledAppWithNonCascade
request.Namespace = installedApp.Namespace
request.AcdPartialDelete = true

request, err = handler.appStoreDeploymentService.DeleteInstalledApp(ctx, request)
request, err = handler.appStoreDeploymentService.DeleteInstalledApp(r.Context(), request)
if err != nil {
handler.Logger.Errorw("service err, DeleteInstalledApp", "err", err, "installAppId", installedAppId)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
32 changes: 2 additions & 30 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
util2 "github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/go-pg/pg"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -64,7 +63,6 @@ type AppStoreDeploymentRestHandlerImpl struct {
appStoreDeploymentDBService service.AppStoreDeploymentDBService
validator *validator.Validate
helmAppService service2.HelmAppService
argoUserService argo.ArgoUserService
installAppService EAMode.InstalledAppDBService
attributesService attributes.AttributesService
}
Expand All @@ -73,8 +71,8 @@ func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthSer
enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm,
appStoreDeploymentService service.AppStoreDeploymentService,
appStoreDeploymentDBService service.AppStoreDeploymentDBService,
validator *validator.Validate, helmAppService service2.HelmAppService,
argoUserService argo.ArgoUserService,
validator *validator.Validate,
helmAppService service2.HelmAppService,
installAppService EAMode.InstalledAppDBService, attributesService attributes.AttributesService) *AppStoreDeploymentRestHandlerImpl {
return &AppStoreDeploymentRestHandlerImpl{
Logger: Logger,
Expand All @@ -86,7 +84,6 @@ func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthSer
appStoreDeploymentDBService: appStoreDeploymentDBService,
validator: validator,
helmAppService: helmAppService,
argoUserService: argoUserService,
installAppService: installAppService,
attributesService: attributesService,
}
Expand Down Expand Up @@ -165,16 +162,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) InstallApp(w http.ResponseWrite
}
if util2.IsBaseStack() || util2.IsHelmApp(request.AppOfferingMode) {
ctx = context.WithValue(r.Context(), "token", token)
} else {
acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
handler.Logger.Errorw("error in getting acd token", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
ctx = context.WithValue(r.Context(), "token", acdToken)
}

defer cancel()
res, err := handler.appStoreDeploymentService.InstallApp(&request, ctx)
if err != nil {
Expand Down Expand Up @@ -348,14 +336,6 @@ func (handler AppStoreDeploymentRestHandlerImpl) DeleteInstalledApp(w http.Respo
}
if util2.IsBaseStack() || util2.IsHelmApp(request.AppOfferingMode) {
ctx = context.WithValue(r.Context(), "token", token)
} else {
acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
handler.Logger.Errorw("error in getting acd token", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
ctx = context.WithValue(r.Context(), "token", acdToken)
}

request, err = handler.appStoreDeploymentService.DeleteInstalledApp(ctx, request)
Expand Down Expand Up @@ -476,14 +456,6 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo
}
if util2.IsBaseStack() || util2.IsHelmApp(request.AppOfferingMode) {
ctx = context.WithValue(r.Context(), "token", token)
} else {
acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
handler.Logger.Errorw("error in getting acd token", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
ctx = context.WithValue(r.Context(), "token", acdToken)
}
res, err := handler.appStoreDeploymentService.UpdateInstalledApp(ctx, &request)
if err != nil {
Expand Down
13 changes: 1 addition & 12 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
util2 "github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/gorilla/mux"
"go.opentelemetry.io/otel"
Expand All @@ -61,15 +60,14 @@ type CommonDeploymentRestHandlerImpl struct {
installedAppService EAMode.InstalledAppDBService
validator *validator.Validate
helmAppService service2.HelmAppService
argoUserService argo.ArgoUserService
attributesService attributes.AttributesService
}

func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService,
enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm,
appStoreDeploymentService service.AppStoreDeploymentService, installedAppService EAMode.InstalledAppDBService,
validator *validator.Validate, helmAppService service2.HelmAppService,
argoUserService argo.ArgoUserService, attributesService attributes.AttributesService) *CommonDeploymentRestHandlerImpl {
attributesService attributes.AttributesService) *CommonDeploymentRestHandlerImpl {
return &CommonDeploymentRestHandlerImpl{
Logger: Logger,
userAuthService: userAuthService,
Expand All @@ -80,7 +78,6 @@ func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthServi
installedAppService: installedAppService,
validator: validator,
helmAppService: helmAppService,
argoUserService: argoUserService,
attributesService: attributesService,
}
}
Expand Down Expand Up @@ -305,14 +302,6 @@ func (handler *CommonDeploymentRestHandlerImpl) RollbackApplication(w http.Respo
}
if util2.IsBaseStack() || util2.IsHelmApp(appOfferingMode) {
ctx = context.WithValue(r.Context(), "token", token)
} else {
acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
handler.Logger.Errorw("error in getting acd token", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
ctx = context.WithValue(r.Context(), "token", acdToken)
}

defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion api/bean/AppView.go → api/bean/AppView/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package bean
package AppView

import (
"encoding/json"
Expand Down
7 changes: 7 additions & 0 deletions api/bean/Security.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type CreateVulnerabilityPolicyRequest struct {
Severity string `json:"severity,omitempty"`
}

func (r *CreateVulnerabilityPolicyRequest) IsRequestGlobal() bool {
if r.ClusterId == 0 && r.EnvId == 0 && r.AppId == 0 {
return true
}
return false
}

// CreateVulnerabilityPolicyResponse defines model for CreateVulnerabilityPolicyResponse.
type CreateVulnerabilityPolicyResponse struct {
// Error object
Expand Down
1 change: 1 addition & 0 deletions api/bean/ValuesOverrideRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ValuesOverrideRequest struct {
PipelineOverrideId int `json:"pipelineOverrideId"` // required for async install/upgrade event;
DeploymentType models.DeploymentType `json:"deploymentType"` // required for async install/upgrade handling; previously if was used internally
ForceSyncDeployment bool `json:"forceSyncDeployment,notnull"`
IsRollbackDeployment bool `json:"isRollbackDeployment"`
UserId int32 `json:"-"`
EnvId int `json:"-"`
EnvName string `json:"-"`
Expand Down
Loading

0 comments on commit 8facf4f

Please sign in to comment.