Skip to content

Commit

Permalink
update 320 ua
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zhao <[email protected]>
  • Loading branch information
PetrusZ committed Nov 1, 2024
1 parent 0a92576 commit 2a6c686
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
5 changes: 0 additions & 5 deletions pkg/cli/initconfig/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ import (
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb/template"
vmcommonrepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb/vm"
statrepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/stat/repository/mongodb"
"github.com/koderover/zadig/v2/pkg/shared/handler"
systemrepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/system/repository/mongodb"
systemservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/system/service"
templateservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/templatestore/service"
sprintservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/sprint_management/service"
workflowservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/workflow/service/workflow"
configmongodb "github.com/koderover/zadig/v2/pkg/microservice/systemconfig/core/email/repository/mongodb"
userdb "github.com/koderover/zadig/v2/pkg/microservice/user/core/repository/mongodb"
Expand Down Expand Up @@ -254,9 +252,6 @@ func initSystemData() error {

templateservice.InitWorkflowTemplate()

ctx := handler.NewBackgroupContext()
sprintservice.InitAllProjectSprintTemplate(ctx)

// update offical plugins
workflowservice.UpdateOfficalPluginRepository(log.SugaredLogger())

Expand Down
23 changes: 23 additions & 0 deletions pkg/cli/upgradeassistant/cmd/migrate/320.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"gorm.io/gorm"

"github.com/koderover/zadig/v2/pkg/cli/upgradeassistant/internal/upgradepath"
templaterepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb/template"
sprintservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/sprint_management/service"
"github.com/koderover/zadig/v2/pkg/microservice/user/core/repository"
usermodels "github.com/koderover/zadig/v2/pkg/microservice/user/core/repository/models"
"github.com/koderover/zadig/v2/pkg/shared/handler"
Expand All @@ -36,6 +38,12 @@ func init() {
func V310ToV320() error {
ctx := handler.NewBackgroupContext()
ctx.Logger.Infof("-------- start init existed project's sprint template --------")
if err := initAllProjectSprintTemplate(ctx); err != nil {
ctx.Logger.Errorf("failed to init existed project's sprint template, error: %s", err)
return err
}

ctx.Logger.Infof("-------- start add get_sprint action for read-only role --------")
if err := addGetSprintActionForReadOnlyRole(ctx); err != nil {
ctx.Logger.Errorf("failed to add get_sprint action for read-only role, error: %s", err)
return err
Expand All @@ -48,6 +56,21 @@ func V320ToV310() error {
return nil
}

func initAllProjectSprintTemplate(ctx *handler.Context) error {
projects, err := templaterepo.NewProductColl().List()
if err != nil {
err = fmt.Errorf("failed to list project list, error: %s", err)
ctx.Logger.Error(err)
return err
}

for _, project := range projects {
sprintservice.InitSprintTemplate(ctx, project.ProductName)
}

return nil
}

func addGetSprintActionForReadOnlyRole(ctx *handler.Context) error {
action := &usermodels.Action{}
err := repository.DB.Where("action = ? AND resource = ?", "get_sprint", "SprintManagement").First(&action).Error
Expand Down
17 changes: 0 additions & 17 deletions pkg/microservice/aslan/core/sprint_management/service/sprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package service

import (
"fmt"
"time"

"github.com/pkg/errors"
Expand All @@ -26,7 +25,6 @@ import (
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models"
commonmodels "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb"
templaterepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb/template"
"github.com/koderover/zadig/v2/pkg/shared/handler"
e "github.com/koderover/zadig/v2/pkg/tool/errors"
"github.com/koderover/zadig/v2/pkg/types"
Expand Down Expand Up @@ -355,18 +353,3 @@ func ListSprint(ctx *handler.Context, opt *ListSprintOption) (*ListSprintResp, e
Total: total,
}, nil
}

func InitAllProjectSprintTemplate(ctx *handler.Context) {
projects, err := templaterepo.NewProductColl().List()
if err != nil {
err = fmt.Errorf("failed to list project list, error: %s", err)
ctx.Logger.Error(err)
return
}

for _, project := range projects {
InitSprintTemplate(ctx, project.ProductName)
}

return
}

0 comments on commit 2a6c686

Please sign in to comment.