Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cde3380
feat: add release plan collaboration and versioned diffs
huanghongbo-hhb May 19, 2026
ac78461
chore: remove release plan RFC from PR
huanghongbo-hhb May 19, 2026
ac6efbe
refactor: simplify release plan version semantics
huanghongbo-hhb May 20, 2026
4f71191
chore: extend release plan collaboration ttl
huanghongbo-hhb May 20, 2026
db5a8c8
fix: align release plan approval logs in watcher
huanghongbo-hhb May 21, 2026
ebbde9f
fix: harden release plan collaboration flows
huanghongbo-hhb May 21, 2026
01e61c6
feat: support ordered release plan diffs
huanghongbo-hhb May 21, 2026
950e019
chore: remove diff tests from pr
huanghongbo-hhb May 21, 2026
8d3ec5d
refactor: simplify release plan diff labels
huanghongbo-hhb May 22, 2026
c0bd8a9
fix release plan collaboration cleanup and diff order
huanghongbo-hhb May 22, 2026
dd011f9
fix: improve release plan target order labels
huanghongbo-hhb May 22, 2026
4812543
fix: refine release plan version diff snapshots
huanghongbo-hhb May 28, 2026
6ab9efd
fix: polish release plan collaboration follow-ups
huanghongbo-hhb May 28, 2026
9739584
fix: harden release plan collaboration lifecycle
huanghongbo-hhb Jun 9, 2026
551e9a9
chore: remove release plan test files from pr
huanghongbo-hhb Jun 9, 2026
fac3036
fix: preserve release plan initial diff baseline
huanghongbo-hhb Jun 9, 2026
57fa175
fix: align release plan workflow diff snapshot
huanghongbo-hhb Jun 10, 2026
90b0220
fix: enrich release plan workflow snapshot
huanghongbo-hhb Jun 10, 2026
8b7f058
fix: log workflow snapshot recover events
huanghongbo-hhb Jun 10, 2026
f1a5a99
fix: keep workflow skipped flag in release plan snapshot
huanghongbo-hhb Jun 10, 2026
9122345
fix: backfill incomplete workflow diff base snapshot
huanghongbo-hhb Jun 10, 2026
ccdf6d0
feat: expose approval snapshot diff display mode
huanghongbo-hhb Jun 10, 2026
38f0eac
fix: preserve rich text release plan diff values
huanghongbo-hhb Jun 10, 2026
5186748
fix: skip empty release plan logs
huanghongbo-hhb Jun 11, 2026
cee6350
fix: cap diff depth and batch collab reads
huanghongbo-hhb Jun 11, 2026
928c28c
refactor: align release plan metadata section keys
huanghongbo-hhb Jun 11, 2026
40b6860
fix: skip empty release plan snapshot changes
huanghongbo-hhb Jun 12, 2026
fcbb3be
fix: ignore derived approval users in release plan logs
huanghongbo-hhb Jun 12, 2026
1ad1771
fix: refine release plan metadata diff display
huanghongbo-hhb Jun 12, 2026
6ccffce
fix: stabilize release plan workflow diff snapshots
huanghongbo-hhb Jun 12, 2026
8a6be57
fix: compat legacy release plan workflow lookup fields
huanghongbo-hhb Jun 12, 2026
167170e
fix: normalize legacy release plan workflow specs
huanghongbo-hhb Jun 12, 2026
65bf542
perf: optimize release plan workflow snapshots
huanghongbo-hhb Jun 15, 2026
97126c0
fix: normalize release plan rich text diff
huanghongbo-hhb Jun 15, 2026
746117b
fix: isolate release plan workflow snapshot cache
huanghongbo-hhb Jun 23, 2026
408c443
fix: avoid no-op release plan collaboration updates
huanghongbo-hhb Jun 25, 2026
f99f5eb
fix: include release jobs in initial release plan diff
huanghongbo-hhb Jun 25, 2026
c8d136c
fix: skip empty initial release plan diffs
huanghongbo-hhb Jun 25, 2026
4a46128
fix: treat empty release job rich text as unchanged
huanghongbo-hhb Jun 25, 2026
698c3d1
fix: retain initial release job diffs
huanghongbo-hhb Jun 25, 2026
030cc2a
fix: address release plan review findings
huanghongbo-hhb Jul 24, 2026
c34dd06
refactor: simplify release plan diff helpers
huanghongbo-hhb Jul 24, 2026
a20ed93
refactor: address release plan review comments
huanghongbo-hhb Jul 24, 2026
3a76e30
fix: use explicit release plan transactions
huanghongbo-hhb Jul 24, 2026
72591c5
fix: retain release plan versions without diffs
huanghongbo-hhb Jul 24, 2026
30fb011
fix: finalize Mongo transaction handling
huanghongbo-hhb Jul 24, 2026
fb3cb6d
refactor: simplify release plan path joining
huanghongbo-hhb Jul 24, 2026
d856cea
fix: handle nil transaction return error
huanghongbo-hhb Jul 24, 2026
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
1 change: 1 addition & 0 deletions pkg/cli/initconfig/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func createOrUpdateMongodbIndex(ctx context.Context) {
commonrepo.NewLLMIntegrationColl(),
commonrepo.NewReleasePlanColl(),
commonrepo.NewReleasePlanLogColl(),
commonrepo.NewReleasePlanVersionColl(),
commonrepo.NewEnvServiceVersionColl(),
commonrepo.NewLabelColl(),
commonrepo.NewSprintTemplateColl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type ReleasePlan struct {
ID primitive.ObjectID `bson:"_id,omitempty" yaml:"-" json:"id"`
Index int64 `bson:"index" yaml:"index" json:"index"`
Version int64 `bson:"version" yaml:"version" json:"version"`
Name string `bson:"name" yaml:"name" json:"name"`
Manager string `bson:"manager" yaml:"manager" json:"manager"`
// ManagerID is the user id of the manager
Expand Down Expand Up @@ -120,19 +121,43 @@ type WorkflowReleaseJobSpec struct {
}

type ReleasePlanLog struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
PlanID string `bson:"plan_id" json:"plan_id"`
Username string `bson:"username" json:"username"`
Account string `bson:"account" json:"account"`
Verb string `bson:"verb" json:"verb"`
TargetName string `bson:"target_name" json:"target_name"`
TargetType string `bson:"target_type" json:"target_type"`
Before interface{} `bson:"before" json:"before"`
After interface{} `bson:"after" json:"after"`
Detail string `bson:"detail" json:"detail"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
PlanID string `bson:"plan_id" json:"plan_id"`
Username string `bson:"username" json:"username"`
Account string `bson:"account" json:"account"`
Verb string `bson:"verb" json:"verb"`
TargetName string `bson:"target_name" json:"target_name"`
TargetType string `bson:"target_type" json:"target_type"`
Before interface{} `bson:"before,omitempty" json:"before,omitempty"`
After interface{} `bson:"after,omitempty" json:"after,omitempty"`
Detail string `bson:"detail" json:"detail"`
Version int64 `bson:"version,omitempty" json:"version,omitempty"`
SectionKey string `bson:"section_key,omitempty" json:"section_key,omitempty"`
SectionName string `bson:"section_name,omitempty" json:"section_name,omitempty"`
SectionType string `bson:"section_type,omitempty" json:"section_type,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
}

func (ReleasePlanLog) TableName() string {
return "release_plan_log"
}

type ReleasePlanVersion struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
PlanID string `bson:"plan_id" json:"plan_id"`
Version int64 `bson:"version" json:"version"`
PreviousVersion int64 `bson:"previous_version,omitempty" json:"previous_version,omitempty"`
Operator string `bson:"operator" json:"operator"`
Account string `bson:"account" json:"account"`
SectionKey string `bson:"section_key,omitempty" json:"section_key,omitempty"`
SectionName string `bson:"section_name,omitempty" json:"section_name,omitempty"`
SectionType string `bson:"section_type,omitempty" json:"section_type,omitempty"`
Verb string `bson:"verb,omitempty" json:"verb,omitempty"`
BaseSnapshot interface{} `bson:"base_snapshot,omitempty" json:"base_snapshot,omitempty"`
Snapshot interface{} `bson:"snapshot" json:"snapshot"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
}

func (ReleasePlanVersion) TableName() string {
return "release_plan_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,34 @@ func (c *ReleasePlanColl) EnsureIndex(ctx context.Context) error {
Keys: bson.M{"update_time": 1},
Options: options.Index().SetUnique(false),
},
{
Keys: bson.M{"version": 1},
Options: options.Index().SetUnique(false),
},
Comment thread
huanghongbo-hhb marked this conversation as resolved.
Outdated
}

_, err := c.Indexes().CreateMany(ctx, mod, mongotool.CreateIndexOptions(ctx))
return err
}

func (c *ReleasePlanColl) Create(args *models.ReleasePlan) (string, error) {
return c.CreateWithCtx(context.Background(), args)
}

func (c *ReleasePlanColl) CreateWithCtx(ctx context.Context, args *models.ReleasePlan) (string, error) {
if args == nil {
return "", errors.New("nil ReleasePlan")
}

res, err := c.InsertOne(context.Background(), args)
return res.InsertedID.(primitive.ObjectID).Hex(), err
res, err := c.InsertOne(ctx, args)
if err != nil {
return "", err
}
id, ok := res.InsertedID.(primitive.ObjectID)
if !ok {
return "", errors.New("invalid ReleasePlan inserted id")
}
return id.Hex(), nil
}

func (c *ReleasePlanColl) GetByID(ctx context.Context, idString string) (*models.ReleasePlan, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ func (c *ReleasePlanLogColl) GetCollectionName() string {
}

func (c *ReleasePlanLogColl) EnsureIndex(ctx context.Context) error {
return nil
mod := []mongo.IndexModel{
{
Keys: bson.D{{Key: "plan_id", Value: 1}, {Key: "created_at", Value: -1}},
},
}

_, err := c.Indexes().CreateMany(ctx, mod, mongotool.CreateIndexOptions(ctx))
return err
}

func (c *ReleasePlanLogColl) Create(args *models.ReleasePlanLog) error {
Expand Down Expand Up @@ -76,7 +83,7 @@ func (c *ReleasePlanLogColl) ListByOptions(opt *ListReleasePlanLogOption) ([]*mo
ctx := context.Background()
opts := options.Find()
if opt.IsSort {
opts.SetSort(bson.D{{"create_time", -1}})
opts.SetSort(bson.D{{"created_at", -1}})
}
if opt.PlanID != "" {
query["plan_id"] = opt.PlanID
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright 2026 The KodeRover Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package mongodb

import (
"context"

"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

"github.com/koderover/zadig/v2/pkg/microservice/aslan/config"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models"
mongotool "github.com/koderover/zadig/v2/pkg/tool/mongo"
)

type ReleasePlanVersionColl struct {
*mongo.Collection

coll string
}

func NewReleasePlanVersionColl() *ReleasePlanVersionColl {
name := models.ReleasePlanVersion{}.TableName()
return &ReleasePlanVersionColl{
Collection: mongotool.Database(config.MongoDatabase()).Collection(name),
coll: name,
}
}

func (c *ReleasePlanVersionColl) GetCollectionName() string {
return c.coll
}

func (c *ReleasePlanVersionColl) EnsureIndex(ctx context.Context) error {
mod := []mongo.IndexModel{
{
Keys: bson.D{{Key: "plan_id", Value: 1}, {Key: "version", Value: 1}},
Options: options.Index().SetUnique(true),
},
{
Keys: bson.D{{Key: "plan_id", Value: 1}, {Key: "created_at", Value: -1}},
},
}

_, err := c.Indexes().CreateMany(ctx, mod, mongotool.CreateIndexOptions(ctx))
return err
}

func (c *ReleasePlanVersionColl) CreateWithCtx(ctx context.Context, args *models.ReleasePlanVersion) error {
if args == nil {
return errors.New("nil ReleasePlanVersion")
}

_, err := c.InsertOne(ctx, args)
return err
}

func (c *ReleasePlanVersionColl) UpsertWithCtx(ctx context.Context, args *models.ReleasePlanVersion) error {
if args == nil {
return errors.New("nil ReleasePlanVersion")
}

_, err := c.ReplaceOne(ctx, bson.M{
"plan_id": args.PlanID,
"version": args.Version,
}, args, options.Replace().SetUpsert(true))
return err
}

func (c *ReleasePlanVersionColl) DeleteWithCtx(ctx context.Context, planID string, version int64) error {
_, err := c.DeleteOne(ctx, bson.M{
"plan_id": planID,
"version": version,
})
return err
}

func (c *ReleasePlanVersionColl) Get(planID string, version int64) (*models.ReleasePlanVersion, error) {
resp := new(models.ReleasePlanVersion)
err := c.FindOne(context.Background(), bson.M{
"plan_id": planID,
"version": version,
}).Decode(resp)
return resp, err
}

func (c *ReleasePlanVersionColl) GetLatestBySectionsBefore(planID string, sectionKeys []string, beforeVersion int64) (*models.ReleasePlanVersion, error) {
resp := new(models.ReleasePlanVersion)
err := c.FindOne(context.Background(), bson.M{
"plan_id": planID,
"version": bson.M{"$lt": beforeVersion},
"section_key": bson.M{
"$in": sectionKeys,
},
}, options.FindOne().SetSort(bson.D{{Key: "version", Value: -1}})).Decode(resp)
return resp, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ func OpenAPIUpdateReleasePlanWithJobs(c *gin.Context) {
return
}

ctx.RespErr = service.OpenAPICreateReleasePlanWithJobs(ctx, c.Param("id"), opt)
ctx.RespErr = service.OpenAPIUpdateReleasePlanWithJobs(ctx, c.Param("id"), opt)
}
81 changes: 81 additions & 0 deletions pkg/microservice/aslan/core/release_plan/handler/release_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package handler

import (
"fmt"
"strconv"
"strings"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -78,6 +79,56 @@ func GetReleasePlanLogs(c *gin.Context) {
ctx.Resp, ctx.RespErr = service.GetReleasePlanLogs(c.Param("id"))
}

func GetReleasePlanCollaborationSnapshot(c *gin.Context) {
ctx, err := internalhandler.NewContextWithAuthorization(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()

if err != nil {
ctx.Logger.Errorf("failed to generate authorization info for user: %s, error: %s", ctx.UserID, err)
ctx.RespErr = fmt.Errorf("authorization Info Generation failed: err %s", err)
ctx.UnAuthorized = true
return
}

if !ctx.Resources.IsSystemAdmin && !ctx.Resources.SystemActions.ReleasePlan.View {
ctx.UnAuthorized = true
return
}

err = commonutil.CheckZadigEnterpriseLicense()
if err != nil {
ctx.RespErr = err
return
}

ctx.Resp, ctx.RespErr = service.GetReleasePlanCollaborationSnapshot(c.Param("id"))
}

func ReleasePlanCollaborationWS(c *gin.Context) {
ctx, err := internalhandler.NewContextWithAuthorization(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()

if err != nil {
ctx.Logger.Errorf("failed to generate authorization info for user: %s, error: %s", ctx.UserID, err)
ctx.RespErr = fmt.Errorf("authorization Info Generation failed: err %s", err)
ctx.UnAuthorized = true
return
}

if !ctx.Resources.IsSystemAdmin && !ctx.Resources.SystemActions.ReleasePlan.View {
ctx.UnAuthorized = true
return
}

err = commonutil.CheckZadigEnterpriseLicense()
if err != nil {
ctx.RespErr = err
return
}

ctx.RespErr = service.OpenReleasePlanCollaborationWS(c, ctx, c.Param("id"))
}

func CreateReleasePlan(c *gin.Context) {
ctx, err := internalhandler.NewContextWithAuthorization(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()
Expand Down Expand Up @@ -189,6 +240,36 @@ func UpdateReleasePlan(c *gin.Context) {
ctx.RespErr = service.UpdateReleasePlan(ctx, c.Param("id"), req)
}

func GetReleasePlanVersionDiff(c *gin.Context) {
ctx, err := internalhandler.NewContextWithAuthorization(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()

if err != nil {
ctx.RespErr = fmt.Errorf("authorization Info Generation failed: err %s", err)
ctx.UnAuthorized = true
return
}

if !ctx.Resources.IsSystemAdmin && !ctx.Resources.SystemActions.ReleasePlan.View {
ctx.UnAuthorized = true
return
}

err = commonutil.CheckZadigEnterpriseLicense()
if err != nil {
ctx.RespErr = err
return
}

version, err := strconv.ParseInt(c.Param("version"), 10, 64)
if err != nil {
ctx.RespErr = e.ErrInvalidParam.AddDesc(err.Error())
return
}

ctx.Resp, ctx.RespErr = service.GetReleasePlanVersionDiff(c.Param("id"), version)
}

func GetReleasePlanJobDetail(c *gin.Context) {
ctx, err := internalhandler.NewContextWithAuthorization(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()
Expand Down
3 changes: 3 additions & 0 deletions pkg/microservice/aslan/core/release_plan/handler/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func (*Router) Inject(router *gin.RouterGroup) {
v1.POST("/:id/copy", CopyReleasePlan)
v1.GET("/:id", GetReleasePlan)
v1.GET("/:id/logs", GetReleasePlanLogs)
v1.GET("/:id/collaboration/editors", GetReleasePlanCollaborationSnapshot)
v1.GET("/:id/collaboration/ws", ReleasePlanCollaborationWS)
v1.PUT("/:id", UpdateReleasePlan)
v1.GET("/:id/versions/:version/diff", GetReleasePlanVersionDiff)
v1.GET("/:id/job/:jobID", GetReleasePlanJobDetail)
v1.DELETE("/:id", DeleteReleasePlan)

Expand Down
Loading
Loading