Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update patch.go #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions pkg/v2/service/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ func (s *patchService) Do(ctx context.Context, req *PatchRequest) (resp *PatchRe
return
}

resource, err := s.database.Get(ctx, req.ResourceID, nil)
//resource, err := s.database.Get(ctx, req.ResourceID, nil)
ref, err := s.database.Get(ctx, req.ResourceID, nil)
if err != nil {
return
}

if s.config.ETag.Supported && req.MatchCriteria != nil {
if !req.MatchCriteria(resource) {
if !req.MatchCriteria(ref) {
//if !req.MatchCriteria(resource) {
err = fmt.Errorf("%w: resource does not meet pre condition", spec.ErrConflict)
return
}
Expand All @@ -98,7 +100,8 @@ func (s *patchService) Do(ctx context.Context, req *PatchRequest) (resp *PatchRe
// To save another database round trip, we use Clone to retain independent copy of the fetched resource.
// However, because the cloned instance share subscribers, it is better to work on the original instance.
// Hence, we assign reference to the clone, which will not be modified.
ref := resource.Clone()
resource := ref.Clone()
//ref := resource.Clone()

for _, f := range s.preFilters {
if err = f.FilterRef(ctx, resource, ref); err != nil {
Expand Down