configuration stores the identity list

This commit is contained in:
Chris Lu 2020-02-17 12:31:59 -08:00
parent b4abe3c081
commit 4cdde5f569
4 changed files with 35 additions and 34 deletions

View file

@ -13,7 +13,7 @@ service SeaweedIdentityAccessManagement {
////////////////////////////////////////////////// //////////////////////////////////////////////////
message Identities { message S3ApiConfiguration {
repeated Identity identities = 1; repeated Identity identities = 1;
} }

View file

@ -35,16 +35,16 @@ var _ = math.Inf
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Identities struct { type S3ApiConfiguration struct {
Identities []*Identity `protobuf:"bytes,1,rep,name=identities" json:"identities,omitempty"` Identities []*Identity `protobuf:"bytes,1,rep,name=identities" json:"identities,omitempty"`
} }
func (m *Identities) Reset() { *m = Identities{} } func (m *S3ApiConfiguration) Reset() { *m = S3ApiConfiguration{} }
func (m *Identities) String() string { return proto.CompactTextString(m) } func (m *S3ApiConfiguration) String() string { return proto.CompactTextString(m) }
func (*Identities) ProtoMessage() {} func (*S3ApiConfiguration) ProtoMessage() {}
func (*Identities) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*S3ApiConfiguration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Identities) GetIdentities() []*Identity { func (m *S3ApiConfiguration) GetIdentities() []*Identity {
if m != nil { if m != nil {
return m.Identities return m.Identities
} }
@ -108,7 +108,7 @@ func (m *Credential) GetSecretKey() string {
} }
func init() { func init() {
proto.RegisterType((*Identities)(nil), "iam_pb.Identities") proto.RegisterType((*S3ApiConfiguration)(nil), "iam_pb.Identities")
proto.RegisterType((*Identity)(nil), "iam_pb.Identity") proto.RegisterType((*Identity)(nil), "iam_pb.Identity")
proto.RegisterType((*Credential)(nil), "iam_pb.Credential") proto.RegisterType((*Credential)(nil), "iam_pb.Credential")
} }
@ -154,20 +154,21 @@ var _SeaweedIdentityAccessManagement_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("iam.proto", fileDescriptor0) } func init() { proto.RegisterFile("iam.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 238 bytes of a gzipped FileDescriptorProto // 250 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x4c, 0x90, 0x41, 0x4b, 0xc3, 0x40,
0x10, 0x86, 0x49, 0x23, 0xb5, 0x99, 0x5e, 0xca, 0x9c, 0xf6, 0xa0, 0x18, 0x73, 0xca, 0x29, 0x48, 0x10, 0x85, 0x69, 0x23, 0xb5, 0x99, 0x5e, 0xca, 0x9c, 0xf6, 0xa0, 0x18, 0x73, 0xca, 0x29, 0x48,
0xf5, 0x2c, 0xa8, 0xa7, 0x5a, 0x04, 0x89, 0x0f, 0x50, 0xa6, 0xdb, 0x51, 0x16, 0xbb, 0x9b, 0x92, 0xeb, 0x1f, 0xa8, 0x05, 0xa1, 0x16, 0x41, 0xd2, 0x1f, 0x50, 0xa6, 0xdb, 0x69, 0x19, 0xec, 0x6e,
0x59, 0x90, 0xbc, 0xbd, 0x64, 0xb7, 0xdb, 0xf6, 0xb6, 0xf3, 0x7f, 0xdf, 0xcc, 0x32, 0x03, 0x85, 0x42, 0x76, 0x45, 0xf2, 0xef, 0x25, 0xbb, 0x46, 0x7b, 0xdb, 0x7d, 0xdf, 0x7b, 0xb3, 0x3b, 0x0f,
0x21, 0xdb, 0x1c, 0xfa, 0xce, 0x77, 0x38, 0x35, 0x64, 0x37, 0x87, 0x6d, 0xf5, 0x0c, 0xb0, 0xda, 0x52, 0x21, 0x53, 0x36, 0x6d, 0xed, 0x6b, 0x9c, 0x08, 0x99, 0x7d, 0x73, 0xc8, 0x5f, 0x01, 0x77,
0xb1, 0x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x00, 0x69, 0xcd, 0xce, 0xed, 0x3f,
0xc0, 0x93, 0x88, 0x63, 0xb2, 0xe6, 0x61, 0x79, 0x0f, 0x77, 0x5f, 0x4c, 0x7f, 0xcc, 0xbb, 0xb4, 0xb9, 0xfb, 0x7d, 0x37, 0x8d, 0xca, 0x96, 0xbb, 0x1e, 0x3b, 0xd6, 0x2d, 0xfb, 0x80, 0xc7, 0x11,
0xc2, 0x4b, 0x68, 0xfd, 0x20, 0x47, 0x3f, 0x6c, 0xd9, 0xf9, 0xd7, 0x1b, 0x58, 0x48, 0x54, 0xbe, 0x47, 0x65, 0xcb, 0xdd, 0xe2, 0x11, 0x1e, 0x76, 0x4c, 0xdf, 0xcc, 0xc7, 0x61, 0x85, 0x55, 0x88,
0xa5, 0xd1, 0x7b, 0x33, 0x66, 0xb3, 0x15, 0xd9, 0xcf, 0xf1, 0x88, 0xdb, 0x69, 0xb8, 0xe5, 0xe3, 0xbe, 0x93, 0xa5, 0x33, 0x1b, 0xb6, 0xfe, 0xe5, 0x0e, 0xe6, 0x2e, 0x5a, 0x4e, 0xae, 0xd4, 0x17,
0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x65, 0xb9, 0x71, 0x4e, 0x58, 0x01, 0x00, 0x00, 0xe9, 0xb5, 0xe9, 0x86, 0xcc, 0x47, 0x5f, 0xe6, 0x61, 0x12, 0x3a, 0x5d, 0xfe, 0x04, 0x00, 0x00,
0xff, 0xff, 0x83, 0x4f, 0x61, 0x03, 0x60, 0x01, 0x00, 0x00,
} }

View file

@ -47,15 +47,15 @@ func NewIdentityAccessManagement(fileName string, domain string) *IdentityAccess
if fileName == "" { if fileName == "" {
return iam 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) glog.Fatalf("fail to load config file %s: %v", fileName, err)
} }
return iam 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) rawData, readErr := ioutil.ReadFile(fileName)
if readErr != nil { if readErr != nil {
@ -64,12 +64,12 @@ func (iam *IdentityAccessManagement) loadIdentities(fileName string) error {
} }
glog.V(1).Infof("maybeLoadVolumeInfo Unmarshal volume info %v", fileName) 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) glog.Warningf("unmarshal error: %v", err)
return fmt.Errorf("unmarshal %s error: %v", fileName, err) return fmt.Errorf("unmarshal %s error: %v", fileName, err)
} }
for _, ident := range identities.Identities { for _, ident := range s3ApiConfiguration.Identities {
t := &Identity{ t := &Identity{
Name: ident.Name, Name: ident.Name,
Credentials: nil, Credentials: nil,

View file

@ -10,7 +10,7 @@ import (
func TestIdentityListFileFormat(t *testing.T) { func TestIdentityListFileFormat(t *testing.T) {
identities := &iam_pb.Identities{} s3ApiConfiguration := &iam_pb.S3ApiConfiguration{}
identity1 := &iam_pb.Identity{ identity1 := &iam_pb.Identity{
Name: "some_name", Name: "some_name",
@ -52,16 +52,16 @@ func TestIdentityListFileFormat(t *testing.T) {
}, },
} }
identities.Identities = append(identities.Identities, identity1) s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity1)
identities.Identities = append(identities.Identities, identity2) s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity2)
identities.Identities = append(identities.Identities, identity3) s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity3)
m := jsonpb.Marshaler{ m := jsonpb.Marshaler{
EmitDefaults: true, EmitDefaults: true,
Indent: " ", Indent: " ",
} }
text, _ := m.MarshalToString(identities) text, _ := m.MarshalToString(s3ApiConfiguration)
println(text) println(text)