seaweedfs/weed/filer/s3iam_conf.go

27 lines
540 B
Go
Raw Permalink Normal View History

2020-12-07 07:16:20 +00:00
package filer
import (
"bytes"
"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
"github.com/golang/protobuf/jsonpb"
2021-07-09 10:19:21 +00:00
"github.com/golang/protobuf/proto"
2020-12-07 07:16:20 +00:00
"io"
)
func ParseS3ConfigurationFromBytes(content []byte, config *iam_pb.S3ApiConfiguration) error {
if err := jsonpb.Unmarshal(bytes.NewBuffer(content), config); err != nil {
return err
}
return nil
}
2021-07-09 10:19:21 +00:00
func ProtoToText(writer io.Writer, config proto.Message) error {
2020-12-07 07:16:20 +00:00
m := jsonpb.Marshaler{
EmitDefaults: false,
Indent: " ",
}
return m.Marshal(writer, config)
}