Skip to content

Commit

Permalink
Merge pull request #6052 from devtron-labs/release-candidate-v0.22.0
Browse files Browse the repository at this point in the history
release: Release candidate v0.22.0
  • Loading branch information
vikramdevtron authored Nov 7, 2024
2 parents b6ba56e + aa975d4 commit 127203b
Show file tree
Hide file tree
Showing 24 changed files with 451 additions and 424 deletions.
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
1 change: 1 addition & 0 deletions api/bean/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type DeploymentDetailContainer struct {
DeploymentConfig *bean.DeploymentConfig `json:"-"`
IsPipelineTriggered bool `json:"isPipelineTriggered"`
ReleaseMode string `json:"releaseMode"`
LastDeployedById int `json:"-" sql:"last_deployed_by_id"`
}

type AppDetailContainer struct {
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
12 changes: 8 additions & 4 deletions cmd/external-app/wire_gen.go

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

2 changes: 1 addition & 1 deletion internal/sql/repository/AppListingRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) (
func (impl AppListingRepositoryImpl) DeploymentDetailByArtifactId(ciArtifactId int, envId int) (bean.DeploymentDetailContainer, error) {
impl.Logger.Debug("reached at AppListingRepository:")
var deploymentDetail bean.DeploymentDetailContainer
query := "SELECT env.id AS environment_id, env.environment_name, env.default, pco.created_on as last_deployed_time, a.app_name" +
query := "SELECT env.id AS environment_id, env.environment_name, env.default, pco.created_on as last_deployed_time, pco.updated_by as last_deployed_by_id, a.app_name" +
" FROM pipeline_config_override pco" +
" INNER JOIN pipeline p on p.id = pco.pipeline_id" +
" INNER JOIN environment env ON env.id=p.environment_id" +
Expand Down
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
Loading

0 comments on commit 127203b

Please sign in to comment.