Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e0d794b
feat: add release plan collaboration and versioned diffs
huanghongbo-hhb May 19, 2026
2a847f6
chore: remove release plan RFC from PR
huanghongbo-hhb May 19, 2026
c5a16fb
refactor: simplify release plan version semantics
huanghongbo-hhb May 20, 2026
b75af25
chore: extend release plan collaboration ttl
huanghongbo-hhb May 20, 2026
663a3cb
fix: align release plan approval logs in watcher
huanghongbo-hhb May 21, 2026
4d0791c
fix: harden release plan collaboration flows
huanghongbo-hhb May 21, 2026
19bec59
feat: support ordered release plan diffs
huanghongbo-hhb May 21, 2026
bd85d62
chore: remove diff tests from pr
huanghongbo-hhb May 21, 2026
7054f2e
refactor: simplify release plan diff labels
huanghongbo-hhb May 22, 2026
4b06d33
fix release plan collaboration cleanup and diff order
huanghongbo-hhb May 22, 2026
8954bab
fix: improve release plan target order labels
huanghongbo-hhb May 22, 2026
45473e7
fix: refine release plan version diff snapshots
huanghongbo-hhb May 28, 2026
07246b8
fix: polish release plan collaboration follow-ups
huanghongbo-hhb May 28, 2026
79465a5
fix: harden release plan collaboration lifecycle
huanghongbo-hhb Jun 9, 2026
be82dce
chore: remove release plan test files from pr
huanghongbo-hhb Jun 9, 2026
c508087
fix: preserve release plan initial diff baseline
huanghongbo-hhb Jun 9, 2026
ae69bbf
fix: align release plan workflow diff snapshot
huanghongbo-hhb Jun 10, 2026
83310b6
fix: enrich release plan workflow snapshot
huanghongbo-hhb Jun 10, 2026
d767bea
fix: log workflow snapshot recover events
huanghongbo-hhb Jun 10, 2026
4198b6a
fix: keep workflow skipped flag in release plan snapshot
huanghongbo-hhb Jun 10, 2026
874447f
fix: backfill incomplete workflow diff base snapshot
huanghongbo-hhb Jun 10, 2026
3e3d3a0
feat: expose approval snapshot diff display mode
huanghongbo-hhb Jun 10, 2026
f03ea48
fix: preserve rich text release plan diff values
huanghongbo-hhb Jun 10, 2026
9f6036e
fix: skip empty release plan logs
huanghongbo-hhb Jun 11, 2026
c4975b6
fix: cap diff depth and batch collab reads
huanghongbo-hhb Jun 11, 2026
d6d1468
refactor: align release plan metadata section keys
huanghongbo-hhb Jun 11, 2026
94a3045
fix: skip empty release plan snapshot changes
huanghongbo-hhb Jun 12, 2026
18e11d0
fix: ignore derived approval users in release plan logs
huanghongbo-hhb Jun 12, 2026
c604fdc
Merge remote-tracking branch 'upstream/main' into feat/release-plan-c…
huanghongbo-hhb Jun 12, 2026
b9523d8
fix: align restart workload fetch results
huanghongbo-hhb Jun 12, 2026
b793e70
fix: refine release plan metadata diff display
huanghongbo-hhb Jun 12, 2026
8b62bf1
fix: stabilize release plan workflow diff snapshots
huanghongbo-hhb Jun 12, 2026
bc3d2ab
fix: compat legacy release plan workflow lookup fields
huanghongbo-hhb Jun 12, 2026
4f80d04
fix: normalize legacy release plan workflow specs
huanghongbo-hhb Jun 12, 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,6 +79,10 @@ 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),
},
}

_, err := c.Indexes().CreateMany(ctx, mod, mongotool.CreateIndexOptions(ctx))
Expand Down Expand Up @@ -121,6 +125,35 @@ func (c *ReleasePlanColl) UpdateByID(ctx context.Context, idString string, args
return err
}

func (c *ReleasePlanColl) UpdateVersionByID(ctx context.Context, idString string, version int64) error {
id, err := primitive.ObjectIDFromHex(idString)
if err != nil {
return fmt.Errorf("invalid id")
}

query := bson.M{"_id": id}
change := bson.M{"$set": bson.M{"version": version}}
_, err = c.UpdateOne(ctx, query, change)
return err
}

func (c *ReleasePlanColl) IncrementVersionByID(ctx context.Context, idString string) (int64, error) {
id, err := primitive.ObjectIDFromHex(idString)
if err != nil {
return 0, fmt.Errorf("invalid id")
}

query := bson.M{"_id": id}
change := bson.M{"$inc": bson.M{"version": 1}}
opts := options.FindOneAndUpdate().SetReturnDocument(options.After)

result := new(models.ReleasePlan)
if err := c.FindOneAndUpdate(ctx, query, change, opts).Decode(result); err != nil {
return 0, err
}
return result.Version, nil
}

func (c *ReleasePlanColl) DeleteByID(ctx context.Context, idString string) error {
id, err := primitive.ObjectIDFromHex(idString)
if err != nil {
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,101 @@
/*
* 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) Create(args *models.ReleasePlanVersion) error {
if args == nil {
return errors.New("nil ReleasePlanVersion")
}

_, err := c.InsertOne(context.Background(), args)
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) GetLatest(planID string) (*models.ReleasePlanVersion, error) {
resp := new(models.ReleasePlanVersion)
err := c.FindOne(context.Background(), bson.M{
"plan_id": planID,
}, options.FindOne().SetSort(bson.D{{Key: "version", Value: -1}})).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 @@ -242,7 +242,7 @@ func (c *RestartJobCtl) restartHelmService(ctx context.Context, env *commonmodel
}

func restartWorkloadResources(ctx context.Context, clusterID string, resources []*kube.WorkloadResource, env *commonmodels.Product, kubeClient crClient.Client, clientSet *kubernetes.Clientset) (replaceResources []commonmodels.Resource, relatedPodLabels []map[string]string, err error) {
deployments, statefulSets, _, _, _, err := kube.FetchSelectedWorkloads(env.Namespace, resources, kubeClient, clientSet)
deployments, _, statefulSets, _, _, _, err := kube.FetchSelectedWorkloads(env.Namespace, resources, kubeClient, clientSet)
if err != nil {
return nil, nil, err
}
Expand Down
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 @@ -19,6 +19,7 @@ package handler
import (
"fmt"
"strings"
"strconv"

"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 GetReleasePlanCollaborationEditors(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.GetReleasePlanCollaborationEditors(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", GetReleasePlanCollaborationEditors)
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