mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring
This commit is contained in:
parent
9acda432fe
commit
78f3ab439c
|
@ -33,7 +33,7 @@ func (ifs *IAMFilerStore) LoadIAMConfig(config *iam_pb.S3ApiConfiguration) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ifs.loadIAMConfigFromEntry(resp.Entry, config)
|
err = ifs.loadIAMConfigFromBytes(resp.Entry.Content, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@ func (ifs *IAMFilerStore) SaveIAMConfig(config *iam_pb.S3ApiConfiguration) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ifs *IAMFilerStore) loadIAMConfigFromEntry(entry *filer_pb.Entry, config *iam_pb.S3ApiConfiguration) error {
|
func (ifs *IAMFilerStore) loadIAMConfigFromBytes(content []byte, config *iam_pb.S3ApiConfiguration) error {
|
||||||
if err := proto.Unmarshal(entry.Content, config); err != nil {
|
if err := proto.Unmarshal(content, config); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package s3iam
|
package s3iam
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -51,11 +51,10 @@ func TestS3Conf(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
entry := filer_pb.Entry{}
|
content, _ := proto.Marshal(config)
|
||||||
err := ifs.saveIAMConfigToEntry(&entry, s3Conf)
|
|
||||||
assert.Equal(t, err, nil)
|
assert.Equal(t, err, nil)
|
||||||
s3ConfSaved := &iam_pb.S3ApiConfiguration{}
|
s3ConfSaved := &iam_pb.S3ApiConfiguration{}
|
||||||
err = ifs.loadIAMConfigFromEntry(&entry, s3ConfSaved)
|
err = ifs.loadIAMConfigFromBytes(content, s3ConfSaved)
|
||||||
assert.Equal(t, err, nil)
|
assert.Equal(t, err, nil)
|
||||||
|
|
||||||
assert.Equal(t, "some_name", s3ConfSaved.Identities[0].Name)
|
assert.Equal(t, "some_name", s3ConfSaved.Identities[0].Name)
|
||||||
|
|
Loading…
Reference in a new issue