From f7b32afd64ee06595f46b2b0d208cd020d2bd662 Mon Sep 17 00:00:00 2001 From: knanao Date: Tue, 15 Mar 2022 16:02:38 +0900 Subject: [PATCH 1/3] Define RBAC resource model --- pkg/model/project.pb.go | 586 ++++++++++++++++++++++++----- pkg/model/project.pb.validate.go | 462 +++++++++++++++++++++++ pkg/model/project.proto | 52 +++ web/model/project_pb.d.ts | 92 +++++ web/model/project_pb.js | 612 ++++++++++++++++++++++++++++++- 5 files changed, 1720 insertions(+), 84 deletions(-) diff --git a/pkg/model/project.pb.go b/pkg/model/project.pb.go index b9f9492e86..c2bad4ef93 100644 --- a/pkg/model/project.pb.go +++ b/pkg/model/project.pb.go @@ -88,6 +88,125 @@ func (ProjectSSOConfig_Provider) EnumDescriptor() ([]byte, []int) { return file_pkg_model_project_proto_rawDescGZIP(), []int{2, 0} } +type ProjectRBACPolicy_ResourceType int32 + +const ( + ProjectRBACPolicy_APPLICATION ProjectRBACPolicy_ResourceType = 0 + ProjectRBACPolicy_DEPLOYMENT ProjectRBACPolicy_ResourceType = 1 + ProjectRBACPolicy_EVENT ProjectRBACPolicy_ResourceType = 2 + ProjectRBACPolicy_PIPED ProjectRBACPolicy_ResourceType = 3 + ProjectRBACPolicy_DEPLOYMENTCHAIN ProjectRBACPolicy_ResourceType = 4 + ProjectRBACPolicy_PROJECT ProjectRBACPolicy_ResourceType = 5 + ProjectRBACPolicy_APIKEY ProjectRBACPolicy_ResourceType = 6 + ProjectRBACPolicy_INSIGHT ProjectRBACPolicy_ResourceType = 7 +) + +// Enum value maps for ProjectRBACPolicy_ResourceType. +var ( + ProjectRBACPolicy_ResourceType_name = map[int32]string{ + 0: "APPLICATION", + 1: "DEPLOYMENT", + 2: "EVENT", + 3: "PIPED", + 4: "DEPLOYMENTCHAIN", + 5: "PROJECT", + 6: "APIKEY", + 7: "INSIGHT", + } + ProjectRBACPolicy_ResourceType_value = map[string]int32{ + "APPLICATION": 0, + "DEPLOYMENT": 1, + "EVENT": 2, + "PIPED": 3, + "DEPLOYMENTCHAIN": 4, + "PROJECT": 5, + "APIKEY": 6, + "INSIGHT": 7, + } +) + +func (x ProjectRBACPolicy_ResourceType) Enum() *ProjectRBACPolicy_ResourceType { + p := new(ProjectRBACPolicy_ResourceType) + *p = x + return p +} + +func (x ProjectRBACPolicy_ResourceType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ProjectRBACPolicy_ResourceType) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_model_project_proto_enumTypes[1].Descriptor() +} + +func (ProjectRBACPolicy_ResourceType) Type() protoreflect.EnumType { + return &file_pkg_model_project_proto_enumTypes[1] +} + +func (x ProjectRBACPolicy_ResourceType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ProjectRBACPolicy_ResourceType.Descriptor instead. +func (ProjectRBACPolicy_ResourceType) EnumDescriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{6, 0} +} + +type ProjectRBACPolicy_ActionType int32 + +const ( + ProjectRBACPolicy_GET ProjectRBACPolicy_ActionType = 0 + ProjectRBACPolicy_LIST ProjectRBACPolicy_ActionType = 1 + ProjectRBACPolicy_CREATE ProjectRBACPolicy_ActionType = 2 + ProjectRBACPolicy_UPDATE ProjectRBACPolicy_ActionType = 3 + ProjectRBACPolicy_DELETE ProjectRBACPolicy_ActionType = 4 +) + +// Enum value maps for ProjectRBACPolicy_ActionType. +var ( + ProjectRBACPolicy_ActionType_name = map[int32]string{ + 0: "GET", + 1: "LIST", + 2: "CREATE", + 3: "UPDATE", + 4: "DELETE", + } + ProjectRBACPolicy_ActionType_value = map[string]int32{ + "GET": 0, + "LIST": 1, + "CREATE": 2, + "UPDATE": 3, + "DELETE": 4, + } +) + +func (x ProjectRBACPolicy_ActionType) Enum() *ProjectRBACPolicy_ActionType { + p := new(ProjectRBACPolicy_ActionType) + *p = x + return p +} + +func (x ProjectRBACPolicy_ActionType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ProjectRBACPolicy_ActionType) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_model_project_proto_enumTypes[2].Descriptor() +} + +func (ProjectRBACPolicy_ActionType) Type() protoreflect.EnumType { + return &file_pkg_model_project_proto_enumTypes[2] +} + +func (x ProjectRBACPolicy_ActionType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ProjectRBACPolicy_ActionType.Descriptor instead. +func (ProjectRBACPolicy_ActionType) EnumDescriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{6, 1} +} + // Project contains needed data for a PipeCD project. // Each project can have multiple pipeds, enviroments, applications. // And each project can be controlled by a group of admin users. @@ -116,6 +235,10 @@ type Project struct { // Enable this field will allow users not belonging // to any registered teams to log in with Viewer role. AllowStrayAsViewer bool `protobuf:"varint,8,opt,name=allow_stray_as_viewer,json=allowStrayAsViewer,proto3" json:"allow_stray_as_viewer,omitempty"` + // RBAC roles for this project. + RbacRoles []*ProjectRBACRole `protobuf:"bytes,9,rep,name=rbac_roles,json=rbacRoles,proto3" json:"rbac_roles,omitempty"` + // Teams for this project. + Teams []*ProjectTeam `protobuf:"bytes,10,rep,name=teams,proto3" json:"teams,omitempty"` // Unix time when the project is created. CreatedAt int64 `protobuf:"varint,14,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // Unix time of the last time when the project is updated. @@ -210,6 +333,20 @@ func (x *Project) GetAllowStrayAsViewer() bool { return false } +func (x *Project) GetRbacRoles() []*ProjectRBACRole { + if x != nil { + return x.RbacRoles + } + return nil +} + +func (x *Project) GetTeams() []*ProjectTeam { + if x != nil { + return x.Teams + } + return nil +} + func (x *Project) GetCreatedAt() int64 { if x != nil { return x.CreatedAt @@ -408,6 +545,197 @@ func (x *ProjectRBACConfig) GetViewer() string { return "" } +// ProjectTeam represents a team. +type ProjectTeam struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of team. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The name of rbac role. + RoleName string `protobuf:"bytes,2,opt,name=role_name,json=roleName,proto3" json:"role_name,omitempty"` +} + +func (x *ProjectTeam) Reset() { + *x = ProjectTeam{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_model_project_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProjectTeam) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProjectTeam) ProtoMessage() {} + +func (x *ProjectTeam) ProtoReflect() protoreflect.Message { + mi := &file_pkg_model_project_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProjectTeam.ProtoReflect.Descriptor instead. +func (*ProjectTeam) Descriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{4} +} + +func (x *ProjectTeam) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ProjectTeam) GetRoleName() string { + if x != nil { + return x.RoleName + } + return "" +} + +// ProjectRBACRole represents a RBAC role. +type ProjectRBACRole struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of role. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The policy of role. + Policy []*ProjectRBACPolicy `protobuf:"bytes,2,rep,name=policy,proto3" json:"policy,omitempty"` +} + +func (x *ProjectRBACRole) Reset() { + *x = ProjectRBACRole{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_model_project_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProjectRBACRole) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProjectRBACRole) ProtoMessage() {} + +func (x *ProjectRBACRole) ProtoReflect() protoreflect.Message { + mi := &file_pkg_model_project_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProjectRBACRole.ProtoReflect.Descriptor instead. +func (*ProjectRBACRole) Descriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{5} +} + +func (x *ProjectRBACRole) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ProjectRBACRole) GetPolicy() []*ProjectRBACPolicy { + if x != nil { + return x.Policy + } + return nil +} + +type ProjectRBACPolicy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The type of resource. + ResourceType ProjectRBACPolicy_ResourceType `protobuf:"varint,1,opt,name=resource_type,json=resourceType,proto3,enum=model.ProjectRBACPolicy_ResourceType" json:"resource_type,omitempty"` + // The type of action. + ActionType ProjectRBACPolicy_ActionType `protobuf:"varint,2,opt,name=action_type,json=actionType,proto3,enum=model.ProjectRBACPolicy_ActionType" json:"action_type,omitempty"` + // The key of resource label. + LabelKey string `protobuf:"bytes,3,opt,name=label_key,json=labelKey,proto3" json:"label_key,omitempty"` + // The value of resource label. + LabelValue string `protobuf:"bytes,4,opt,name=label_value,json=labelValue,proto3" json:"label_value,omitempty"` +} + +func (x *ProjectRBACPolicy) Reset() { + *x = ProjectRBACPolicy{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_model_project_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProjectRBACPolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProjectRBACPolicy) ProtoMessage() {} + +func (x *ProjectRBACPolicy) ProtoReflect() protoreflect.Message { + mi := &file_pkg_model_project_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProjectRBACPolicy.ProtoReflect.Descriptor instead. +func (*ProjectRBACPolicy) Descriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{6} +} + +func (x *ProjectRBACPolicy) GetResourceType() ProjectRBACPolicy_ResourceType { + if x != nil { + return x.ResourceType + } + return ProjectRBACPolicy_APPLICATION +} + +func (x *ProjectRBACPolicy) GetActionType() ProjectRBACPolicy_ActionType { + if x != nil { + return x.ActionType + } + return ProjectRBACPolicy_GET +} + +func (x *ProjectRBACPolicy) GetLabelKey() string { + if x != nil { + return x.LabelKey + } + return "" +} + +func (x *ProjectRBACPolicy) GetLabelValue() string { + if x != nil { + return x.LabelValue + } + return "" +} + type ProjectSSOConfig_GitHub struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -428,7 +756,7 @@ type ProjectSSOConfig_GitHub struct { func (x *ProjectSSOConfig_GitHub) Reset() { *x = ProjectSSOConfig_GitHub{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_model_project_proto_msgTypes[4] + mi := &file_pkg_model_project_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -441,7 +769,7 @@ func (x *ProjectSSOConfig_GitHub) String() string { func (*ProjectSSOConfig_GitHub) ProtoMessage() {} func (x *ProjectSSOConfig_GitHub) ProtoReflect() protoreflect.Message { - mi := &file_pkg_model_project_proto_msgTypes[4] + mi := &file_pkg_model_project_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -506,7 +834,7 @@ type ProjectSSOConfig_Google struct { func (x *ProjectSSOConfig_Google) Reset() { *x = ProjectSSOConfig_Google{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_model_project_proto_msgTypes[5] + mi := &file_pkg_model_project_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -519,7 +847,7 @@ func (x *ProjectSSOConfig_Google) String() string { func (*ProjectSSOConfig_Google) ProtoMessage() {} func (x *ProjectSSOConfig_Google) ProtoReflect() protoreflect.Message { - mi := &file_pkg_model_project_proto_msgTypes[5] + mi := &file_pkg_model_project_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -555,7 +883,7 @@ var file_pkg_model_project_proto_rawDesc = []byte{ 0x0a, 0x17, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb5, 0x03, 0x0a, 0x07, 0x50, 0x72, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x04, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, @@ -578,61 +906,107 @@ var file_pkg_model_project_proto_rawDesc = []byte{ 0x0a, 0x15, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x61, 0x73, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x53, 0x74, 0x72, 0x61, 0x79, 0x41, 0x73, 0x56, 0x69, 0x65, 0x77, 0x65, - 0x72, 0x12, 0x26, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, - 0x0e, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x09, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x22, 0x66, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, 0x74, - 0x69, 0x63, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, - 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x0d, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x06, 0x52, 0x0c, 0x70, 0x61, 0x73, - 0x73, 0x77, 0x6f, 0x72, 0x64, 0x48, 0x61, 0x73, 0x68, 0x22, 0x9d, 0x04, 0x0a, 0x10, 0x50, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x46, - 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x20, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x36, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x47, 0x69, 0x74, 0x48, 0x75, 0x62, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x12, 0x36, - 0x0a, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, - 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x53, - 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x52, 0x06, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x1a, 0xb3, 0x01, 0x0a, 0x06, 0x47, 0x69, 0x74, 0x48, 0x75, - 0x62, 0x12, 0x24, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x75, 0x72, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x61, 0x73, 0x65, 0x55, 0x72, 0x6c, - 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x12, - 0x1b, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x72, 0x6c, 0x1a, 0x5c, 0x0a, 0x06, - 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, - 0x10, 0x01, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0d, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x3d, 0x0a, 0x08, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, - 0x10, 0x00, 0x12, 0x19, 0x0a, 0x11, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x5f, 0x45, 0x4e, 0x54, - 0x45, 0x52, 0x50, 0x52, 0x49, 0x53, 0x45, 0x10, 0x01, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x0a, 0x0a, - 0x06, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x10, 0x02, 0x22, 0x62, 0x0a, 0x11, 0x50, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1d, - 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x16, 0x0a, - 0x06, 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, - 0x64, 0x69, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x42, 0x25, 0x5a, - 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x65, - 0x2d, 0x63, 0x64, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x63, 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6d, - 0x6f, 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x12, 0x35, 0x0a, 0x0a, 0x72, 0x62, 0x61, 0x63, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x09, 0x72, + 0x62, 0x61, 0x63, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, + 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, + 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x74, 0x65, 0x61, + 0x6d, 0x73, 0x12, 0x26, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, + 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, + 0x41, 0x74, 0x22, 0x66, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x69, 0x63, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, + 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x0d, + 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x06, 0x52, 0x0c, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x48, 0x61, 0x73, 0x68, 0x22, 0x9d, 0x04, 0x0a, 0x10, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x46, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x20, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x36, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, + 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x47, 0x69, 0x74, 0x48, 0x75, 0x62, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x12, + 0x36, 0x0a, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1e, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, + 0x53, 0x4f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x52, + 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x1a, 0xb3, 0x01, 0x0a, 0x06, 0x47, 0x69, 0x74, 0x48, + 0x75, 0x62, 0x12, 0x24, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x75, + 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x61, 0x73, 0x65, 0x55, 0x72, + 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, + 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x72, 0x6c, 0x1a, 0x5c, 0x0a, + 0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, + 0x02, 0x10, 0x01, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2c, 0x0a, + 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x3d, 0x0a, 0x08, 0x50, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55, + 0x42, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x11, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x5f, 0x45, 0x4e, + 0x54, 0x45, 0x52, 0x50, 0x52, 0x49, 0x53, 0x45, 0x10, 0x01, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x0a, + 0x0a, 0x06, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x10, 0x02, 0x22, 0x62, 0x0a, 0x11, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x1d, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, + 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x22, 0x50, + 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x1b, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x72, 0x6f, + 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, + 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, + 0x22, 0x60, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, + 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x30, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x22, 0xbf, 0x03, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, + 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x54, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x25, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, + 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4e, + 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, + 0x10, 0x01, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, + 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x80, 0x01, 0x0a, + 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, + 0x0b, 0x41, 0x50, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0e, + 0x0a, 0x0a, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x09, + 0x0a, 0x05, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x49, 0x50, + 0x45, 0x44, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, + 0x4e, 0x54, 0x43, 0x48, 0x41, 0x49, 0x4e, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, + 0x4a, 0x45, 0x43, 0x54, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x50, 0x49, 0x4b, 0x45, 0x59, + 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x49, 0x47, 0x48, 0x54, 0x10, 0x07, 0x22, + 0x43, 0x0a, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, + 0x03, 0x47, 0x45, 0x54, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, + 0x54, 0x45, 0x10, 0x04, 0x42, 0x25, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x2d, 0x63, 0x64, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x63, + 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -647,29 +1021,39 @@ func file_pkg_model_project_proto_rawDescGZIP() []byte { return file_pkg_model_project_proto_rawDescData } -var file_pkg_model_project_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_pkg_model_project_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pkg_model_project_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_pkg_model_project_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_pkg_model_project_proto_goTypes = []interface{}{ - (ProjectSSOConfig_Provider)(0), // 0: model.ProjectSSOConfig.Provider - (*Project)(nil), // 1: model.Project - (*ProjectStaticUser)(nil), // 2: model.ProjectStaticUser - (*ProjectSSOConfig)(nil), // 3: model.ProjectSSOConfig - (*ProjectRBACConfig)(nil), // 4: model.ProjectRBACConfig - (*ProjectSSOConfig_GitHub)(nil), // 5: model.ProjectSSOConfig.GitHub - (*ProjectSSOConfig_Google)(nil), // 6: model.ProjectSSOConfig.Google + (ProjectSSOConfig_Provider)(0), // 0: model.ProjectSSOConfig.Provider + (ProjectRBACPolicy_ResourceType)(0), // 1: model.ProjectRBACPolicy.ResourceType + (ProjectRBACPolicy_ActionType)(0), // 2: model.ProjectRBACPolicy.ActionType + (*Project)(nil), // 3: model.Project + (*ProjectStaticUser)(nil), // 4: model.ProjectStaticUser + (*ProjectSSOConfig)(nil), // 5: model.ProjectSSOConfig + (*ProjectRBACConfig)(nil), // 6: model.ProjectRBACConfig + (*ProjectTeam)(nil), // 7: model.ProjectTeam + (*ProjectRBACRole)(nil), // 8: model.ProjectRBACRole + (*ProjectRBACPolicy)(nil), // 9: model.ProjectRBACPolicy + (*ProjectSSOConfig_GitHub)(nil), // 10: model.ProjectSSOConfig.GitHub + (*ProjectSSOConfig_Google)(nil), // 11: model.ProjectSSOConfig.Google } var file_pkg_model_project_proto_depIdxs = []int32{ - 2, // 0: model.Project.static_admin:type_name -> model.ProjectStaticUser - 3, // 1: model.Project.sso:type_name -> model.ProjectSSOConfig - 4, // 2: model.Project.rbac:type_name -> model.ProjectRBACConfig - 0, // 3: model.ProjectSSOConfig.provider:type_name -> model.ProjectSSOConfig.Provider - 5, // 4: model.ProjectSSOConfig.github:type_name -> model.ProjectSSOConfig.GitHub - 6, // 5: model.ProjectSSOConfig.google:type_name -> model.ProjectSSOConfig.Google - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 4, // 0: model.Project.static_admin:type_name -> model.ProjectStaticUser + 5, // 1: model.Project.sso:type_name -> model.ProjectSSOConfig + 6, // 2: model.Project.rbac:type_name -> model.ProjectRBACConfig + 8, // 3: model.Project.rbac_roles:type_name -> model.ProjectRBACRole + 7, // 4: model.Project.teams:type_name -> model.ProjectTeam + 0, // 5: model.ProjectSSOConfig.provider:type_name -> model.ProjectSSOConfig.Provider + 10, // 6: model.ProjectSSOConfig.github:type_name -> model.ProjectSSOConfig.GitHub + 11, // 7: model.ProjectSSOConfig.google:type_name -> model.ProjectSSOConfig.Google + 9, // 8: model.ProjectRBACRole.policy:type_name -> model.ProjectRBACPolicy + 1, // 9: model.ProjectRBACPolicy.resource_type:type_name -> model.ProjectRBACPolicy.ResourceType + 2, // 10: model.ProjectRBACPolicy.action_type:type_name -> model.ProjectRBACPolicy.ActionType + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_pkg_model_project_proto_init() } @@ -727,7 +1111,7 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProjectSSOConfig_GitHub); i { + switch v := v.(*ProjectTeam); i { case 0: return &v.state case 1: @@ -739,6 +1123,42 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProjectRBACRole); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_model_project_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProjectRBACPolicy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_model_project_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProjectSSOConfig_GitHub); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_model_project_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProjectSSOConfig_Google); i { case 0: return &v.state @@ -756,8 +1176,8 @@ func file_pkg_model_project_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pkg_model_project_proto_rawDesc, - NumEnums: 1, - NumMessages: 6, + NumEnums: 3, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/model/project.pb.validate.go b/pkg/model/project.pb.validate.go index 59626c2c44..b187ea8f1e 100644 --- a/pkg/model/project.pb.validate.go +++ b/pkg/model/project.pb.validate.go @@ -173,6 +173,74 @@ func (m *Project) validate(all bool) error { // no validation rules for AllowStrayAsViewer + for idx, item := range m.GetRbacRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectValidationError{ + field: fmt.Sprintf("RbacRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectValidationError{ + field: fmt.Sprintf("RbacRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ProjectValidationError{ + field: fmt.Sprintf("RbacRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetTeams() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectValidationError{ + field: fmt.Sprintf("Teams[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectValidationError{ + field: fmt.Sprintf("Teams[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ProjectValidationError{ + field: fmt.Sprintf("Teams[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if m.GetCreatedAt() <= 0 { err := ProjectValidationError{ field: "CreatedAt", @@ -682,6 +750,400 @@ var _ interface { ErrorName() string } = ProjectRBACConfigValidationError{} +// Validate checks the field values on ProjectTeam with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *ProjectTeam) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProjectTeam with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ProjectTeamMultiError, or +// nil if none found. +func (m *ProjectTeam) ValidateAll() error { + return m.validate(true) +} + +func (m *ProjectTeam) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetName()) < 1 { + err := ProjectTeamValidationError{ + field: "Name", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetRoleName()) < 1 { + err := ProjectTeamValidationError{ + field: "RoleName", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return ProjectTeamMultiError(errors) + } + + return nil +} + +// ProjectTeamMultiError is an error wrapping multiple validation errors +// returned by ProjectTeam.ValidateAll() if the designated constraints aren't met. +type ProjectTeamMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectTeamMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectTeamMultiError) AllErrors() []error { return m } + +// ProjectTeamValidationError is the validation error returned by +// ProjectTeam.Validate if the designated constraints aren't met. +type ProjectTeamValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ProjectTeamValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ProjectTeamValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ProjectTeamValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ProjectTeamValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ProjectTeamValidationError) ErrorName() string { return "ProjectTeamValidationError" } + +// Error satisfies the builtin error interface +func (e ProjectTeamValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProjectTeam.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ProjectTeamValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ProjectTeamValidationError{} + +// Validate checks the field values on ProjectRBACRole with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ProjectRBACRole) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProjectRBACRole with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProjectRBACRoleMultiError, or nil if none found. +func (m *ProjectRBACRole) ValidateAll() error { + return m.validate(true) +} + +func (m *ProjectRBACRole) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetName()) < 1 { + err := ProjectRBACRoleValidationError{ + field: "Name", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetPolicy() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectRBACRoleValidationError{ + field: fmt.Sprintf("Policy[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectRBACRoleValidationError{ + field: fmt.Sprintf("Policy[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ProjectRBACRoleValidationError{ + field: fmt.Sprintf("Policy[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ProjectRBACRoleMultiError(errors) + } + + return nil +} + +// ProjectRBACRoleMultiError is an error wrapping multiple validation errors +// returned by ProjectRBACRole.ValidateAll() if the designated constraints +// aren't met. +type ProjectRBACRoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectRBACRoleMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectRBACRoleMultiError) AllErrors() []error { return m } + +// ProjectRBACRoleValidationError is the validation error returned by +// ProjectRBACRole.Validate if the designated constraints aren't met. +type ProjectRBACRoleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ProjectRBACRoleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ProjectRBACRoleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ProjectRBACRoleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ProjectRBACRoleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ProjectRBACRoleValidationError) ErrorName() string { return "ProjectRBACRoleValidationError" } + +// Error satisfies the builtin error interface +func (e ProjectRBACRoleValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProjectRBACRole.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ProjectRBACRoleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ProjectRBACRoleValidationError{} + +// Validate checks the field values on ProjectRBACPolicy with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ProjectRBACPolicy) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProjectRBACPolicy with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProjectRBACPolicyMultiError, or nil if none found. +func (m *ProjectRBACPolicy) ValidateAll() error { + return m.validate(true) +} + +func (m *ProjectRBACPolicy) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if _, ok := ProjectRBACPolicy_ResourceType_name[int32(m.GetResourceType())]; !ok { + err := ProjectRBACPolicyValidationError{ + field: "ResourceType", + reason: "value must be one of the defined enum values", + } + if !all { + return err + } + errors = append(errors, err) + } + + if _, ok := ProjectRBACPolicy_ActionType_name[int32(m.GetActionType())]; !ok { + err := ProjectRBACPolicyValidationError{ + field: "ActionType", + reason: "value must be one of the defined enum values", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for LabelKey + + // no validation rules for LabelValue + + if len(errors) > 0 { + return ProjectRBACPolicyMultiError(errors) + } + + return nil +} + +// ProjectRBACPolicyMultiError is an error wrapping multiple validation errors +// returned by ProjectRBACPolicy.ValidateAll() if the designated constraints +// aren't met. +type ProjectRBACPolicyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectRBACPolicyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectRBACPolicyMultiError) AllErrors() []error { return m } + +// ProjectRBACPolicyValidationError is the validation error returned by +// ProjectRBACPolicy.Validate if the designated constraints aren't met. +type ProjectRBACPolicyValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ProjectRBACPolicyValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ProjectRBACPolicyValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ProjectRBACPolicyValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ProjectRBACPolicyValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ProjectRBACPolicyValidationError) ErrorName() string { + return "ProjectRBACPolicyValidationError" +} + +// Error satisfies the builtin error interface +func (e ProjectRBACPolicyValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProjectRBACPolicy.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ProjectRBACPolicyValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ProjectRBACPolicyValidationError{} + // Validate checks the field values on ProjectSSOConfig_GitHub with the rules // defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. diff --git a/pkg/model/project.proto b/pkg/model/project.proto index 803b56b4c8..0620559599 100644 --- a/pkg/model/project.proto +++ b/pkg/model/project.proto @@ -46,6 +46,12 @@ message Project { // to any registered teams to log in with Viewer role. bool allow_stray_as_viewer = 8; + // RBAC roles for this project. + repeated ProjectRBACRole rbac_roles = 9; + + // Teams for this project. + repeated ProjectTeam teams = 10; + // Unix time when the project is created. int64 created_at = 14 [(validate.rules).int64.gt = 0]; // Unix time of the last time when the project is updated. @@ -99,3 +105,49 @@ message ProjectRBACConfig { string editor = 2; string viewer = 3; } + +// ProjectTeam represents a team. +message ProjectTeam { + // The name of team. + string name = 1 [(validate.rules).string.min_len = 1]; + // The name of rbac role. + string role_name = 2 [(validate.rules).string.min_len = 1]; +} + +// ProjectRBACRole represents a RBAC role. +message ProjectRBACRole { + // The name of role. + string name = 1 [(validate.rules).string.min_len = 1]; + // The policy of role. + repeated ProjectRBACPolicy policy = 2; +} + +message ProjectRBACPolicy { + enum ResourceType { + APPLICATION = 0; + DEPLOYMENT = 1; + EVENT = 2; + PIPED = 3; + DEPLOYMENTCHAIN = 4; + PROJECT = 5; + APIKEY = 6; + INSIGHT = 7; + } + + enum ActionType { + GET = 0; + LIST = 1; + CREATE = 2; + UPDATE = 3; + DELETE = 4; + } + + // The type of resource. + ResourceType resource_type = 1 [(validate.rules).enum.defined_only = true]; + // The type of action. + ActionType action_type = 2 [(validate.rules).enum.defined_only = true]; + // The key of resource label. + string label_key = 3; + // The value of resource label. + string label_value = 4; +} diff --git a/web/model/project_pb.d.ts b/web/model/project_pb.d.ts index 4ed71659fa..9e4b0eb6a7 100644 --- a/web/model/project_pb.d.ts +++ b/web/model/project_pb.d.ts @@ -34,6 +34,11 @@ export class Project extends jspb.Message { getAllowStrayAsViewer(): boolean; setAllowStrayAsViewer(value: boolean): Project; + getRbacRolesList(): Array; + setRbacRolesList(value: Array): Project; + clearRbacRolesList(): Project; + addRbacRoles(value?: ProjectRBACRole, index?: number): ProjectRBACRole; + getCreatedAt(): number; setCreatedAt(value: number): Project; @@ -58,6 +63,7 @@ export namespace Project { rbac?: ProjectRBACConfig.AsObject, sharedSsoName: string, allowStrayAsViewer: boolean, + rbacRolesList: Array, createdAt: number, updatedAt: number, } @@ -205,3 +211,89 @@ export namespace ProjectRBACConfig { } } +export class ProjectRBACRole extends jspb.Message { + getName(): string; + setName(value: string): ProjectRBACRole; + + getType(): ProjectRBACRole.RoleType; + setType(value: ProjectRBACRole.RoleType): ProjectRBACRole; + + getSubject(): string; + setSubject(value: string): ProjectRBACRole; + + getPolicyList(): Array; + setPolicyList(value: Array): ProjectRBACRole; + clearPolicyList(): ProjectRBACRole; + addPolicy(value?: ProjectRBACPolicy, index?: number): ProjectRBACPolicy; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProjectRBACRole.AsObject; + static toObject(includeInstance: boolean, msg: ProjectRBACRole): ProjectRBACRole.AsObject; + static serializeBinaryToWriter(message: ProjectRBACRole, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectRBACRole; + static deserializeBinaryFromReader(message: ProjectRBACRole, reader: jspb.BinaryReader): ProjectRBACRole; +} + +export namespace ProjectRBACRole { + export type AsObject = { + name: string, + type: ProjectRBACRole.RoleType, + subject: string, + policyList: Array, + } + + export enum RoleType { + GITHUB_TEAM = 0, + GOOGLE_GROUP = 1, + } +} + +export class ProjectRBACPolicy extends jspb.Message { + getResourceType(): ProjectRBACPolicy.ResourceType; + setResourceType(value: ProjectRBACPolicy.ResourceType): ProjectRBACPolicy; + + getActionType(): ProjectRBACPolicy.ActionType; + setActionType(value: ProjectRBACPolicy.ActionType): ProjectRBACPolicy; + + getLabelKey(): string; + setLabelKey(value: string): ProjectRBACPolicy; + + getLabelValue(): string; + setLabelValue(value: string): ProjectRBACPolicy; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProjectRBACPolicy.AsObject; + static toObject(includeInstance: boolean, msg: ProjectRBACPolicy): ProjectRBACPolicy.AsObject; + static serializeBinaryToWriter(message: ProjectRBACPolicy, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectRBACPolicy; + static deserializeBinaryFromReader(message: ProjectRBACPolicy, reader: jspb.BinaryReader): ProjectRBACPolicy; +} + +export namespace ProjectRBACPolicy { + export type AsObject = { + resourceType: ProjectRBACPolicy.ResourceType, + actionType: ProjectRBACPolicy.ActionType, + labelKey: string, + labelValue: string, + } + + export enum ResourceType { + APPLICATION = 0, + DEPLOYMENT = 1, + EVENT = 2, + PIPED = 3, + DEPLOYMENTCHAIN = 4, + PROJECT = 5, + ROLE = 6, + APIKEY = 7, + } + + export enum ActionType { + GET = 0, + LIST = 1, + CREATE = 2, + UPDATE = 3, + DELETE = 4, + } +} + diff --git a/web/model/project_pb.js b/web/model/project_pb.js index 9365cb71f6..0f650f5ff2 100644 --- a/web/model/project_pb.js +++ b/web/model/project_pb.js @@ -25,6 +25,11 @@ var global = (function() { goog.exportSymbol('proto.model.Project', null, global); goog.exportSymbol('proto.model.ProjectRBACConfig', null, global); +goog.exportSymbol('proto.model.ProjectRBACPolicy', null, global); +goog.exportSymbol('proto.model.ProjectRBACPolicy.ActionType', null, global); +goog.exportSymbol('proto.model.ProjectRBACPolicy.ResourceType', null, global); +goog.exportSymbol('proto.model.ProjectRBACRole', null, global); +goog.exportSymbol('proto.model.ProjectRBACRole.RoleType', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.GitHub', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.Google', null, global); @@ -41,7 +46,7 @@ goog.exportSymbol('proto.model.ProjectStaticUser', null, global); * @constructor */ proto.model.Project = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); + jspb.Message.initialize(this, opt_data, 0, -1, proto.model.Project.repeatedFields_, null); }; goog.inherits(proto.model.Project, jspb.Message); if (goog.DEBUG && !COMPILED) { @@ -156,6 +161,55 @@ if (goog.DEBUG && !COMPILED) { */ proto.model.ProjectRBACConfig.displayName = 'proto.model.ProjectRBACConfig'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.model.ProjectRBACRole = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.model.ProjectRBACRole.repeatedFields_, null); +}; +goog.inherits(proto.model.ProjectRBACRole, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.model.ProjectRBACRole.displayName = 'proto.model.ProjectRBACRole'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.model.ProjectRBACPolicy = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.model.ProjectRBACPolicy, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.model.ProjectRBACPolicy.displayName = 'proto.model.ProjectRBACPolicy'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.model.Project.repeatedFields_ = [9]; @@ -196,6 +250,8 @@ proto.model.Project.toObject = function(includeInstance, msg) { rbac: (f = msg.getRbac()) && proto.model.ProjectRBACConfig.toObject(includeInstance, f), sharedSsoName: jspb.Message.getFieldWithDefault(msg, 7, ""), allowStrayAsViewer: jspb.Message.getBooleanFieldWithDefault(msg, 8, false), + rbacRolesList: jspb.Message.toObjectList(msg.getRbacRolesList(), + proto.model.ProjectRBACRole.toObject, includeInstance), createdAt: jspb.Message.getFieldWithDefault(msg, 14, 0), updatedAt: jspb.Message.getFieldWithDefault(msg, 15, 0) }; @@ -269,6 +325,11 @@ proto.model.Project.deserializeBinaryFromReader = function(msg, reader) { var value = /** @type {boolean} */ (reader.readBool()); msg.setAllowStrayAsViewer(value); break; + case 9: + var value = new proto.model.ProjectRBACRole; + reader.readMessage(value,proto.model.ProjectRBACRole.deserializeBinaryFromReader); + msg.addRbacRoles(value); + break; case 14: var value = /** @type {number} */ (reader.readInt64()); msg.setCreatedAt(value); @@ -365,6 +426,14 @@ proto.model.Project.serializeBinaryToWriter = function(message, writer) { f ); } + f = message.getRbacRolesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 9, + f, + proto.model.ProjectRBACRole.serializeBinaryToWriter + ); + } f = message.getCreatedAt(); if (f !== 0) { writer.writeInt64( @@ -583,6 +652,44 @@ proto.model.Project.prototype.setAllowStrayAsViewer = function(value) { }; +/** + * repeated ProjectRBACRole rbac_roles = 9; + * @return {!Array} + */ +proto.model.Project.prototype.getRbacRolesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectRBACRole, 9)); +}; + + +/** + * @param {!Array} value + * @return {!proto.model.Project} returns this +*/ +proto.model.Project.prototype.setRbacRolesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 9, value); +}; + + +/** + * @param {!proto.model.ProjectRBACRole=} opt_value + * @param {number=} opt_index + * @return {!proto.model.ProjectRBACRole} + */ +proto.model.Project.prototype.addRbacRoles = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 9, opt_value, proto.model.ProjectRBACRole, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.model.Project} returns this + */ +proto.model.Project.prototype.clearRbacRolesList = function() { + return this.setRbacRolesList([]); +}; + + /** * optional int64 created_at = 14; * @return {number} @@ -1620,4 +1727,507 @@ proto.model.ProjectRBACConfig.prototype.setViewer = function(value) { }; + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.model.ProjectRBACRole.repeatedFields_ = [4]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.model.ProjectRBACRole.prototype.toObject = function(opt_includeInstance) { + return proto.model.ProjectRBACRole.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.model.ProjectRBACRole} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACRole.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + type: jspb.Message.getFieldWithDefault(msg, 2, 0), + subject: jspb.Message.getFieldWithDefault(msg, 3, ""), + policyList: jspb.Message.toObjectList(msg.getPolicyList(), + proto.model.ProjectRBACPolicy.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.model.ProjectRBACRole} + */ +proto.model.ProjectRBACRole.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.model.ProjectRBACRole; + return proto.model.ProjectRBACRole.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.model.ProjectRBACRole} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.model.ProjectRBACRole} + */ +proto.model.ProjectRBACRole.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 2: + var value = /** @type {!proto.model.ProjectRBACRole.RoleType} */ (reader.readEnum()); + msg.setType(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setSubject(value); + break; + case 4: + var value = new proto.model.ProjectRBACPolicy; + reader.readMessage(value,proto.model.ProjectRBACPolicy.deserializeBinaryFromReader); + msg.addPolicy(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.model.ProjectRBACRole.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.model.ProjectRBACRole.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.model.ProjectRBACRole} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACRole.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getSubject(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getPolicyList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 4, + f, + proto.model.ProjectRBACPolicy.serializeBinaryToWriter + ); + } +}; + + +/** + * @enum {number} + */ +proto.model.ProjectRBACRole.RoleType = { + GITHUB_TEAM: 0, + GOOGLE_GROUP: 1 +}; + +/** + * optional string name = 1; + * @return {string} + */ +proto.model.ProjectRBACRole.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectRBACRole} returns this + */ +proto.model.ProjectRBACRole.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional RoleType type = 2; + * @return {!proto.model.ProjectRBACRole.RoleType} + */ +proto.model.ProjectRBACRole.prototype.getType = function() { + return /** @type {!proto.model.ProjectRBACRole.RoleType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.model.ProjectRBACRole.RoleType} value + * @return {!proto.model.ProjectRBACRole} returns this + */ +proto.model.ProjectRBACRole.prototype.setType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional string subject = 3; + * @return {string} + */ +proto.model.ProjectRBACRole.prototype.getSubject = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectRBACRole} returns this + */ +proto.model.ProjectRBACRole.prototype.setSubject = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * repeated ProjectRBACPolicy policy = 4; + * @return {!Array} + */ +proto.model.ProjectRBACRole.prototype.getPolicyList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectRBACPolicy, 4)); +}; + + +/** + * @param {!Array} value + * @return {!proto.model.ProjectRBACRole} returns this +*/ +proto.model.ProjectRBACRole.prototype.setPolicyList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 4, value); +}; + + +/** + * @param {!proto.model.ProjectRBACPolicy=} opt_value + * @param {number=} opt_index + * @return {!proto.model.ProjectRBACPolicy} + */ +proto.model.ProjectRBACRole.prototype.addPolicy = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, proto.model.ProjectRBACPolicy, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.model.ProjectRBACRole} returns this + */ +proto.model.ProjectRBACRole.prototype.clearPolicyList = function() { + return this.setPolicyList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.model.ProjectRBACPolicy.prototype.toObject = function(opt_includeInstance) { + return proto.model.ProjectRBACPolicy.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.model.ProjectRBACPolicy} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACPolicy.toObject = function(includeInstance, msg) { + var f, obj = { + resourceType: jspb.Message.getFieldWithDefault(msg, 1, 0), + actionType: jspb.Message.getFieldWithDefault(msg, 2, 0), + labelKey: jspb.Message.getFieldWithDefault(msg, 3, ""), + labelValue: jspb.Message.getFieldWithDefault(msg, 4, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.model.ProjectRBACPolicy} + */ +proto.model.ProjectRBACPolicy.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.model.ProjectRBACPolicy; + return proto.model.ProjectRBACPolicy.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.model.ProjectRBACPolicy} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.model.ProjectRBACPolicy} + */ +proto.model.ProjectRBACPolicy.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.model.ProjectRBACPolicy.ResourceType} */ (reader.readEnum()); + msg.setResourceType(value); + break; + case 2: + var value = /** @type {!proto.model.ProjectRBACPolicy.ActionType} */ (reader.readEnum()); + msg.setActionType(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setLabelKey(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setLabelValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.model.ProjectRBACPolicy.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.model.ProjectRBACPolicy.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.model.ProjectRBACPolicy} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACPolicy.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getResourceType(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getActionType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getLabelKey(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getLabelValue(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.model.ProjectRBACPolicy.ResourceType = { + APPLICATION: 0, + DEPLOYMENT: 1, + EVENT: 2, + PIPED: 3, + DEPLOYMENTCHAIN: 4, + PROJECT: 5, + ROLE: 6, + APIKEY: 7 +}; + +/** + * @enum {number} + */ +proto.model.ProjectRBACPolicy.ActionType = { + GET: 0, + LIST: 1, + CREATE: 2, + UPDATE: 3, + DELETE: 4 +}; + +/** + * optional ResourceType resource_type = 1; + * @return {!proto.model.ProjectRBACPolicy.ResourceType} + */ +proto.model.ProjectRBACPolicy.prototype.getResourceType = function() { + return /** @type {!proto.model.ProjectRBACPolicy.ResourceType} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.model.ProjectRBACPolicy.ResourceType} value + * @return {!proto.model.ProjectRBACPolicy} returns this + */ +proto.model.ProjectRBACPolicy.prototype.setResourceType = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional ActionType action_type = 2; + * @return {!proto.model.ProjectRBACPolicy.ActionType} + */ +proto.model.ProjectRBACPolicy.prototype.getActionType = function() { + return /** @type {!proto.model.ProjectRBACPolicy.ActionType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.model.ProjectRBACPolicy.ActionType} value + * @return {!proto.model.ProjectRBACPolicy} returns this + */ +proto.model.ProjectRBACPolicy.prototype.setActionType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional string label_key = 3; + * @return {string} + */ +proto.model.ProjectRBACPolicy.prototype.getLabelKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectRBACPolicy} returns this + */ +proto.model.ProjectRBACPolicy.prototype.setLabelKey = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string label_value = 4; + * @return {string} + */ +proto.model.ProjectRBACPolicy.prototype.getLabelValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectRBACPolicy} returns this + */ +proto.model.ProjectRBACPolicy.prototype.setLabelValue = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + goog.object.extend(exports, proto.model); From 2a17a00eada6dd9b0f2167dd08c3f39d6dc1ce59 Mon Sep 17 00:00:00 2001 From: knanao Date: Tue, 15 Mar 2022 16:32:05 +0900 Subject: [PATCH 2/3] Chore to run make codegen --- web/model/project_pb.d.ts | 45 ++-- web/model/project_pb.js | 322 +++++++++++++++++++------- web/src/__fixtures__/dummy-project.ts | 2 + 3 files changed, 276 insertions(+), 93 deletions(-) diff --git a/web/model/project_pb.d.ts b/web/model/project_pb.d.ts index 9e4b0eb6a7..19cca7246a 100644 --- a/web/model/project_pb.d.ts +++ b/web/model/project_pb.d.ts @@ -39,6 +39,11 @@ export class Project extends jspb.Message { clearRbacRolesList(): Project; addRbacRoles(value?: ProjectRBACRole, index?: number): ProjectRBACRole; + getTeamsList(): Array; + setTeamsList(value: Array): Project; + clearTeamsList(): Project; + addTeams(value?: ProjectTeam, index?: number): ProjectTeam; + getCreatedAt(): number; setCreatedAt(value: number): Project; @@ -64,6 +69,7 @@ export namespace Project { sharedSsoName: string, allowStrayAsViewer: boolean, rbacRolesList: Array, + teamsList: Array, createdAt: number, updatedAt: number, } @@ -211,15 +217,31 @@ export namespace ProjectRBACConfig { } } -export class ProjectRBACRole extends jspb.Message { +export class ProjectTeam extends jspb.Message { getName(): string; - setName(value: string): ProjectRBACRole; + setName(value: string): ProjectTeam; + + getRoleName(): string; + setRoleName(value: string): ProjectTeam; - getType(): ProjectRBACRole.RoleType; - setType(value: ProjectRBACRole.RoleType): ProjectRBACRole; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProjectTeam.AsObject; + static toObject(includeInstance: boolean, msg: ProjectTeam): ProjectTeam.AsObject; + static serializeBinaryToWriter(message: ProjectTeam, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectTeam; + static deserializeBinaryFromReader(message: ProjectTeam, reader: jspb.BinaryReader): ProjectTeam; +} + +export namespace ProjectTeam { + export type AsObject = { + name: string, + roleName: string, + } +} - getSubject(): string; - setSubject(value: string): ProjectRBACRole; +export class ProjectRBACRole extends jspb.Message { + getName(): string; + setName(value: string): ProjectRBACRole; getPolicyList(): Array; setPolicyList(value: Array): ProjectRBACRole; @@ -237,15 +259,8 @@ export class ProjectRBACRole extends jspb.Message { export namespace ProjectRBACRole { export type AsObject = { name: string, - type: ProjectRBACRole.RoleType, - subject: string, policyList: Array, } - - export enum RoleType { - GITHUB_TEAM = 0, - GOOGLE_GROUP = 1, - } } export class ProjectRBACPolicy extends jspb.Message { @@ -284,8 +299,8 @@ export namespace ProjectRBACPolicy { PIPED = 3, DEPLOYMENTCHAIN = 4, PROJECT = 5, - ROLE = 6, - APIKEY = 7, + APIKEY = 6, + INSIGHT = 7, } export enum ActionType { diff --git a/web/model/project_pb.js b/web/model/project_pb.js index 0f650f5ff2..74e3c20d96 100644 --- a/web/model/project_pb.js +++ b/web/model/project_pb.js @@ -29,12 +29,12 @@ goog.exportSymbol('proto.model.ProjectRBACPolicy', null, global); goog.exportSymbol('proto.model.ProjectRBACPolicy.ActionType', null, global); goog.exportSymbol('proto.model.ProjectRBACPolicy.ResourceType', null, global); goog.exportSymbol('proto.model.ProjectRBACRole', null, global); -goog.exportSymbol('proto.model.ProjectRBACRole.RoleType', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.GitHub', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.Google', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.Provider', null, global); goog.exportSymbol('proto.model.ProjectStaticUser', null, global); +goog.exportSymbol('proto.model.ProjectTeam', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -161,6 +161,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.model.ProjectRBACConfig.displayName = 'proto.model.ProjectRBACConfig'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.model.ProjectTeam = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.model.ProjectTeam, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.model.ProjectTeam.displayName = 'proto.model.ProjectTeam'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -209,7 +230,7 @@ if (goog.DEBUG && !COMPILED) { * @private {!Array} * @const */ -proto.model.Project.repeatedFields_ = [9]; +proto.model.Project.repeatedFields_ = [9,10]; @@ -252,6 +273,8 @@ proto.model.Project.toObject = function(includeInstance, msg) { allowStrayAsViewer: jspb.Message.getBooleanFieldWithDefault(msg, 8, false), rbacRolesList: jspb.Message.toObjectList(msg.getRbacRolesList(), proto.model.ProjectRBACRole.toObject, includeInstance), + teamsList: jspb.Message.toObjectList(msg.getTeamsList(), + proto.model.ProjectTeam.toObject, includeInstance), createdAt: jspb.Message.getFieldWithDefault(msg, 14, 0), updatedAt: jspb.Message.getFieldWithDefault(msg, 15, 0) }; @@ -330,6 +353,11 @@ proto.model.Project.deserializeBinaryFromReader = function(msg, reader) { reader.readMessage(value,proto.model.ProjectRBACRole.deserializeBinaryFromReader); msg.addRbacRoles(value); break; + case 10: + var value = new proto.model.ProjectTeam; + reader.readMessage(value,proto.model.ProjectTeam.deserializeBinaryFromReader); + msg.addTeams(value); + break; case 14: var value = /** @type {number} */ (reader.readInt64()); msg.setCreatedAt(value); @@ -434,6 +462,14 @@ proto.model.Project.serializeBinaryToWriter = function(message, writer) { proto.model.ProjectRBACRole.serializeBinaryToWriter ); } + f = message.getTeamsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 10, + f, + proto.model.ProjectTeam.serializeBinaryToWriter + ); + } f = message.getCreatedAt(); if (f !== 0) { writer.writeInt64( @@ -690,6 +726,44 @@ proto.model.Project.prototype.clearRbacRolesList = function() { }; +/** + * repeated ProjectTeam teams = 10; + * @return {!Array} + */ +proto.model.Project.prototype.getTeamsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectTeam, 10)); +}; + + +/** + * @param {!Array} value + * @return {!proto.model.Project} returns this +*/ +proto.model.Project.prototype.setTeamsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 10, value); +}; + + +/** + * @param {!proto.model.ProjectTeam=} opt_value + * @param {number=} opt_index + * @return {!proto.model.ProjectTeam} + */ +proto.model.Project.prototype.addTeams = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 10, opt_value, proto.model.ProjectTeam, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.model.Project} returns this + */ +proto.model.Project.prototype.clearTeamsList = function() { + return this.setTeamsList([]); +}; + + /** * optional int64 created_at = 14; * @return {number} @@ -1728,12 +1802,172 @@ proto.model.ProjectRBACConfig.prototype.setViewer = function(value) { + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.model.ProjectTeam.prototype.toObject = function(opt_includeInstance) { + return proto.model.ProjectTeam.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.model.ProjectTeam} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectTeam.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + roleName: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.model.ProjectTeam} + */ +proto.model.ProjectTeam.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.model.ProjectTeam; + return proto.model.ProjectTeam.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.model.ProjectTeam} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.model.ProjectTeam} + */ +proto.model.ProjectTeam.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setRoleName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.model.ProjectTeam.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.model.ProjectTeam.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.model.ProjectTeam} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectTeam.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getRoleName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.model.ProjectTeam.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectTeam} returns this + */ +proto.model.ProjectTeam.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string role_name = 2; + * @return {string} + */ +proto.model.ProjectTeam.prototype.getRoleName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.model.ProjectTeam} returns this + */ +proto.model.ProjectTeam.prototype.setRoleName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + + /** * List of repeated fields within this message type. * @private {!Array} * @const */ -proto.model.ProjectRBACRole.repeatedFields_ = [4]; +proto.model.ProjectRBACRole.repeatedFields_ = [2]; @@ -1767,8 +2001,6 @@ proto.model.ProjectRBACRole.prototype.toObject = function(opt_includeInstance) { proto.model.ProjectRBACRole.toObject = function(includeInstance, msg) { var f, obj = { name: jspb.Message.getFieldWithDefault(msg, 1, ""), - type: jspb.Message.getFieldWithDefault(msg, 2, 0), - subject: jspb.Message.getFieldWithDefault(msg, 3, ""), policyList: jspb.Message.toObjectList(msg.getPolicyList(), proto.model.ProjectRBACPolicy.toObject, includeInstance) }; @@ -1812,14 +2044,6 @@ proto.model.ProjectRBACRole.deserializeBinaryFromReader = function(msg, reader) msg.setName(value); break; case 2: - var value = /** @type {!proto.model.ProjectRBACRole.RoleType} */ (reader.readEnum()); - msg.setType(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setSubject(value); - break; - case 4: var value = new proto.model.ProjectRBACPolicy; reader.readMessage(value,proto.model.ProjectRBACPolicy.deserializeBinaryFromReader); msg.addPolicy(value); @@ -1860,24 +2084,10 @@ proto.model.ProjectRBACRole.serializeBinaryToWriter = function(message, writer) f ); } - f = message.getType(); - if (f !== 0.0) { - writer.writeEnum( - 2, - f - ); - } - f = message.getSubject(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } f = message.getPolicyList(); if (f.length > 0) { writer.writeRepeatedMessage( - 4, + 2, f, proto.model.ProjectRBACPolicy.serializeBinaryToWriter ); @@ -1885,14 +2095,6 @@ proto.model.ProjectRBACRole.serializeBinaryToWriter = function(message, writer) }; -/** - * @enum {number} - */ -proto.model.ProjectRBACRole.RoleType = { - GITHUB_TEAM: 0, - GOOGLE_GROUP: 1 -}; - /** * optional string name = 1; * @return {string} @@ -1912,48 +2114,12 @@ proto.model.ProjectRBACRole.prototype.setName = function(value) { /** - * optional RoleType type = 2; - * @return {!proto.model.ProjectRBACRole.RoleType} - */ -proto.model.ProjectRBACRole.prototype.getType = function() { - return /** @type {!proto.model.ProjectRBACRole.RoleType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {!proto.model.ProjectRBACRole.RoleType} value - * @return {!proto.model.ProjectRBACRole} returns this - */ -proto.model.ProjectRBACRole.prototype.setType = function(value) { - return jspb.Message.setProto3EnumField(this, 2, value); -}; - - -/** - * optional string subject = 3; - * @return {string} - */ -proto.model.ProjectRBACRole.prototype.getSubject = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.model.ProjectRBACRole} returns this - */ -proto.model.ProjectRBACRole.prototype.setSubject = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); -}; - - -/** - * repeated ProjectRBACPolicy policy = 4; + * repeated ProjectRBACPolicy policy = 2; * @return {!Array} */ proto.model.ProjectRBACRole.prototype.getPolicyList = function() { return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectRBACPolicy, 4)); + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectRBACPolicy, 2)); }; @@ -1962,7 +2128,7 @@ proto.model.ProjectRBACRole.prototype.getPolicyList = function() { * @return {!proto.model.ProjectRBACRole} returns this */ proto.model.ProjectRBACRole.prototype.setPolicyList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 4, value); + return jspb.Message.setRepeatedWrapperField(this, 2, value); }; @@ -1972,7 +2138,7 @@ proto.model.ProjectRBACRole.prototype.setPolicyList = function(value) { * @return {!proto.model.ProjectRBACPolicy} */ proto.model.ProjectRBACRole.prototype.addPolicy = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, proto.model.ProjectRBACPolicy, opt_index); + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.model.ProjectRBACPolicy, opt_index); }; @@ -2143,8 +2309,8 @@ proto.model.ProjectRBACPolicy.ResourceType = { PIPED: 3, DEPLOYMENTCHAIN: 4, PROJECT: 5, - ROLE: 6, - APIKEY: 7 + APIKEY: 6, + INSIGHT: 7 }; /** diff --git a/web/src/__fixtures__/dummy-project.ts b/web/src/__fixtures__/dummy-project.ts index 0733035c76..c23d2ab085 100644 --- a/web/src/__fixtures__/dummy-project.ts +++ b/web/src/__fixtures__/dummy-project.ts @@ -25,6 +25,8 @@ export const dummyProject: Project.AsObject = { editor: "editor-team", viewer: "viewer-team", }, + rbacRolesList: [], + teamsList: [], staticAdmin: { username: "static-admin-user", passwordHash: randomKeyHash(), From 714e64f45834ba45a08094bfcca106935b4dde66 Mon Sep 17 00:00:00 2001 From: knanao Date: Wed, 16 Mar 2022 17:11:46 +0900 Subject: [PATCH 3/3] Fix from reviews --- pkg/model/project.pb.go | 415 ++++++++++++++---------- pkg/model/project.pb.validate.go | 275 ++++++++++++---- pkg/model/project.proto | 42 +-- web/model/project_pb.d.ts | 102 +++--- web/model/project_pb.js | 450 ++++++++++++++++++-------- web/src/__fixtures__/dummy-project.ts | 2 +- 6 files changed, 854 insertions(+), 432 deletions(-) diff --git a/pkg/model/project.pb.go b/pkg/model/project.pb.go index c2bad4ef93..f61260e8ab 100644 --- a/pkg/model/project.pb.go +++ b/pkg/model/project.pb.go @@ -88,90 +88,90 @@ func (ProjectSSOConfig_Provider) EnumDescriptor() ([]byte, []int) { return file_pkg_model_project_proto_rawDescGZIP(), []int{2, 0} } -type ProjectRBACPolicy_ResourceType int32 +type ProjectRBACResource_ResourceType int32 const ( - ProjectRBACPolicy_APPLICATION ProjectRBACPolicy_ResourceType = 0 - ProjectRBACPolicy_DEPLOYMENT ProjectRBACPolicy_ResourceType = 1 - ProjectRBACPolicy_EVENT ProjectRBACPolicy_ResourceType = 2 - ProjectRBACPolicy_PIPED ProjectRBACPolicy_ResourceType = 3 - ProjectRBACPolicy_DEPLOYMENTCHAIN ProjectRBACPolicy_ResourceType = 4 - ProjectRBACPolicy_PROJECT ProjectRBACPolicy_ResourceType = 5 - ProjectRBACPolicy_APIKEY ProjectRBACPolicy_ResourceType = 6 - ProjectRBACPolicy_INSIGHT ProjectRBACPolicy_ResourceType = 7 + ProjectRBACResource_APPLICATION ProjectRBACResource_ResourceType = 0 + ProjectRBACResource_DEPLOYMENT ProjectRBACResource_ResourceType = 1 + ProjectRBACResource_EVENT ProjectRBACResource_ResourceType = 2 + ProjectRBACResource_PIPED ProjectRBACResource_ResourceType = 3 + ProjectRBACResource_DEPLOYMENT_CHAIN ProjectRBACResource_ResourceType = 4 + ProjectRBACResource_PROJECT ProjectRBACResource_ResourceType = 5 + ProjectRBACResource_API_KEY ProjectRBACResource_ResourceType = 6 + ProjectRBACResource_INSIGHT ProjectRBACResource_ResourceType = 7 ) -// Enum value maps for ProjectRBACPolicy_ResourceType. +// Enum value maps for ProjectRBACResource_ResourceType. var ( - ProjectRBACPolicy_ResourceType_name = map[int32]string{ + ProjectRBACResource_ResourceType_name = map[int32]string{ 0: "APPLICATION", 1: "DEPLOYMENT", 2: "EVENT", 3: "PIPED", - 4: "DEPLOYMENTCHAIN", + 4: "DEPLOYMENT_CHAIN", 5: "PROJECT", - 6: "APIKEY", + 6: "API_KEY", 7: "INSIGHT", } - ProjectRBACPolicy_ResourceType_value = map[string]int32{ - "APPLICATION": 0, - "DEPLOYMENT": 1, - "EVENT": 2, - "PIPED": 3, - "DEPLOYMENTCHAIN": 4, - "PROJECT": 5, - "APIKEY": 6, - "INSIGHT": 7, + ProjectRBACResource_ResourceType_value = map[string]int32{ + "APPLICATION": 0, + "DEPLOYMENT": 1, + "EVENT": 2, + "PIPED": 3, + "DEPLOYMENT_CHAIN": 4, + "PROJECT": 5, + "API_KEY": 6, + "INSIGHT": 7, } ) -func (x ProjectRBACPolicy_ResourceType) Enum() *ProjectRBACPolicy_ResourceType { - p := new(ProjectRBACPolicy_ResourceType) +func (x ProjectRBACResource_ResourceType) Enum() *ProjectRBACResource_ResourceType { + p := new(ProjectRBACResource_ResourceType) *p = x return p } -func (x ProjectRBACPolicy_ResourceType) String() string { +func (x ProjectRBACResource_ResourceType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ProjectRBACPolicy_ResourceType) Descriptor() protoreflect.EnumDescriptor { +func (ProjectRBACResource_ResourceType) Descriptor() protoreflect.EnumDescriptor { return file_pkg_model_project_proto_enumTypes[1].Descriptor() } -func (ProjectRBACPolicy_ResourceType) Type() protoreflect.EnumType { +func (ProjectRBACResource_ResourceType) Type() protoreflect.EnumType { return &file_pkg_model_project_proto_enumTypes[1] } -func (x ProjectRBACPolicy_ResourceType) Number() protoreflect.EnumNumber { +func (x ProjectRBACResource_ResourceType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use ProjectRBACPolicy_ResourceType.Descriptor instead. -func (ProjectRBACPolicy_ResourceType) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use ProjectRBACResource_ResourceType.Descriptor instead. +func (ProjectRBACResource_ResourceType) EnumDescriptor() ([]byte, []int) { return file_pkg_model_project_proto_rawDescGZIP(), []int{6, 0} } -type ProjectRBACPolicy_ActionType int32 +type ProjectRBACPolicy_Action int32 const ( - ProjectRBACPolicy_GET ProjectRBACPolicy_ActionType = 0 - ProjectRBACPolicy_LIST ProjectRBACPolicy_ActionType = 1 - ProjectRBACPolicy_CREATE ProjectRBACPolicy_ActionType = 2 - ProjectRBACPolicy_UPDATE ProjectRBACPolicy_ActionType = 3 - ProjectRBACPolicy_DELETE ProjectRBACPolicy_ActionType = 4 + ProjectRBACPolicy_GET ProjectRBACPolicy_Action = 0 + ProjectRBACPolicy_LIST ProjectRBACPolicy_Action = 1 + ProjectRBACPolicy_CREATE ProjectRBACPolicy_Action = 2 + ProjectRBACPolicy_UPDATE ProjectRBACPolicy_Action = 3 + ProjectRBACPolicy_DELETE ProjectRBACPolicy_Action = 4 ) -// Enum value maps for ProjectRBACPolicy_ActionType. +// Enum value maps for ProjectRBACPolicy_Action. var ( - ProjectRBACPolicy_ActionType_name = map[int32]string{ + ProjectRBACPolicy_Action_name = map[int32]string{ 0: "GET", 1: "LIST", 2: "CREATE", 3: "UPDATE", 4: "DELETE", } - ProjectRBACPolicy_ActionType_value = map[string]int32{ + ProjectRBACPolicy_Action_value = map[string]int32{ "GET": 0, "LIST": 1, "CREATE": 2, @@ -180,31 +180,31 @@ var ( } ) -func (x ProjectRBACPolicy_ActionType) Enum() *ProjectRBACPolicy_ActionType { - p := new(ProjectRBACPolicy_ActionType) +func (x ProjectRBACPolicy_Action) Enum() *ProjectRBACPolicy_Action { + p := new(ProjectRBACPolicy_Action) *p = x return p } -func (x ProjectRBACPolicy_ActionType) String() string { +func (x ProjectRBACPolicy_Action) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ProjectRBACPolicy_ActionType) Descriptor() protoreflect.EnumDescriptor { +func (ProjectRBACPolicy_Action) Descriptor() protoreflect.EnumDescriptor { return file_pkg_model_project_proto_enumTypes[2].Descriptor() } -func (ProjectRBACPolicy_ActionType) Type() protoreflect.EnumType { +func (ProjectRBACPolicy_Action) Type() protoreflect.EnumType { return &file_pkg_model_project_proto_enumTypes[2] } -func (x ProjectRBACPolicy_ActionType) Number() protoreflect.EnumNumber { +func (x ProjectRBACPolicy_Action) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use ProjectRBACPolicy_ActionType.Descriptor instead. -func (ProjectRBACPolicy_ActionType) EnumDescriptor() ([]byte, []int) { - return file_pkg_model_project_proto_rawDescGZIP(), []int{6, 1} +// Deprecated: Use ProjectRBACPolicy_Action.Descriptor instead. +func (ProjectRBACPolicy_Action) EnumDescriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{7, 0} } // Project contains needed data for a PipeCD project. @@ -237,8 +237,8 @@ type Project struct { AllowStrayAsViewer bool `protobuf:"varint,8,opt,name=allow_stray_as_viewer,json=allowStrayAsViewer,proto3" json:"allow_stray_as_viewer,omitempty"` // RBAC roles for this project. RbacRoles []*ProjectRBACRole `protobuf:"bytes,9,rep,name=rbac_roles,json=rbacRoles,proto3" json:"rbac_roles,omitempty"` - // Teams for this project. - Teams []*ProjectTeam `protobuf:"bytes,10,rep,name=teams,proto3" json:"teams,omitempty"` + // Mapping SSO group and RBAC role. + UserGroups []*ProjectUserGroup `protobuf:"bytes,10,rep,name=user_groups,json=userGroups,proto3" json:"user_groups,omitempty"` // Unix time when the project is created. CreatedAt int64 `protobuf:"varint,14,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // Unix time of the last time when the project is updated. @@ -340,9 +340,9 @@ func (x *Project) GetRbacRoles() []*ProjectRBACRole { return nil } -func (x *Project) GetTeams() []*ProjectTeam { +func (x *Project) GetUserGroups() []*ProjectUserGroup { if x != nil { - return x.Teams + return x.UserGroups } return nil } @@ -545,20 +545,20 @@ func (x *ProjectRBACConfig) GetViewer() string { return "" } -// ProjectTeam represents a team. -type ProjectTeam struct { +// ProjectUserGroup represents a user group. +type ProjectUserGroup struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The name of team. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The name of sso group. + SsoGroup string `protobuf:"bytes,1,opt,name=sso_group,json=ssoGroup,proto3" json:"sso_group,omitempty"` // The name of rbac role. - RoleName string `protobuf:"bytes,2,opt,name=role_name,json=roleName,proto3" json:"role_name,omitempty"` + Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` } -func (x *ProjectTeam) Reset() { - *x = ProjectTeam{} +func (x *ProjectUserGroup) Reset() { + *x = ProjectUserGroup{} if protoimpl.UnsafeEnabled { mi := &file_pkg_model_project_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -566,13 +566,13 @@ func (x *ProjectTeam) Reset() { } } -func (x *ProjectTeam) String() string { +func (x *ProjectUserGroup) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ProjectTeam) ProtoMessage() {} +func (*ProjectUserGroup) ProtoMessage() {} -func (x *ProjectTeam) ProtoReflect() protoreflect.Message { +func (x *ProjectUserGroup) ProtoReflect() protoreflect.Message { mi := &file_pkg_model_project_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -584,21 +584,21 @@ func (x *ProjectTeam) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ProjectTeam.ProtoReflect.Descriptor instead. -func (*ProjectTeam) Descriptor() ([]byte, []int) { +// Deprecated: Use ProjectUserGroup.ProtoReflect.Descriptor instead. +func (*ProjectUserGroup) Descriptor() ([]byte, []int) { return file_pkg_model_project_proto_rawDescGZIP(), []int{4} } -func (x *ProjectTeam) GetName() string { +func (x *ProjectUserGroup) GetSsoGroup() string { if x != nil { - return x.Name + return x.SsoGroup } return "" } -func (x *ProjectTeam) GetRoleName() string { +func (x *ProjectUserGroup) GetRole() string { if x != nil { - return x.RoleName + return x.Role } return "" } @@ -661,23 +661,20 @@ func (x *ProjectRBACRole) GetPolicy() []*ProjectRBACPolicy { return nil } -type ProjectRBACPolicy struct { +// ProjectResource represents a RBAC resource. +type ProjectRBACResource struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The type of resource. - ResourceType ProjectRBACPolicy_ResourceType `protobuf:"varint,1,opt,name=resource_type,json=resourceType,proto3,enum=model.ProjectRBACPolicy_ResourceType" json:"resource_type,omitempty"` - // The type of action. - ActionType ProjectRBACPolicy_ActionType `protobuf:"varint,2,opt,name=action_type,json=actionType,proto3,enum=model.ProjectRBACPolicy_ActionType" json:"action_type,omitempty"` - // The key of resource label. - LabelKey string `protobuf:"bytes,3,opt,name=label_key,json=labelKey,proto3" json:"label_key,omitempty"` - // The value of resource label. - LabelValue string `protobuf:"bytes,4,opt,name=label_value,json=labelValue,proto3" json:"label_value,omitempty"` + Type ProjectRBACResource_ResourceType `protobuf:"varint,1,opt,name=type,proto3,enum=model.ProjectRBACResource_ResourceType" json:"type,omitempty"` + // Custom attributes to identify resource. + Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (x *ProjectRBACPolicy) Reset() { - *x = ProjectRBACPolicy{} +func (x *ProjectRBACResource) Reset() { + *x = ProjectRBACResource{} if protoimpl.UnsafeEnabled { mi := &file_pkg_model_project_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -685,13 +682,13 @@ func (x *ProjectRBACPolicy) Reset() { } } -func (x *ProjectRBACPolicy) String() string { +func (x *ProjectRBACResource) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ProjectRBACPolicy) ProtoMessage() {} +func (*ProjectRBACResource) ProtoMessage() {} -func (x *ProjectRBACPolicy) ProtoReflect() protoreflect.Message { +func (x *ProjectRBACResource) ProtoReflect() protoreflect.Message { mi := &file_pkg_model_project_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -703,37 +700,80 @@ func (x *ProjectRBACPolicy) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ProjectRBACPolicy.ProtoReflect.Descriptor instead. -func (*ProjectRBACPolicy) Descriptor() ([]byte, []int) { +// Deprecated: Use ProjectRBACResource.ProtoReflect.Descriptor instead. +func (*ProjectRBACResource) Descriptor() ([]byte, []int) { return file_pkg_model_project_proto_rawDescGZIP(), []int{6} } -func (x *ProjectRBACPolicy) GetResourceType() ProjectRBACPolicy_ResourceType { +func (x *ProjectRBACResource) GetType() ProjectRBACResource_ResourceType { if x != nil { - return x.ResourceType + return x.Type } - return ProjectRBACPolicy_APPLICATION + return ProjectRBACResource_APPLICATION } -func (x *ProjectRBACPolicy) GetActionType() ProjectRBACPolicy_ActionType { +func (x *ProjectRBACResource) GetLabels() map[string]string { if x != nil { - return x.ActionType + return x.Labels + } + return nil +} + +type ProjectRBACPolicy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The resources of this project. + Resources []*ProjectRBACResource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` + // The types of action. + Actions []ProjectRBACPolicy_Action `protobuf:"varint,2,rep,packed,name=actions,proto3,enum=model.ProjectRBACPolicy_Action" json:"actions,omitempty"` +} + +func (x *ProjectRBACPolicy) Reset() { + *x = ProjectRBACPolicy{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_model_project_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProjectRBACPolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProjectRBACPolicy) ProtoMessage() {} + +func (x *ProjectRBACPolicy) ProtoReflect() protoreflect.Message { + mi := &file_pkg_model_project_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return ProjectRBACPolicy_GET + return mi.MessageOf(x) } -func (x *ProjectRBACPolicy) GetLabelKey() string { +// Deprecated: Use ProjectRBACPolicy.ProtoReflect.Descriptor instead. +func (*ProjectRBACPolicy) Descriptor() ([]byte, []int) { + return file_pkg_model_project_proto_rawDescGZIP(), []int{7} +} + +func (x *ProjectRBACPolicy) GetResources() []*ProjectRBACResource { if x != nil { - return x.LabelKey + return x.Resources } - return "" + return nil } -func (x *ProjectRBACPolicy) GetLabelValue() string { +func (x *ProjectRBACPolicy) GetActions() []ProjectRBACPolicy_Action { if x != nil { - return x.LabelValue + return x.Actions } - return "" + return nil } type ProjectSSOConfig_GitHub struct { @@ -756,7 +796,7 @@ type ProjectSSOConfig_GitHub struct { func (x *ProjectSSOConfig_GitHub) Reset() { *x = ProjectSSOConfig_GitHub{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_model_project_proto_msgTypes[7] + mi := &file_pkg_model_project_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -769,7 +809,7 @@ func (x *ProjectSSOConfig_GitHub) String() string { func (*ProjectSSOConfig_GitHub) ProtoMessage() {} func (x *ProjectSSOConfig_GitHub) ProtoReflect() protoreflect.Message { - mi := &file_pkg_model_project_proto_msgTypes[7] + mi := &file_pkg_model_project_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -834,7 +874,7 @@ type ProjectSSOConfig_Google struct { func (x *ProjectSSOConfig_Google) Reset() { *x = ProjectSSOConfig_Google{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_model_project_proto_msgTypes[8] + mi := &file_pkg_model_project_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -847,7 +887,7 @@ func (x *ProjectSSOConfig_Google) String() string { func (*ProjectSSOConfig_Google) ProtoMessage() {} func (x *ProjectSSOConfig_Google) ProtoReflect() protoreflect.Message { - mi := &file_pkg_model_project_proto_msgTypes[8] + mi := &file_pkg_model_project_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -883,7 +923,7 @@ var file_pkg_model_project_proto_rawDesc = []byte{ 0x0a, 0x17, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x04, 0x0a, 0x07, 0x50, 0x72, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa6, 0x04, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, @@ -909,10 +949,11 @@ var file_pkg_model_project_proto_rawDesc = []byte{ 0x72, 0x12, 0x35, 0x0a, 0x0a, 0x72, 0x62, 0x61, 0x63, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x09, 0x72, - 0x62, 0x61, 0x63, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, - 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, - 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x74, 0x65, 0x61, - 0x6d, 0x73, 0x12, 0x26, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x62, 0x61, 0x63, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, + 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x73, 0x12, 0x26, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, @@ -963,50 +1004,58 @@ var file_pkg_model_project_proto_rawDesc = []byte{ 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x22, 0x50, - 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x1b, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, - 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x72, 0x6f, - 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, - 0x22, 0x60, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, - 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x30, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x22, 0xbf, 0x03, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, - 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x54, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x25, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, - 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x22, 0x55, + 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x73, 0x65, 0x72, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x12, 0x24, 0x0a, 0x09, 0x73, 0x73, 0x6f, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, + 0x73, 0x73, 0x6f, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, + 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x60, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x42, 0x41, 0x43, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, + 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0xf6, 0x02, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, + 0x45, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, + 0x43, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, - 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4e, - 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, - 0x10, 0x01, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, - 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x80, 0x01, 0x0a, - 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, - 0x0b, 0x41, 0x50, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0e, - 0x0a, 0x0a, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x09, - 0x0a, 0x05, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x49, 0x50, - 0x45, 0x44, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, - 0x4e, 0x54, 0x43, 0x48, 0x41, 0x49, 0x4e, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, - 0x4a, 0x45, 0x43, 0x54, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x50, 0x49, 0x4b, 0x45, 0x59, - 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x49, 0x47, 0x48, 0x54, 0x10, 0x07, 0x22, - 0x43, 0x0a, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, - 0x03, 0x47, 0x45, 0x54, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, - 0x54, 0x45, 0x10, 0x04, 0x42, 0x25, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x2d, 0x63, 0x64, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x63, - 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x58, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x18, + 0xfa, 0x42, 0x09, 0x9a, 0x01, 0x06, 0x22, 0x04, 0x72, 0x02, 0x10, 0x01, 0xfa, 0x42, 0x09, 0x9a, + 0x01, 0x06, 0x2a, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, + 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x82, 0x01, 0x0a, 0x0c, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, + 0x41, 0x50, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0e, 0x0a, + 0x0a, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x09, 0x0a, + 0x05, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x49, 0x50, 0x45, + 0x44, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x4d, 0x45, 0x4e, + 0x54, 0x5f, 0x43, 0x48, 0x41, 0x49, 0x4e, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, + 0x4a, 0x45, 0x43, 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x50, 0x49, 0x5f, 0x4b, 0x45, + 0x59, 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x49, 0x47, 0x48, 0x54, 0x10, 0x07, + 0x22, 0xc9, 0x01, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6d, 0x6f, 0x64, 0x65, + 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x42, 0x41, 0x43, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x12, 0x39, 0x0a, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0e, 0x32, 0x1f, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x42, 0x41, 0x43, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x3f, 0x0a, 0x06, 0x41, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x45, 0x54, 0x10, 0x00, 0x12, 0x08, + 0x0a, 0x04, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, + 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x04, 0x42, 0x25, 0x5a, 0x23, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x2d, + 0x63, 0x64, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x63, 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x6f, + 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1022,38 +1071,42 @@ func file_pkg_model_project_proto_rawDescGZIP() []byte { } var file_pkg_model_project_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_pkg_model_project_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_pkg_model_project_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_pkg_model_project_proto_goTypes = []interface{}{ - (ProjectSSOConfig_Provider)(0), // 0: model.ProjectSSOConfig.Provider - (ProjectRBACPolicy_ResourceType)(0), // 1: model.ProjectRBACPolicy.ResourceType - (ProjectRBACPolicy_ActionType)(0), // 2: model.ProjectRBACPolicy.ActionType - (*Project)(nil), // 3: model.Project - (*ProjectStaticUser)(nil), // 4: model.ProjectStaticUser - (*ProjectSSOConfig)(nil), // 5: model.ProjectSSOConfig - (*ProjectRBACConfig)(nil), // 6: model.ProjectRBACConfig - (*ProjectTeam)(nil), // 7: model.ProjectTeam - (*ProjectRBACRole)(nil), // 8: model.ProjectRBACRole - (*ProjectRBACPolicy)(nil), // 9: model.ProjectRBACPolicy - (*ProjectSSOConfig_GitHub)(nil), // 10: model.ProjectSSOConfig.GitHub - (*ProjectSSOConfig_Google)(nil), // 11: model.ProjectSSOConfig.Google + (ProjectSSOConfig_Provider)(0), // 0: model.ProjectSSOConfig.Provider + (ProjectRBACResource_ResourceType)(0), // 1: model.ProjectRBACResource.ResourceType + (ProjectRBACPolicy_Action)(0), // 2: model.ProjectRBACPolicy.Action + (*Project)(nil), // 3: model.Project + (*ProjectStaticUser)(nil), // 4: model.ProjectStaticUser + (*ProjectSSOConfig)(nil), // 5: model.ProjectSSOConfig + (*ProjectRBACConfig)(nil), // 6: model.ProjectRBACConfig + (*ProjectUserGroup)(nil), // 7: model.ProjectUserGroup + (*ProjectRBACRole)(nil), // 8: model.ProjectRBACRole + (*ProjectRBACResource)(nil), // 9: model.ProjectRBACResource + (*ProjectRBACPolicy)(nil), // 10: model.ProjectRBACPolicy + (*ProjectSSOConfig_GitHub)(nil), // 11: model.ProjectSSOConfig.GitHub + (*ProjectSSOConfig_Google)(nil), // 12: model.ProjectSSOConfig.Google + nil, // 13: model.ProjectRBACResource.LabelsEntry } var file_pkg_model_project_proto_depIdxs = []int32{ 4, // 0: model.Project.static_admin:type_name -> model.ProjectStaticUser 5, // 1: model.Project.sso:type_name -> model.ProjectSSOConfig 6, // 2: model.Project.rbac:type_name -> model.ProjectRBACConfig 8, // 3: model.Project.rbac_roles:type_name -> model.ProjectRBACRole - 7, // 4: model.Project.teams:type_name -> model.ProjectTeam + 7, // 4: model.Project.user_groups:type_name -> model.ProjectUserGroup 0, // 5: model.ProjectSSOConfig.provider:type_name -> model.ProjectSSOConfig.Provider - 10, // 6: model.ProjectSSOConfig.github:type_name -> model.ProjectSSOConfig.GitHub - 11, // 7: model.ProjectSSOConfig.google:type_name -> model.ProjectSSOConfig.Google - 9, // 8: model.ProjectRBACRole.policy:type_name -> model.ProjectRBACPolicy - 1, // 9: model.ProjectRBACPolicy.resource_type:type_name -> model.ProjectRBACPolicy.ResourceType - 2, // 10: model.ProjectRBACPolicy.action_type:type_name -> model.ProjectRBACPolicy.ActionType - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 11, // 6: model.ProjectSSOConfig.github:type_name -> model.ProjectSSOConfig.GitHub + 12, // 7: model.ProjectSSOConfig.google:type_name -> model.ProjectSSOConfig.Google + 10, // 8: model.ProjectRBACRole.policy:type_name -> model.ProjectRBACPolicy + 1, // 9: model.ProjectRBACResource.type:type_name -> model.ProjectRBACResource.ResourceType + 13, // 10: model.ProjectRBACResource.labels:type_name -> model.ProjectRBACResource.LabelsEntry + 9, // 11: model.ProjectRBACPolicy.resources:type_name -> model.ProjectRBACResource + 2, // 12: model.ProjectRBACPolicy.actions:type_name -> model.ProjectRBACPolicy.Action + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_pkg_model_project_proto_init() } @@ -1111,7 +1164,7 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProjectTeam); i { + switch v := v.(*ProjectUserGroup); i { case 0: return &v.state case 1: @@ -1135,7 +1188,7 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProjectRBACPolicy); i { + switch v := v.(*ProjectRBACResource); i { case 0: return &v.state case 1: @@ -1147,7 +1200,7 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProjectSSOConfig_GitHub); i { + switch v := v.(*ProjectRBACPolicy); i { case 0: return &v.state case 1: @@ -1159,6 +1212,18 @@ func file_pkg_model_project_proto_init() { } } file_pkg_model_project_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProjectSSOConfig_GitHub); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_model_project_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProjectSSOConfig_Google); i { case 0: return &v.state @@ -1177,7 +1242,7 @@ func file_pkg_model_project_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pkg_model_project_proto_rawDesc, NumEnums: 3, - NumMessages: 9, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/model/project.pb.validate.go b/pkg/model/project.pb.validate.go index b187ea8f1e..0b7e1d0c04 100644 --- a/pkg/model/project.pb.validate.go +++ b/pkg/model/project.pb.validate.go @@ -207,7 +207,7 @@ func (m *Project) validate(all bool) error { } - for idx, item := range m.GetTeams() { + for idx, item := range m.GetUserGroups() { _, _ = idx, item if all { @@ -215,7 +215,7 @@ func (m *Project) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ProjectValidationError{ - field: fmt.Sprintf("Teams[%v]", idx), + field: fmt.Sprintf("UserGroups[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -223,7 +223,7 @@ func (m *Project) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ProjectValidationError{ - field: fmt.Sprintf("Teams[%v]", idx), + field: fmt.Sprintf("UserGroups[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -232,7 +232,7 @@ func (m *Project) validate(all bool) error { } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ProjectValidationError{ - field: fmt.Sprintf("Teams[%v]", idx), + field: fmt.Sprintf("UserGroups[%v]", idx), reason: "embedded message failed validation", cause: err, } @@ -750,31 +750,31 @@ var _ interface { ErrorName() string } = ProjectRBACConfigValidationError{} -// Validate checks the field values on ProjectTeam with the rules defined in -// the proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *ProjectTeam) Validate() error { +// Validate checks the field values on ProjectUserGroup with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ProjectUserGroup) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ProjectTeam with the rules defined in -// the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in ProjectTeamMultiError, or -// nil if none found. -func (m *ProjectTeam) ValidateAll() error { +// ValidateAll checks the field values on ProjectUserGroup with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProjectUserGroupMultiError, or nil if none found. +func (m *ProjectUserGroup) ValidateAll() error { return m.validate(true) } -func (m *ProjectTeam) validate(all bool) error { +func (m *ProjectUserGroup) validate(all bool) error { if m == nil { return nil } var errors []error - if utf8.RuneCountInString(m.GetName()) < 1 { - err := ProjectTeamValidationError{ - field: "Name", + if utf8.RuneCountInString(m.GetSsoGroup()) < 1 { + err := ProjectUserGroupValidationError{ + field: "SsoGroup", reason: "value length must be at least 1 runes", } if !all { @@ -783,9 +783,9 @@ func (m *ProjectTeam) validate(all bool) error { errors = append(errors, err) } - if utf8.RuneCountInString(m.GetRoleName()) < 1 { - err := ProjectTeamValidationError{ - field: "RoleName", + if utf8.RuneCountInString(m.GetRole()) < 1 { + err := ProjectUserGroupValidationError{ + field: "Role", reason: "value length must be at least 1 runes", } if !all { @@ -795,18 +795,19 @@ func (m *ProjectTeam) validate(all bool) error { } if len(errors) > 0 { - return ProjectTeamMultiError(errors) + return ProjectUserGroupMultiError(errors) } return nil } -// ProjectTeamMultiError is an error wrapping multiple validation errors -// returned by ProjectTeam.ValidateAll() if the designated constraints aren't met. -type ProjectTeamMultiError []error +// ProjectUserGroupMultiError is an error wrapping multiple validation errors +// returned by ProjectUserGroup.ValidateAll() if the designated constraints +// aren't met. +type ProjectUserGroupMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ProjectTeamMultiError) Error() string { +func (m ProjectUserGroupMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -815,11 +816,11 @@ func (m ProjectTeamMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ProjectTeamMultiError) AllErrors() []error { return m } +func (m ProjectUserGroupMultiError) AllErrors() []error { return m } -// ProjectTeamValidationError is the validation error returned by -// ProjectTeam.Validate if the designated constraints aren't met. -type ProjectTeamValidationError struct { +// ProjectUserGroupValidationError is the validation error returned by +// ProjectUserGroup.Validate if the designated constraints aren't met. +type ProjectUserGroupValidationError struct { field string reason string cause error @@ -827,22 +828,22 @@ type ProjectTeamValidationError struct { } // Field function returns field value. -func (e ProjectTeamValidationError) Field() string { return e.field } +func (e ProjectUserGroupValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ProjectTeamValidationError) Reason() string { return e.reason } +func (e ProjectUserGroupValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ProjectTeamValidationError) Cause() error { return e.cause } +func (e ProjectUserGroupValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ProjectTeamValidationError) Key() bool { return e.key } +func (e ProjectUserGroupValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ProjectTeamValidationError) ErrorName() string { return "ProjectTeamValidationError" } +func (e ProjectUserGroupValidationError) ErrorName() string { return "ProjectUserGroupValidationError" } // Error satisfies the builtin error interface -func (e ProjectTeamValidationError) Error() string { +func (e ProjectUserGroupValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -854,14 +855,14 @@ func (e ProjectTeamValidationError) Error() string { } return fmt.Sprintf( - "invalid %sProjectTeam.%s: %s%s", + "invalid %sProjectUserGroup.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ProjectTeamValidationError{} +var _ error = ProjectUserGroupValidationError{} var _ interface { Field() string @@ -869,7 +870,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ProjectTeamValidationError{} +} = ProjectUserGroupValidationError{} // Validate checks the field values on ProjectRBACRole with the rules defined // in the proto definition for this message. If any rules are violated, the @@ -1016,31 +1017,31 @@ var _ interface { ErrorName() string } = ProjectRBACRoleValidationError{} -// Validate checks the field values on ProjectRBACPolicy with the rules defined -// in the proto definition for this message. If any rules are violated, the -// first error encountered is returned, or nil if there are no violations. -func (m *ProjectRBACPolicy) Validate() error { +// Validate checks the field values on ProjectRBACResource with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ProjectRBACResource) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ProjectRBACPolicy with the rules +// ValidateAll checks the field values on ProjectRBACResource with the rules // defined in the proto definition for this message. If any rules are // violated, the result is a list of violation errors wrapped in -// ProjectRBACPolicyMultiError, or nil if none found. -func (m *ProjectRBACPolicy) ValidateAll() error { +// ProjectRBACResourceMultiError, or nil if none found. +func (m *ProjectRBACResource) ValidateAll() error { return m.validate(true) } -func (m *ProjectRBACPolicy) validate(all bool) error { +func (m *ProjectRBACResource) validate(all bool) error { if m == nil { return nil } var errors []error - if _, ok := ProjectRBACPolicy_ResourceType_name[int32(m.GetResourceType())]; !ok { - err := ProjectRBACPolicyValidationError{ - field: "ResourceType", + if _, ok := ProjectRBACResource_ResourceType_name[int32(m.GetType())]; !ok { + err := ProjectRBACResourceValidationError{ + field: "Type", reason: "value must be one of the defined enum values", } if !all { @@ -1049,20 +1050,178 @@ func (m *ProjectRBACPolicy) validate(all bool) error { errors = append(errors, err) } - if _, ok := ProjectRBACPolicy_ActionType_name[int32(m.GetActionType())]; !ok { - err := ProjectRBACPolicyValidationError{ - field: "ActionType", - reason: "value must be one of the defined enum values", + { + sorted_keys := make([]string, len(m.GetLabels())) + i := 0 + for key := range m.GetLabels() { + sorted_keys[i] = key + i++ } - if !all { - return err + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetLabels()[key] + _ = val + + if utf8.RuneCountInString(key) < 1 { + err := ProjectRBACResourceValidationError{ + field: fmt.Sprintf("Labels[%v]", key), + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(val) < 1 { + err := ProjectRBACResourceValidationError{ + field: fmt.Sprintf("Labels[%v]", key), + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + } - errors = append(errors, err) } - // no validation rules for LabelKey + if len(errors) > 0 { + return ProjectRBACResourceMultiError(errors) + } + + return nil +} + +// ProjectRBACResourceMultiError is an error wrapping multiple validation +// errors returned by ProjectRBACResource.ValidateAll() if the designated +// constraints aren't met. +type ProjectRBACResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectRBACResourceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectRBACResourceMultiError) AllErrors() []error { return m } + +// ProjectRBACResourceValidationError is the validation error returned by +// ProjectRBACResource.Validate if the designated constraints aren't met. +type ProjectRBACResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ProjectRBACResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ProjectRBACResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ProjectRBACResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ProjectRBACResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ProjectRBACResourceValidationError) ErrorName() string { + return "ProjectRBACResourceValidationError" +} + +// Error satisfies the builtin error interface +func (e ProjectRBACResourceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProjectRBACResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ProjectRBACResourceValidationError{} - // no validation rules for LabelValue +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ProjectRBACResourceValidationError{} + +// Validate checks the field values on ProjectRBACPolicy with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ProjectRBACPolicy) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProjectRBACPolicy with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProjectRBACPolicyMultiError, or nil if none found. +func (m *ProjectRBACPolicy) ValidateAll() error { + return m.validate(true) +} + +func (m *ProjectRBACPolicy) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectRBACPolicyValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectRBACPolicyValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ProjectRBACPolicyValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } if len(errors) > 0 { return ProjectRBACPolicyMultiError(errors) diff --git a/pkg/model/project.proto b/pkg/model/project.proto index 0620559599..59c41ed33f 100644 --- a/pkg/model/project.proto +++ b/pkg/model/project.proto @@ -49,8 +49,8 @@ message Project { // RBAC roles for this project. repeated ProjectRBACRole rbac_roles = 9; - // Teams for this project. - repeated ProjectTeam teams = 10; + // Mapping SSO group and RBAC role. + repeated ProjectUserGroup user_groups = 10; // Unix time when the project is created. int64 created_at = 14 [(validate.rules).int64.gt = 0]; @@ -106,12 +106,12 @@ message ProjectRBACConfig { string viewer = 3; } -// ProjectTeam represents a team. -message ProjectTeam { - // The name of team. - string name = 1 [(validate.rules).string.min_len = 1]; +// ProjectUserGroup represents a user group. +message ProjectUserGroup { + // The name of sso group. + string sso_group = 1 [(validate.rules).string.min_len = 1]; // The name of rbac role. - string role_name = 2 [(validate.rules).string.min_len = 1]; + string role = 2 [(validate.rules).string.min_len = 1]; } // ProjectRBACRole represents a RBAC role. @@ -122,19 +122,27 @@ message ProjectRBACRole { repeated ProjectRBACPolicy policy = 2; } -message ProjectRBACPolicy { +// ProjectResource represents a RBAC resource. +message ProjectRBACResource { enum ResourceType { APPLICATION = 0; DEPLOYMENT = 1; EVENT = 2; PIPED = 3; - DEPLOYMENTCHAIN = 4; + DEPLOYMENT_CHAIN = 4; PROJECT = 5; - APIKEY = 6; + API_KEY = 6; INSIGHT = 7; } - enum ActionType { + // The type of resource. + ResourceType type = 1 [(validate.rules).enum.defined_only = true]; + // Custom attributes to identify resource. + map labels = 2 [(validate.rules).map.keys.string.min_len = 1, (validate.rules).map.values.string.min_len = 1]; +} + +message ProjectRBACPolicy { + enum Action { GET = 0; LIST = 1; CREATE = 2; @@ -142,12 +150,8 @@ message ProjectRBACPolicy { DELETE = 4; } - // The type of resource. - ResourceType resource_type = 1 [(validate.rules).enum.defined_only = true]; - // The type of action. - ActionType action_type = 2 [(validate.rules).enum.defined_only = true]; - // The key of resource label. - string label_key = 3; - // The value of resource label. - string label_value = 4; + // The resources of this project. + repeated ProjectRBACResource resources = 1; + // The types of action. + repeated Action actions = 2; } diff --git a/web/model/project_pb.d.ts b/web/model/project_pb.d.ts index 19cca7246a..ee07029f0f 100644 --- a/web/model/project_pb.d.ts +++ b/web/model/project_pb.d.ts @@ -39,10 +39,10 @@ export class Project extends jspb.Message { clearRbacRolesList(): Project; addRbacRoles(value?: ProjectRBACRole, index?: number): ProjectRBACRole; - getTeamsList(): Array; - setTeamsList(value: Array): Project; - clearTeamsList(): Project; - addTeams(value?: ProjectTeam, index?: number): ProjectTeam; + getUserGroupsList(): Array; + setUserGroupsList(value: Array): Project; + clearUserGroupsList(): Project; + addUserGroups(value?: ProjectUserGroup, index?: number): ProjectUserGroup; getCreatedAt(): number; setCreatedAt(value: number): Project; @@ -69,7 +69,7 @@ export namespace Project { sharedSsoName: string, allowStrayAsViewer: boolean, rbacRolesList: Array, - teamsList: Array, + userGroupsList: Array, createdAt: number, updatedAt: number, } @@ -217,25 +217,25 @@ export namespace ProjectRBACConfig { } } -export class ProjectTeam extends jspb.Message { - getName(): string; - setName(value: string): ProjectTeam; +export class ProjectUserGroup extends jspb.Message { + getSsoGroup(): string; + setSsoGroup(value: string): ProjectUserGroup; - getRoleName(): string; - setRoleName(value: string): ProjectTeam; + getRole(): string; + setRole(value: string): ProjectUserGroup; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ProjectTeam.AsObject; - static toObject(includeInstance: boolean, msg: ProjectTeam): ProjectTeam.AsObject; - static serializeBinaryToWriter(message: ProjectTeam, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ProjectTeam; - static deserializeBinaryFromReader(message: ProjectTeam, reader: jspb.BinaryReader): ProjectTeam; + toObject(includeInstance?: boolean): ProjectUserGroup.AsObject; + static toObject(includeInstance: boolean, msg: ProjectUserGroup): ProjectUserGroup.AsObject; + static serializeBinaryToWriter(message: ProjectUserGroup, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectUserGroup; + static deserializeBinaryFromReader(message: ProjectUserGroup, reader: jspb.BinaryReader): ProjectUserGroup; } -export namespace ProjectTeam { +export namespace ProjectUserGroup { export type AsObject = { - name: string, - roleName: string, + ssoGroup: string, + role: string, } } @@ -263,33 +263,25 @@ export namespace ProjectRBACRole { } } -export class ProjectRBACPolicy extends jspb.Message { - getResourceType(): ProjectRBACPolicy.ResourceType; - setResourceType(value: ProjectRBACPolicy.ResourceType): ProjectRBACPolicy; - - getActionType(): ProjectRBACPolicy.ActionType; - setActionType(value: ProjectRBACPolicy.ActionType): ProjectRBACPolicy; +export class ProjectRBACResource extends jspb.Message { + getType(): ProjectRBACResource.ResourceType; + setType(value: ProjectRBACResource.ResourceType): ProjectRBACResource; - getLabelKey(): string; - setLabelKey(value: string): ProjectRBACPolicy; - - getLabelValue(): string; - setLabelValue(value: string): ProjectRBACPolicy; + getLabelsMap(): jspb.Map; + clearLabelsMap(): ProjectRBACResource; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ProjectRBACPolicy.AsObject; - static toObject(includeInstance: boolean, msg: ProjectRBACPolicy): ProjectRBACPolicy.AsObject; - static serializeBinaryToWriter(message: ProjectRBACPolicy, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ProjectRBACPolicy; - static deserializeBinaryFromReader(message: ProjectRBACPolicy, reader: jspb.BinaryReader): ProjectRBACPolicy; + toObject(includeInstance?: boolean): ProjectRBACResource.AsObject; + static toObject(includeInstance: boolean, msg: ProjectRBACResource): ProjectRBACResource.AsObject; + static serializeBinaryToWriter(message: ProjectRBACResource, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectRBACResource; + static deserializeBinaryFromReader(message: ProjectRBACResource, reader: jspb.BinaryReader): ProjectRBACResource; } -export namespace ProjectRBACPolicy { +export namespace ProjectRBACResource { export type AsObject = { - resourceType: ProjectRBACPolicy.ResourceType, - actionType: ProjectRBACPolicy.ActionType, - labelKey: string, - labelValue: string, + type: ProjectRBACResource.ResourceType, + labelsMap: Array<[string, string]>, } export enum ResourceType { @@ -297,13 +289,39 @@ export namespace ProjectRBACPolicy { DEPLOYMENT = 1, EVENT = 2, PIPED = 3, - DEPLOYMENTCHAIN = 4, + DEPLOYMENT_CHAIN = 4, PROJECT = 5, - APIKEY = 6, + API_KEY = 6, INSIGHT = 7, } +} + +export class ProjectRBACPolicy extends jspb.Message { + getResourcesList(): Array; + setResourcesList(value: Array): ProjectRBACPolicy; + clearResourcesList(): ProjectRBACPolicy; + addResources(value?: ProjectRBACResource, index?: number): ProjectRBACResource; + + getActionsList(): Array; + setActionsList(value: Array): ProjectRBACPolicy; + clearActionsList(): ProjectRBACPolicy; + addActions(value: ProjectRBACPolicy.Action, index?: number): ProjectRBACPolicy; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ProjectRBACPolicy.AsObject; + static toObject(includeInstance: boolean, msg: ProjectRBACPolicy): ProjectRBACPolicy.AsObject; + static serializeBinaryToWriter(message: ProjectRBACPolicy, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ProjectRBACPolicy; + static deserializeBinaryFromReader(message: ProjectRBACPolicy, reader: jspb.BinaryReader): ProjectRBACPolicy; +} + +export namespace ProjectRBACPolicy { + export type AsObject = { + resourcesList: Array, + actionsList: Array, + } - export enum ActionType { + export enum Action { GET = 0, LIST = 1, CREATE = 2, diff --git a/web/model/project_pb.js b/web/model/project_pb.js index 74e3c20d96..73226059cd 100644 --- a/web/model/project_pb.js +++ b/web/model/project_pb.js @@ -26,15 +26,16 @@ var global = (function() { goog.exportSymbol('proto.model.Project', null, global); goog.exportSymbol('proto.model.ProjectRBACConfig', null, global); goog.exportSymbol('proto.model.ProjectRBACPolicy', null, global); -goog.exportSymbol('proto.model.ProjectRBACPolicy.ActionType', null, global); -goog.exportSymbol('proto.model.ProjectRBACPolicy.ResourceType', null, global); +goog.exportSymbol('proto.model.ProjectRBACPolicy.Action', null, global); +goog.exportSymbol('proto.model.ProjectRBACResource', null, global); +goog.exportSymbol('proto.model.ProjectRBACResource.ResourceType', null, global); goog.exportSymbol('proto.model.ProjectRBACRole', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.GitHub', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.Google', null, global); goog.exportSymbol('proto.model.ProjectSSOConfig.Provider', null, global); goog.exportSymbol('proto.model.ProjectStaticUser', null, global); -goog.exportSymbol('proto.model.ProjectTeam', null, global); +goog.exportSymbol('proto.model.ProjectUserGroup', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -171,16 +172,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.model.ProjectTeam = function(opt_data) { +proto.model.ProjectUserGroup = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.model.ProjectTeam, jspb.Message); +goog.inherits(proto.model.ProjectUserGroup, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.model.ProjectTeam.displayName = 'proto.model.ProjectTeam'; + proto.model.ProjectUserGroup.displayName = 'proto.model.ProjectUserGroup'; } /** * Generated by JsPbCodeGenerator. @@ -213,9 +214,30 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.model.ProjectRBACPolicy = function(opt_data) { +proto.model.ProjectRBACResource = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; +goog.inherits(proto.model.ProjectRBACResource, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.model.ProjectRBACResource.displayName = 'proto.model.ProjectRBACResource'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.model.ProjectRBACPolicy = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.model.ProjectRBACPolicy.repeatedFields_, null); +}; goog.inherits(proto.model.ProjectRBACPolicy, jspb.Message); if (goog.DEBUG && !COMPILED) { /** @@ -273,8 +295,8 @@ proto.model.Project.toObject = function(includeInstance, msg) { allowStrayAsViewer: jspb.Message.getBooleanFieldWithDefault(msg, 8, false), rbacRolesList: jspb.Message.toObjectList(msg.getRbacRolesList(), proto.model.ProjectRBACRole.toObject, includeInstance), - teamsList: jspb.Message.toObjectList(msg.getTeamsList(), - proto.model.ProjectTeam.toObject, includeInstance), + userGroupsList: jspb.Message.toObjectList(msg.getUserGroupsList(), + proto.model.ProjectUserGroup.toObject, includeInstance), createdAt: jspb.Message.getFieldWithDefault(msg, 14, 0), updatedAt: jspb.Message.getFieldWithDefault(msg, 15, 0) }; @@ -354,9 +376,9 @@ proto.model.Project.deserializeBinaryFromReader = function(msg, reader) { msg.addRbacRoles(value); break; case 10: - var value = new proto.model.ProjectTeam; - reader.readMessage(value,proto.model.ProjectTeam.deserializeBinaryFromReader); - msg.addTeams(value); + var value = new proto.model.ProjectUserGroup; + reader.readMessage(value,proto.model.ProjectUserGroup.deserializeBinaryFromReader); + msg.addUserGroups(value); break; case 14: var value = /** @type {number} */ (reader.readInt64()); @@ -462,12 +484,12 @@ proto.model.Project.serializeBinaryToWriter = function(message, writer) { proto.model.ProjectRBACRole.serializeBinaryToWriter ); } - f = message.getTeamsList(); + f = message.getUserGroupsList(); if (f.length > 0) { writer.writeRepeatedMessage( 10, f, - proto.model.ProjectTeam.serializeBinaryToWriter + proto.model.ProjectUserGroup.serializeBinaryToWriter ); } f = message.getCreatedAt(); @@ -727,31 +749,31 @@ proto.model.Project.prototype.clearRbacRolesList = function() { /** - * repeated ProjectTeam teams = 10; - * @return {!Array} + * repeated ProjectUserGroup user_groups = 10; + * @return {!Array} */ -proto.model.Project.prototype.getTeamsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectTeam, 10)); +proto.model.Project.prototype.getUserGroupsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectUserGroup, 10)); }; /** - * @param {!Array} value + * @param {!Array} value * @return {!proto.model.Project} returns this */ -proto.model.Project.prototype.setTeamsList = function(value) { +proto.model.Project.prototype.setUserGroupsList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 10, value); }; /** - * @param {!proto.model.ProjectTeam=} opt_value + * @param {!proto.model.ProjectUserGroup=} opt_value * @param {number=} opt_index - * @return {!proto.model.ProjectTeam} + * @return {!proto.model.ProjectUserGroup} */ -proto.model.Project.prototype.addTeams = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 10, opt_value, proto.model.ProjectTeam, opt_index); +proto.model.Project.prototype.addUserGroups = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 10, opt_value, proto.model.ProjectUserGroup, opt_index); }; @@ -759,8 +781,8 @@ proto.model.Project.prototype.addTeams = function(opt_value, opt_index) { * Clears the list making it empty but non-null. * @return {!proto.model.Project} returns this */ -proto.model.Project.prototype.clearTeamsList = function() { - return this.setTeamsList([]); +proto.model.Project.prototype.clearUserGroupsList = function() { + return this.setUserGroupsList([]); }; @@ -1817,8 +1839,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.model.ProjectTeam.prototype.toObject = function(opt_includeInstance) { - return proto.model.ProjectTeam.toObject(opt_includeInstance, this); +proto.model.ProjectUserGroup.prototype.toObject = function(opt_includeInstance) { + return proto.model.ProjectUserGroup.toObject(opt_includeInstance, this); }; @@ -1827,14 +1849,14 @@ proto.model.ProjectTeam.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.model.ProjectTeam} msg The msg instance to transform. + * @param {!proto.model.ProjectUserGroup} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.model.ProjectTeam.toObject = function(includeInstance, msg) { +proto.model.ProjectUserGroup.toObject = function(includeInstance, msg) { var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), - roleName: jspb.Message.getFieldWithDefault(msg, 2, "") + ssoGroup: jspb.Message.getFieldWithDefault(msg, 1, ""), + role: jspb.Message.getFieldWithDefault(msg, 2, "") }; if (includeInstance) { @@ -1848,23 +1870,23 @@ proto.model.ProjectTeam.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.model.ProjectTeam} + * @return {!proto.model.ProjectUserGroup} */ -proto.model.ProjectTeam.deserializeBinary = function(bytes) { +proto.model.ProjectUserGroup.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.model.ProjectTeam; - return proto.model.ProjectTeam.deserializeBinaryFromReader(msg, reader); + var msg = new proto.model.ProjectUserGroup; + return proto.model.ProjectUserGroup.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.model.ProjectTeam} msg The message object to deserialize into. + * @param {!proto.model.ProjectUserGroup} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.model.ProjectTeam} + * @return {!proto.model.ProjectUserGroup} */ -proto.model.ProjectTeam.deserializeBinaryFromReader = function(msg, reader) { +proto.model.ProjectUserGroup.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1873,11 +1895,11 @@ proto.model.ProjectTeam.deserializeBinaryFromReader = function(msg, reader) { switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); - msg.setName(value); + msg.setSsoGroup(value); break; case 2: var value = /** @type {string} */ (reader.readString()); - msg.setRoleName(value); + msg.setRole(value); break; default: reader.skipField(); @@ -1892,9 +1914,9 @@ proto.model.ProjectTeam.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.model.ProjectTeam.prototype.serializeBinary = function() { +proto.model.ProjectUserGroup.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.model.ProjectTeam.serializeBinaryToWriter(this, writer); + proto.model.ProjectUserGroup.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1902,20 +1924,20 @@ proto.model.ProjectTeam.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.model.ProjectTeam} message + * @param {!proto.model.ProjectUserGroup} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.model.ProjectTeam.serializeBinaryToWriter = function(message, writer) { +proto.model.ProjectUserGroup.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getName(); + f = message.getSsoGroup(); if (f.length > 0) { writer.writeString( 1, f ); } - f = message.getRoleName(); + f = message.getRole(); if (f.length > 0) { writer.writeString( 2, @@ -1926,37 +1948,37 @@ proto.model.ProjectTeam.serializeBinaryToWriter = function(message, writer) { /** - * optional string name = 1; + * optional string sso_group = 1; * @return {string} */ -proto.model.ProjectTeam.prototype.getName = function() { +proto.model.ProjectUserGroup.prototype.getSsoGroup = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value - * @return {!proto.model.ProjectTeam} returns this + * @return {!proto.model.ProjectUserGroup} returns this */ -proto.model.ProjectTeam.prototype.setName = function(value) { +proto.model.ProjectUserGroup.prototype.setSsoGroup = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** - * optional string role_name = 2; + * optional string role = 2; * @return {string} */ -proto.model.ProjectTeam.prototype.getRoleName = function() { +proto.model.ProjectUserGroup.prototype.getRole = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value - * @return {!proto.model.ProjectTeam} returns this + * @return {!proto.model.ProjectUserGroup} returns this */ -proto.model.ProjectTeam.prototype.setRoleName = function(value) { +proto.model.ProjectUserGroup.prototype.setRole = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; @@ -2154,6 +2176,190 @@ proto.model.ProjectRBACRole.prototype.clearPolicyList = function() { +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.model.ProjectRBACResource.prototype.toObject = function(opt_includeInstance) { + return proto.model.ProjectRBACResource.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.model.ProjectRBACResource} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACResource.toObject = function(includeInstance, msg) { + var f, obj = { + type: jspb.Message.getFieldWithDefault(msg, 1, 0), + labelsMap: (f = msg.getLabelsMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.model.ProjectRBACResource} + */ +proto.model.ProjectRBACResource.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.model.ProjectRBACResource; + return proto.model.ProjectRBACResource.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.model.ProjectRBACResource} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.model.ProjectRBACResource} + */ +proto.model.ProjectRBACResource.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.model.ProjectRBACResource.ResourceType} */ (reader.readEnum()); + msg.setType(value); + break; + case 2: + var value = msg.getLabelsMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.model.ProjectRBACResource.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.model.ProjectRBACResource.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.model.ProjectRBACResource} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.model.ProjectRBACResource.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getType(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getLabelsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * @enum {number} + */ +proto.model.ProjectRBACResource.ResourceType = { + APPLICATION: 0, + DEPLOYMENT: 1, + EVENT: 2, + PIPED: 3, + DEPLOYMENT_CHAIN: 4, + PROJECT: 5, + API_KEY: 6, + INSIGHT: 7 +}; + +/** + * optional ResourceType type = 1; + * @return {!proto.model.ProjectRBACResource.ResourceType} + */ +proto.model.ProjectRBACResource.prototype.getType = function() { + return /** @type {!proto.model.ProjectRBACResource.ResourceType} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.model.ProjectRBACResource.ResourceType} value + * @return {!proto.model.ProjectRBACResource} returns this + */ +proto.model.ProjectRBACResource.prototype.setType = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * map labels = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.model.ProjectRBACResource.prototype.getLabelsMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.model.ProjectRBACResource} returns this + */ +proto.model.ProjectRBACResource.prototype.clearLabelsMap = function() { + this.getLabelsMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.model.ProjectRBACPolicy.repeatedFields_ = [1,2]; + + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -2183,10 +2389,9 @@ proto.model.ProjectRBACPolicy.prototype.toObject = function(opt_includeInstance) */ proto.model.ProjectRBACPolicy.toObject = function(includeInstance, msg) { var f, obj = { - resourceType: jspb.Message.getFieldWithDefault(msg, 1, 0), - actionType: jspb.Message.getFieldWithDefault(msg, 2, 0), - labelKey: jspb.Message.getFieldWithDefault(msg, 3, ""), - labelValue: jspb.Message.getFieldWithDefault(msg, 4, "") + resourcesList: jspb.Message.toObjectList(msg.getResourcesList(), + proto.model.ProjectRBACResource.toObject, includeInstance), + actionsList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f }; if (includeInstance) { @@ -2224,20 +2429,15 @@ proto.model.ProjectRBACPolicy.deserializeBinaryFromReader = function(msg, reader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!proto.model.ProjectRBACPolicy.ResourceType} */ (reader.readEnum()); - msg.setResourceType(value); + var value = new proto.model.ProjectRBACResource; + reader.readMessage(value,proto.model.ProjectRBACResource.deserializeBinaryFromReader); + msg.addResources(value); break; case 2: - var value = /** @type {!proto.model.ProjectRBACPolicy.ActionType} */ (reader.readEnum()); - msg.setActionType(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setLabelKey(value); - break; - case 4: - var value = /** @type {string} */ (reader.readString()); - msg.setLabelValue(value); + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]); + for (var i = 0; i < values.length; i++) { + msg.addActions(values[i]); + } break; default: reader.skipField(); @@ -2268,31 +2468,18 @@ proto.model.ProjectRBACPolicy.prototype.serializeBinary = function() { */ proto.model.ProjectRBACPolicy.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getResourceType(); - if (f !== 0.0) { - writer.writeEnum( - 1, - f - ); - } - f = message.getActionType(); - if (f !== 0.0) { - writer.writeEnum( - 2, - f - ); - } - f = message.getLabelKey(); + f = message.getResourcesList(); if (f.length > 0) { - writer.writeString( - 3, - f + writer.writeRepeatedMessage( + 1, + f, + proto.model.ProjectRBACResource.serializeBinaryToWriter ); } - f = message.getLabelValue(); + f = message.getActionsList(); if (f.length > 0) { - writer.writeString( - 4, + writer.writePackedEnum( + 2, f ); } @@ -2302,21 +2489,7 @@ proto.model.ProjectRBACPolicy.serializeBinaryToWriter = function(message, writer /** * @enum {number} */ -proto.model.ProjectRBACPolicy.ResourceType = { - APPLICATION: 0, - DEPLOYMENT: 1, - EVENT: 2, - PIPED: 3, - DEPLOYMENTCHAIN: 4, - PROJECT: 5, - APIKEY: 6, - INSIGHT: 7 -}; - -/** - * @enum {number} - */ -proto.model.ProjectRBACPolicy.ActionType = { +proto.model.ProjectRBACPolicy.Action = { GET: 0, LIST: 1, CREATE: 2, @@ -2325,74 +2498,77 @@ proto.model.ProjectRBACPolicy.ActionType = { }; /** - * optional ResourceType resource_type = 1; - * @return {!proto.model.ProjectRBACPolicy.ResourceType} + * repeated ProjectRBACResource resources = 1; + * @return {!Array} */ -proto.model.ProjectRBACPolicy.prototype.getResourceType = function() { - return /** @type {!proto.model.ProjectRBACPolicy.ResourceType} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +proto.model.ProjectRBACPolicy.prototype.getResourcesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.model.ProjectRBACResource, 1)); }; /** - * @param {!proto.model.ProjectRBACPolicy.ResourceType} value + * @param {!Array} value * @return {!proto.model.ProjectRBACPolicy} returns this - */ -proto.model.ProjectRBACPolicy.prototype.setResourceType = function(value) { - return jspb.Message.setProto3EnumField(this, 1, value); +*/ +proto.model.ProjectRBACPolicy.prototype.setResourcesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * optional ActionType action_type = 2; - * @return {!proto.model.ProjectRBACPolicy.ActionType} + * @param {!proto.model.ProjectRBACResource=} opt_value + * @param {number=} opt_index + * @return {!proto.model.ProjectRBACResource} */ -proto.model.ProjectRBACPolicy.prototype.getActionType = function() { - return /** @type {!proto.model.ProjectRBACPolicy.ActionType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.model.ProjectRBACPolicy.prototype.addResources = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.model.ProjectRBACResource, opt_index); }; /** - * @param {!proto.model.ProjectRBACPolicy.ActionType} value + * Clears the list making it empty but non-null. * @return {!proto.model.ProjectRBACPolicy} returns this */ -proto.model.ProjectRBACPolicy.prototype.setActionType = function(value) { - return jspb.Message.setProto3EnumField(this, 2, value); +proto.model.ProjectRBACPolicy.prototype.clearResourcesList = function() { + return this.setResourcesList([]); }; /** - * optional string label_key = 3; - * @return {string} + * repeated Action actions = 2; + * @return {!Array} */ -proto.model.ProjectRBACPolicy.prototype.getLabelKey = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.model.ProjectRBACPolicy.prototype.getActionsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); }; /** - * @param {string} value + * @param {!Array} value * @return {!proto.model.ProjectRBACPolicy} returns this */ -proto.model.ProjectRBACPolicy.prototype.setLabelKey = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.model.ProjectRBACPolicy.prototype.setActionsList = function(value) { + return jspb.Message.setField(this, 2, value || []); }; /** - * optional string label_value = 4; - * @return {string} + * @param {!proto.model.ProjectRBACPolicy.Action} value + * @param {number=} opt_index + * @return {!proto.model.ProjectRBACPolicy} returns this */ -proto.model.ProjectRBACPolicy.prototype.getLabelValue = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +proto.model.ProjectRBACPolicy.prototype.addActions = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); }; /** - * @param {string} value + * Clears the list making it empty but non-null. * @return {!proto.model.ProjectRBACPolicy} returns this */ -proto.model.ProjectRBACPolicy.prototype.setLabelValue = function(value) { - return jspb.Message.setProto3StringField(this, 4, value); +proto.model.ProjectRBACPolicy.prototype.clearActionsList = function() { + return this.setActionsList([]); }; diff --git a/web/src/__fixtures__/dummy-project.ts b/web/src/__fixtures__/dummy-project.ts index c23d2ab085..d477c6b61e 100644 --- a/web/src/__fixtures__/dummy-project.ts +++ b/web/src/__fixtures__/dummy-project.ts @@ -26,7 +26,7 @@ export const dummyProject: Project.AsObject = { viewer: "viewer-team", }, rbacRolesList: [], - teamsList: [], + userGroupsList: [], staticAdmin: { username: "static-admin-user", passwordHash: randomKeyHash(),