[#349] object: Make patcher apply patching for split header
All checks were successful
DCO / DCO (pull_request) Successful in 26s
Code generation / Generate proto (pull_request) Successful in 27s
Tests and linters / Tests (pull_request) Successful in 40s
Tests and linters / Lint (pull_request) Successful in 1m23s

* Change `PatchApplier` interface: `ApplyAttributesPatch` -> `ApplyHeaderPatch`.
  Make `ApplyHeaderPatch` receive `ApplyHeaderPatchPrm` as parameter;
* Fix `patcher`: apply patch for split header;
* Fix `patcher` unit-tests. Add test-case for split header;
* Extend `Patch` struct with `NewSplitHeader`;
* Change `ObjectPatcher` interface for client: `PatchAttributes` -> `PatchHeader`.
  Fix `objectPatcher`.
* Fix object transformer: since object header sets `SplitHeader` if it's passed.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2025-03-26 13:11:41 +03:00
parent 76265fe9be
commit 4d36a49d39
6 changed files with 259 additions and 20 deletions

View file

@ -18,6 +18,10 @@ type Patch struct {
// filled with NewAttributes. Otherwise, the attributes are just merged.
ReplaceAttributes bool
// A new split header which is set to object's header. If `nil`, then split header patching
// is ignored.
NewSplitHeader *SplitHeader
// Payload patch. If this field is not set, then it assumed such Patch patches only
// header (see NewAttributes, ReplaceAttributes).
PayloadPatch *PayloadPatch
@ -41,6 +45,8 @@ func (p *Patch) ToV2() *v2object.PatchRequestBody {
v2.SetNewAttributes(attrs)
v2.SetReplaceAttributes(p.ReplaceAttributes)
v2.SetNewSplitHeader(p.NewSplitHeader.ToV2())
v2.SetPatch(p.PayloadPatch.ToV2())
return v2
@ -63,6 +69,8 @@ func (p *Patch) FromV2(patch *v2object.PatchRequestBody) {
p.ReplaceAttributes = patch.GetReplaceAttributes()
p.NewSplitHeader = NewSplitHeaderFromV2(patch.GetNewSplitHeader())
if v2patch := patch.GetPatch(); v2patch != nil {
p.PayloadPatch = new(PayloadPatch)
p.PayloadPatch.FromV2(v2patch)