Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion apps/console/internal/domain/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (d *domain) UpdateEnvironment(ctx ConsoleContext, projectName string, env e
&env,
common.PatchOpts{
XPatch: repos.Document{
fc.EnvironmentSpec: env.Spec,
fc.EnvironmentSpecRouting: env.Spec.Routing,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): The modification in UpdateEnvironment to specifically update the EnvironmentSpecRouting field suggests a more targeted update approach. This is a significant change that requires thorough testing to ensure that only the Routing part of the EnvironmentSpec is affected by the patch. It would be beneficial to add tests that verify the patch operation's accuracy, ensuring no other parts of the EnvironmentSpec are inadvertently modified. Additionally, testing for potential error conditions related to this patch operation would enhance the robustness of the change.

},
},
)
Expand Down
24 changes: 10 additions & 14 deletions apps/container-registry/internal/domain/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package domain

import (
"context"

"github.com/kloudlite/api/apps/container-registry/internal/domain/entities"
fc "github.com/kloudlite/api/apps/container-registry/internal/domain/entities/field-constants"
iamT "github.com/kloudlite/api/apps/iam/types"
Expand Down Expand Up @@ -104,20 +105,15 @@ func (d *Impl) UpdateBuild(ctx RegistryContext, id repos.ID, build entities.Buil
if err := validateBuild(build); err != nil {
return nil, errors.NewE(err)
}
return d.buildRepo.UpdateById(ctx, id, &entities.Build{
Spec: func() dbv1.BuildRunSpec {
build.Spec.AccountName = ctx.AccountName
return build.Spec
}(),
Name: build.Name,
BuildClusterName: build.BuildClusterName,
CreatedBy: common.CreatedOrUpdatedBy{},
LastUpdatedBy: common.CreatedOrUpdatedBy{UserId: ctx.UserId, UserName: ctx.UserName, UserEmail: ctx.UserEmail},
Source: build.Source,
CredUser: common.CreatedOrUpdatedBy{UserId: ctx.UserId, UserName: ctx.UserName, UserEmail: ctx.UserEmail},
ErrorMessages: map[string]string{},
Status: build.Status,
})

patchDoc := repos.Document{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (llm): I noticed the transition from a full update to a patch operation in the UpdateBuild method. While this is likely an improvement in efficiency, it's crucial to ensure that the tests reflect this change. Specifically, tests should verify that only the intended fields are updated and that no unintended side effects occur due to the patch operation. Could you please confirm if the existing tests have been updated or if new tests have been added to cover this change?

fc.BuildName: build.Name,
fc.BuildBuildClusterName: build.BuildClusterName,
fields.LastUpdatedBy: common.CreatedOrUpdatedBy{UserId: ctx.UserId, UserName: ctx.UserName, UserEmail: ctx.UserEmail},
fc.BuildSource: build.Source,
}

return d.buildRepo.Patch(ctx, repos.Filter{fields.Id: id}, patchDoc)
}

func (d *Impl) UpdateBuildInternal(ctx context.Context, build *entities.Build) (*entities.Build, error) {
Expand Down
13 changes: 12 additions & 1 deletion apps/container-registry/internal/domain/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package domain

import (
"context"

"github.com/kloudlite/api/pkg/repos"
)

Expand All @@ -13,6 +14,16 @@ type RegistryContext struct {
UserEmail string
}

func (c *RegistryContext) GetAccountName() string {
func (c RegistryContext) GetAccountName() string {
return c.AccountName
}

func (c RegistryContext) GetUserId() repos.ID {
return c.UserId
}
func (c RegistryContext) GetUserEmail() string {
return c.UserEmail
}
func (c RegistryContext) GetUserName() string {
return c.UserName
}