From 4ddc222f469705f37742a973aa524f7bfd5c8874 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 9 Jul 2018 11:18:48 +0200 Subject: [PATCH] fix: Propagate bucket policy update in a distributed setup (#6135) Commit 0d521260237ca69a89044f23f10a13b44e1f53c9 caused a regression in setting a new bucket policy in a distributed setup. The reason is that gob is not able to encode fields declared as interfaces unless we provide GobEncode() and GobDecode() This PR adds them by using json marshaller and unmarshaller that are already implemented for Functions interface. --- pkg/policy/condition/func.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/policy/condition/func.go b/pkg/policy/condition/func.go index 2be59672f..01805cbf1 100644 --- a/pkg/policy/condition/func.go +++ b/pkg/policy/condition/func.go @@ -162,6 +162,16 @@ func (functions *Functions) UnmarshalJSON(data []byte) error { return nil } +// GobEncode - encodes Functions to gob data. +func (functions Functions) GobEncode() ([]byte, error) { + return functions.MarshalJSON() +} + +// GobDecode - decodes gob data to Functions. +func (functions *Functions) GobDecode(data []byte) error { + return functions.UnmarshalJSON(data) +} + // NewFunctions - returns new Functions with given function list. func NewFunctions(functions ...Function) Functions { return Functions(functions)