[#349] object: Make patcher apply patching for split header
* 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:
parent
76265fe9be
commit
4d36a49d39
6 changed files with 259 additions and 20 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue