read inside filer
This commit is contained in:
@@ -15,14 +15,18 @@ func (store *FilerEtcStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap
|
|||||||
s3cfg := &iam_pb.S3ApiConfiguration{}
|
s3cfg := &iam_pb.S3ApiConfiguration{}
|
||||||
|
|
||||||
err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
var buf bytes.Buffer
|
// Use ReadInsideFiler instead of ReadEntry since identity.json is small
|
||||||
if err := filer.ReadEntry(nil, client, filer.IamConfigDirectory, filer.IamIdentityFile, &buf); err != nil {
|
// and stored inline. ReadEntry requires a master client for chunked files,
|
||||||
|
// but ReadInsideFiler only reads inline content.
|
||||||
|
content, err := filer.ReadInsideFiler(client, filer.IamConfigDirectory, filer.IamIdentityFile)
|
||||||
|
if err != nil {
|
||||||
if err != filer_pb.ErrNotFound {
|
if err != filer_pb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if buf.Len() > 0 {
|
if len(content) > 0 {
|
||||||
return filer.ParseS3ConfigurationFromBytes(buf.Bytes(), s3cfg)
|
return filer.ParseS3ConfigurationFromBytes(content, s3cfg)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package filer_etc
|
package filer_etc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
@@ -29,8 +28,11 @@ func (store *FilerEtcStore) GetPolicies(ctx context.Context) (map[string]policy_
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
var buf bytes.Buffer
|
// Use ReadInsideFiler instead of ReadEntry since policies.json is small
|
||||||
if err := filer.ReadEntry(nil, client, filer.IamConfigDirectory, filer.IamPoliciesFile, &buf); err != nil {
|
// and stored inline. ReadEntry requires a master client for chunked files,
|
||||||
|
// but ReadInsideFiler only reads inline content.
|
||||||
|
content, err := filer.ReadInsideFiler(client, filer.IamConfigDirectory, filer.IamPoliciesFile)
|
||||||
|
if err != nil {
|
||||||
if err == filer_pb.ErrNotFound {
|
if err == filer_pb.ErrNotFound {
|
||||||
glog.V(1).Infof("Policies file not found at %s/%s, returning empty policies", filer.IamConfigDirectory, filer.IamPoliciesFile)
|
glog.V(1).Infof("Policies file not found at %s/%s, returning empty policies", filer.IamConfigDirectory, filer.IamPoliciesFile)
|
||||||
// If file doesn't exist, return empty collection
|
// If file doesn't exist, return empty collection
|
||||||
@@ -39,8 +41,8 @@ func (store *FilerEtcStore) GetPolicies(ctx context.Context) (map[string]policy_
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.Len() > 0 {
|
if len(content) > 0 {
|
||||||
return json.Unmarshal(buf.Bytes(), policiesCollection)
|
return json.Unmarshal(content, policiesCollection)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user