configuration stores the identity list
This commit is contained in:
@@ -47,15 +47,15 @@ func NewIdentityAccessManagement(fileName string, domain string) *IdentityAccess
|
||||
if fileName == "" {
|
||||
return iam
|
||||
}
|
||||
if err := iam.loadIdentities(fileName); err != nil {
|
||||
if err := iam.loadS3ApiConfiguration(fileName); err != nil {
|
||||
glog.Fatalf("fail to load config file %s: %v", fileName, err)
|
||||
}
|
||||
return iam
|
||||
}
|
||||
|
||||
func (iam *IdentityAccessManagement) loadIdentities(fileName string) error {
|
||||
func (iam *IdentityAccessManagement) loadS3ApiConfiguration(fileName string) error {
|
||||
|
||||
identities := &iam_pb.Identities{}
|
||||
s3ApiConfiguration := &iam_pb.S3ApiConfiguration{}
|
||||
|
||||
rawData, readErr := ioutil.ReadFile(fileName)
|
||||
if readErr != nil {
|
||||
@@ -64,12 +64,12 @@ func (iam *IdentityAccessManagement) loadIdentities(fileName string) error {
|
||||
}
|
||||
|
||||
glog.V(1).Infof("maybeLoadVolumeInfo Unmarshal volume info %v", fileName)
|
||||
if err := jsonpb.Unmarshal(bytes.NewReader(rawData), identities); err != nil {
|
||||
if err := jsonpb.Unmarshal(bytes.NewReader(rawData), s3ApiConfiguration); err != nil {
|
||||
glog.Warningf("unmarshal error: %v", err)
|
||||
return fmt.Errorf("unmarshal %s error: %v", fileName, err)
|
||||
}
|
||||
|
||||
for _, ident := range identities.Identities {
|
||||
for _, ident := range s3ApiConfiguration.Identities {
|
||||
t := &Identity{
|
||||
Name: ident.Name,
|
||||
Credentials: nil,
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestIdentityListFileFormat(t *testing.T) {
|
||||
|
||||
identities := &iam_pb.Identities{}
|
||||
s3ApiConfiguration := &iam_pb.S3ApiConfiguration{}
|
||||
|
||||
identity1 := &iam_pb.Identity{
|
||||
Name: "some_name",
|
||||
@@ -52,16 +52,16 @@ func TestIdentityListFileFormat(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
identities.Identities = append(identities.Identities, identity1)
|
||||
identities.Identities = append(identities.Identities, identity2)
|
||||
identities.Identities = append(identities.Identities, identity3)
|
||||
s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity1)
|
||||
s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity2)
|
||||
s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity3)
|
||||
|
||||
m := jsonpb.Marshaler{
|
||||
EmitDefaults: true,
|
||||
Indent: " ",
|
||||
}
|
||||
|
||||
text, _ := m.MarshalToString(identities)
|
||||
text, _ := m.MarshalToString(s3ApiConfiguration)
|
||||
|
||||
println(text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user