Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
27 changes: 6 additions & 21 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ 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/attributes"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
util2 "github.com/devtron-labs/devtron/util"
Expand All @@ -43,10 +37,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,7 +63,6 @@ type AppStoreDeploymentRestHandlerImpl struct {
validator *validator.Validate
helmAppService service2.HelmAppService
argoUserService argo.ArgoUserService
attributesService attributes.AttributesService
installAppService EAMode.InstalledAppDBService
}

Expand All @@ -77,7 +71,7 @@ func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthSer
appStoreDeploymentService service.AppStoreDeploymentService,
appStoreDeploymentDBService service.AppStoreDeploymentDBService,
validator *validator.Validate, helmAppService service2.HelmAppService,
argoUserService argo.ArgoUserService, attributesService attributes.AttributesService,
argoUserService argo.ArgoUserService,
installAppService EAMode.InstalledAppDBService) *AppStoreDeploymentRestHandlerImpl {
return &AppStoreDeploymentRestHandlerImpl{
Logger: Logger,
Expand All @@ -90,7 +84,6 @@ func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthSer
validator: validator,
helmAppService: helmAppService,
argoUserService: argoUserService,
attributesService: attributesService,
installAppService: installAppService,
}
}
Expand Down Expand Up @@ -488,7 +481,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 +490,6 @@ 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)

common.WriteJsonResp(w, err, res, http.StatusOK)
}
Expand Down
5 changes: 1 addition & 4 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"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 +59,14 @@ type CommonDeploymentRestHandlerImpl struct {
installedAppService EAMode.InstalledAppDBService
validator *validator.Validate
helmAppService service2.HelmAppService
helmAppRestHandler client.HelmAppRestHandler
argoUserService argo.ArgoUserService
}

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) *CommonDeploymentRestHandlerImpl {
return &CommonDeploymentRestHandlerImpl{
Logger: Logger,
userAuthService: userAuthService,
Expand All @@ -79,7 +77,6 @@ func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthServi
installedAppService: installedAppService,
validator: validator,
helmAppService: helmAppService,
helmAppRestHandler: helmAppRestHandler,
argoUserService: argoUserService,
}
}
Expand Down
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
14 changes: 9 additions & 5 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
10 changes: 10 additions & 0 deletions pkg/appStore/adapter/Adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ func NewInstalledAppDeploymentAction(deploymentAppType string) *appStoreBean.Ins
}
return installedAppDeploymentAction
}
func GenerateUpdateRequestDTO(request *appStoreBean.InstallAppVersionDTO, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistory *repository.InstalledAppVersionHistory, installedAppVersionDTO *appStoreBean.InstallAppVersionDTO) {
request.InstalledAppVersionId = installedApp.InstalledAppVersionId
request.AppStoreVersion = installedApp.AppStoreVersion

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
Loading