aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/s3iam/s3iam_filer_store.go12
-rw-r--r--weed/s3iam/s3iam_filer_store_test.go9
2 files changed, 12 insertions, 9 deletions
diff --git a/weed/s3iam/s3iam_filer_store.go b/weed/s3iam/s3iam_filer_store.go
index 045681a99..4f84a0e54 100644
--- a/weed/s3iam/s3iam_filer_store.go
+++ b/weed/s3iam/s3iam_filer_store.go
@@ -33,7 +33,7 @@ func (ifs *IAMFilerStore) LoadIAMConfig(config *iam_pb.S3ApiConfiguration) error
if err != nil {
return err
}
- err = ifs.loadIAMConfigFromEntry(resp.Entry.Content, config)
+ err = ifs.loadIAMConfigFromEntry(resp.Entry, config)
if err != nil {
return err
}
@@ -53,7 +53,7 @@ func (ifs *IAMFilerStore) SaveIAMConfig(config *iam_pb.S3ApiConfiguration) error
},
Content: []byte{},
}
- err := ifs.saveIAMConfigToEntry(entry.Content, config)
+ err := ifs.saveIAMConfigToEntry(entry, config)
if err != nil {
return err
}
@@ -79,15 +79,15 @@ func (ifs *IAMFilerStore) SaveIAMConfig(config *iam_pb.S3ApiConfiguration) error
return nil
}
-func (ifs *IAMFilerStore) loadIAMConfigFromEntry(content []byte, config *iam_pb.S3ApiConfiguration) error {
- if err := proto.Unmarshal(content, config); err != nil {
+func (ifs *IAMFilerStore) loadIAMConfigFromEntry(entry *filer_pb.Entry, config *iam_pb.S3ApiConfiguration) error {
+ if err := proto.Unmarshal(entry.Content, config); err != nil {
return err
}
return nil
}
-func (ifs *IAMFilerStore) saveIAMConfigToEntry(content []byte, config *iam_pb.S3ApiConfiguration) error {
- content, err := proto.Marshal(config)
+func (ifs *IAMFilerStore) saveIAMConfigToEntry(entry *filer_pb.Entry, config *iam_pb.S3ApiConfiguration) (err error) {
+ entry.Content, err = proto.Marshal(config)
if err != nil {
return err
}
diff --git a/weed/s3iam/s3iam_filer_store_test.go b/weed/s3iam/s3iam_filer_store_test.go
index fca83ee92..6c595134e 100644
--- a/weed/s3iam/s3iam_filer_store_test.go
+++ b/weed/s3iam/s3iam_filer_store_test.go
@@ -3,6 +3,7 @@ package s3iam
import (
"testing"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
"github.com/stretchr/testify/assert"
@@ -50,10 +51,12 @@ func TestS3Conf(t *testing.T) {
},
},
}
- content := []byte{}
- _ = ifs.saveIAMConfigToEntry(content, s3Conf)
+ entry := filer_pb.Entry{}
+ err := ifs.saveIAMConfigToEntry(&entry, s3Conf)
+ assert.Equal(t, err, nil)
s3ConfSaved := &iam_pb.S3ApiConfiguration{}
- _ = ifs.loadIAMConfigFromEntry(content, s3ConfSaved)
+ err = ifs.loadIAMConfigFromEntry(&entry, s3ConfSaved)
+ assert.Equal(t, err, nil)
assert.Equal(t, "some_name", s3ConfSaved.Identities[0].Name)
assert.Equal(t, "some_read_only_user", s3ConfSaved.Identities[1].Name)