Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import (
"github.com/devtron-labs/devtron/pkg/appStatus"
"github.com/devtron-labs/devtron/pkg/appStore/chartGroup"
repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository"
repository9 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode"
deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange"
Expand Down Expand Up @@ -339,9 +340,6 @@ func InitializeApp() (*App, error) {
pipelineConfig.NewMaterialRepositoryImpl,
wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)),

util.NewChartTemplateServiceImpl,
wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)),

// scoped variables start
variables.NewScopedVariableServiceImpl,
wire.Bind(new(variables.ScopedVariableService), new(*variables.ScopedVariableServiceImpl)),
Expand Down Expand Up @@ -647,6 +645,8 @@ func InitializeApp() (*App, error) {
wire.Bind(new(chartGroup2.ChartGroupRouter), new(*chartGroup2.ChartGroupRouterImpl)),
repository4.NewChartGroupDeploymentRepositoryImpl,
wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)),
repository9.NewClusterInstalledAppsRepositoryImpl,
wire.Bind(new(repository9.ClusterInstalledAppsRepository), new(*repository9.ClusterInstalledAppsRepositoryImpl)),

commonService.NewCommonServiceImpl,
wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)),
Expand Down
32 changes: 11 additions & 21 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ import (
"encoding/json"
"errors"
"fmt"
service2 "github.com/devtron-labs/devtron/api/helm-app/service"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
"net/http"
"strconv"
"strings"
"time"

openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient"
service2 "github.com/devtron-labs/devtron/api/helm-app/service"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/internal/util"
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
bean2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean"
"github.com/devtron-labs/devtron/pkg/attributes"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
Expand All @@ -43,10 +39,11 @@ import (
"github.com/gorilla/mux"
"go.uber.org/zap"
"gopkg.in/go-playground/validator.v9"
"net/http"
"strconv"
"strings"
)

const HELM_APP_UPDATE_COUNTER = "HelmAppUpdateCounter"

type AppStoreDeploymentRestHandler interface {
InstallApp(w http.ResponseWriter, r *http.Request)
GetInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request)
Expand All @@ -68,17 +65,17 @@ type AppStoreDeploymentRestHandlerImpl struct {
validator *validator.Validate
helmAppService service2.HelmAppService
argoUserService argo.ArgoUserService
attributesService attributes.AttributesService
installAppService EAMode.InstalledAppDBService
attributesService attributes.AttributesService
}

func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService,
enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm,
appStoreDeploymentService service.AppStoreDeploymentService,
appStoreDeploymentDBService service.AppStoreDeploymentDBService,
validator *validator.Validate, helmAppService service2.HelmAppService,
argoUserService argo.ArgoUserService, attributesService attributes.AttributesService,
installAppService EAMode.InstalledAppDBService) *AppStoreDeploymentRestHandlerImpl {
argoUserService argo.ArgoUserService,
installAppService EAMode.InstalledAppDBService, attributesService attributes.AttributesService) *AppStoreDeploymentRestHandlerImpl {
return &AppStoreDeploymentRestHandlerImpl{
Logger: Logger,
userAuthService: userAuthService,
Expand All @@ -90,8 +87,8 @@ func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthSer
validator: validator,
helmAppService: helmAppService,
argoUserService: argoUserService,
attributesService: attributesService,
installAppService: installAppService,
attributesService: attributesService,
}
}

Expand Down Expand Up @@ -488,7 +485,6 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo
}
ctx = context.WithValue(r.Context(), "token", acdToken)
}
triggeredAt := time.Now()
res, err := handler.appStoreDeploymentService.UpdateInstalledApp(ctx, &request)
if err != nil {
if strings.Contains(err.Error(), "application spec is invalid") {
Expand All @@ -498,13 +494,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
err1 := handler.appStoreDeploymentService.UpdatePreviousDeploymentStatusForAppStore(res, triggeredAt, err)
if err1 != nil {
handler.Logger.Errorw("error while update previous installed app version history", "err", err, "installAppVersionRequest", res)
//if installed app is updated and error is in updating previous deployment status, then don't block user, just show error.
}

err = handler.attributesService.UpdateKeyValueByOne(HELM_APP_UPDATE_COUNTER)
err = handler.attributesService.UpdateKeyValueByOne(bean2.HELM_APP_UPDATE_COUNTER)

common.WriteJsonResp(w, err, res, http.StatusOK)
}
Expand Down
10 changes: 6 additions & 4 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"fmt"
service2 "github.com/devtron-labs/devtron/api/helm-app/service"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean"
"github.com/devtron-labs/devtron/pkg/attributes"
"net/http"
"strconv"
"time"

"github.com/devtron-labs/common-lib/utils/k8sObjectsUtil"
client "github.com/devtron-labs/devtron/api/helm-app"
openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/internal/util"
Expand Down Expand Up @@ -60,15 +61,15 @@ type CommonDeploymentRestHandlerImpl struct {
installedAppService EAMode.InstalledAppDBService
validator *validator.Validate
helmAppService service2.HelmAppService
helmAppRestHandler client.HelmAppRestHandler
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,
helmAppRestHandler client.HelmAppRestHandler, argoUserService argo.ArgoUserService) *CommonDeploymentRestHandlerImpl {
argoUserService argo.ArgoUserService, attributesService attributes.AttributesService) *CommonDeploymentRestHandlerImpl {
return &CommonDeploymentRestHandlerImpl{
Logger: Logger,
userAuthService: userAuthService,
Expand All @@ -79,8 +80,8 @@ func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthServi
installedAppService: installedAppService,
validator: validator,
helmAppService: helmAppService,
helmAppRestHandler: helmAppRestHandler,
argoUserService: argoUserService,
attributesService: attributesService,
}
}
func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppId string, appId string) (string, *appStoreBean.InstallAppVersionDTO, error) {
Expand Down Expand Up @@ -324,5 +325,6 @@ func (handler *CommonDeploymentRestHandlerImpl) RollbackApplication(w http.Respo
res := &openapi2.RollbackReleaseResponse{
Success: &success,
}
handler.attributesService.UpdateKeyValueByOne(bean.HELM_APP_UPDATE_COUNTER)
common.WriteJsonResp(w, err, res, http.StatusOK)
}
18 changes: 10 additions & 8 deletions api/appStore/deployment/wire_appStoreDeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ package appStoreDeployment

import (
"github.com/devtron-labs/devtron/client/argocdServer"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
"github.com/devtron-labs/devtron/internal/util"
repository3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common"
deployment2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode/deployment"
appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common"
"github.com/google/wire"
)

var AppStoreDeploymentWireSet = wire.NewSet(
//util.GetDeploymentServiceTypeConfig,
repository.NewClusterInstalledAppsRepositoryImpl,
wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)),
util.NewChartTemplateServiceImpl,
wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)),
appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl,
wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)),
EAMode.NewEAModeDeploymentServiceImpl,
wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)),
deployment2.NewEAModeDeploymentServiceImpl,
wire.Bind(new(deployment2.EAModeDeploymentService), new(*deployment2.EAModeDeploymentServiceImpl)),
service.NewAppStoreDeploymentServiceImpl,
wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)),
service.NewAppStoreDeploymentDBServiceImpl,
Expand All @@ -41,8 +43,8 @@ var AppStoreDeploymentWireSet = wire.NewSet(
wire.Bind(new(AppStoreDeploymentRestHandler), new(*AppStoreDeploymentRestHandlerImpl)),
NewAppStoreDeploymentRouterImpl,
wire.Bind(new(AppStoreDeploymentRouter), new(*AppStoreDeploymentRouterImpl)),
repository.NewInstalledAppVersionHistoryRepositoryImpl,
wire.Bind(new(repository.InstalledAppVersionHistoryRepository), new(*repository.InstalledAppVersionHistoryRepositoryImpl)),
repository3.NewInstalledAppVersionHistoryRepositoryImpl,
wire.Bind(new(repository3.InstalledAppVersionHistoryRepository), new(*repository3.InstalledAppVersionHistoryRepositoryImpl)),

NewCommonDeploymentRestHandlerImpl,
wire.Bind(new(CommonDeploymentRestHandler), new(*CommonDeploymentRestHandlerImpl)),
Expand Down
4 changes: 2 additions & 2 deletions cmd/external-app/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import (
"github.com/devtron-labs/devtron/pkg/app"
"github.com/devtron-labs/devtron/pkg/app/dbMigration"
repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
deployment2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode/deployment"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment"
"github.com/devtron-labs/devtron/pkg/argoRepositoryCreds"
"github.com/devtron-labs/devtron/pkg/attributes"
Expand Down Expand Up @@ -185,7 +185,7 @@ func InitializeApp() (*App, error) {
// needed for enforcer util ends

// binding gitops to helm (for hyperion)
wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)),
wire.Bind(new(deployment.FullModeDeploymentService), new(*deployment2.EAModeDeploymentServiceImpl)),

router.NewTelemetryRouterImpl,
wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)),
Expand Down
10 changes: 7 additions & 3 deletions cmd/external-app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/util/ChartTemplateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type ChartTemplateService interface {
CreateZipFileForChart(chart *chart.Chart, outputChartPathDir string) ([]byte, error)
PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error)
}

type ChartTemplateServiceImpl struct {
randSource rand.Source
logger *zap.SugaredLogger
Expand Down
18 changes: 18 additions & 0 deletions pkg/appStore/adapter/Adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ func NewInstalledAppDeploymentAction(deploymentAppType string) *appStoreBean.Ins
}
return installedAppDeploymentAction
}
func UpdateRequestDTOForRollback(request, installedApp, installedAppVersionDTO *appStoreBean.InstallAppVersionDTO, installedAppVersionHistory *repository.InstalledAppVersionHistory) {
// Update basic version information and IDs for rollback
request.InstalledAppVersionId = installedApp.InstalledAppVersionId
request.AppStoreVersion = installedAppVersionDTO.AppStoreVersion

// Set the ID to installed app version if only the chart version changes
if installedApp.AppStoreVersion != installedAppVersionDTO.AppStoreVersion {
request.Id = installedAppVersionDTO.InstalledAppVersionId
}
// If the AppStoreId changes, reset the ID to indicate a new chart
if installedApp.AppStoreId != installedAppVersionDTO.AppStoreId {
request.Id = 0
}
// setting historical version overrides and reference information
request.ValuesOverrideYaml = installedAppVersionHistory.ValuesYamlRaw
request.ReferenceValueKind = installedAppVersionDTO.ReferenceValueKind
request.ReferenceValueId = installedAppVersionDTO.ReferenceValueId
}

// GenerateInstallAppVersionDTO converts repository.InstalledApps and repository.InstalledAppVersions db object to appStoreBean.InstallAppVersionDTO bean
func GenerateInstallAppVersionDTO(installedApp *repository.InstalledApps, installedAppVersion *repository.InstalledAppVersions, config *bean2.DeploymentConfig) *appStoreBean.InstallAppVersionDTO {
Expand Down
16 changes: 16 additions & 0 deletions pkg/appStore/bean/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ func (chart *InstallAppVersionDTO) GetAppIdentifierString() string {
}
return appIdentifier.GetUniqueAppNameIdentifier()
}
func (chart *InstallAppVersionDTO) NewInstalledAppVersionRequestDTO(userId int32, installedAppId int) *InstallAppVersionDTO {
chart.UserId = userId
chart.InstalledAppId = installedAppId
return chart
}
func (chart *InstallAppVersionDTO) UpdateLog(updatedOn time.Time) {
if chart == nil {
return
}
chart.UpdatedOn = updatedOn
}

// IsExternalCliApp It is used for filtering the incoming request for rollback case
func (chart *InstallAppVersionDTO) IsExternalCliApp() bool {
return chart.InstalledAppId == 0
}

// UpdateDeploymentAppType updates deploymentAppType to InstallAppVersionDTO
func (chart *InstallAppVersionDTO) UpdateDeploymentAppType(deploymentAppType string) {
Expand Down
Loading