diff --git a/api/go/gosdn/plugin-internal/plugin-internal.pb.go b/api/go/gosdn/plugin-internal/plugin-internal.pb.go index e935ccf3d32c240ed31368036d24887bbeb6b709..a52b2b6d07fba3d9db0ef0d3e48473457baac46c 100644 --- a/api/go/gosdn/plugin-internal/plugin-internal.pb.go +++ b/api/go/gosdn/plugin-internal/plugin-internal.pb.go @@ -123,7 +123,7 @@ func (x *GetAvailablePluginsResponse) GetPlugins() []*plugin_registry.Plugin { return nil } -type PluginSchemaRequest struct { +type GetPluginSchemaRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -132,8 +132,8 @@ type PluginSchemaRequest struct { Pid string `protobuf:"bytes,2,opt,name=pid,proto3" json:"pid,omitempty"` } -func (x *PluginSchemaRequest) Reset() { - *x = PluginSchemaRequest{} +func (x *GetPluginSchemaRequest) Reset() { + *x = GetPluginSchemaRequest{} if protoimpl.UnsafeEnabled { mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -141,13 +141,13 @@ func (x *PluginSchemaRequest) Reset() { } } -func (x *PluginSchemaRequest) String() string { +func (x *GetPluginSchemaRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PluginSchemaRequest) ProtoMessage() {} +func (*GetPluginSchemaRequest) ProtoMessage() {} -func (x *PluginSchemaRequest) ProtoReflect() protoreflect.Message { +func (x *GetPluginSchemaRequest) ProtoReflect() protoreflect.Message { mi := &file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -159,19 +159,19 @@ func (x *PluginSchemaRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PluginSchemaRequest.ProtoReflect.Descriptor instead. -func (*PluginSchemaRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPluginSchemaRequest.ProtoReflect.Descriptor instead. +func (*GetPluginSchemaRequest) Descriptor() ([]byte, []int) { return file_gosdn_plugin_internal_plugin_internal_proto_rawDescGZIP(), []int{2} } -func (x *PluginSchemaRequest) GetTimestamp() int64 { +func (x *GetPluginSchemaRequest) GetTimestamp() int64 { if x != nil { return x.Timestamp } return 0 } -func (x *PluginSchemaRequest) GetPid() string { +func (x *GetPluginSchemaRequest) GetPid() string { if x != nil { return x.Pid } @@ -246,33 +246,34 @@ var file_gosdn_plugin_internal_plugin_internal_proto_rawDesc = []byte{ 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x73, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x13, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xec, 0x01, 0x0a, 0x15, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x69, 0x0a, 0x10, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x31, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x47, 0x65, - 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, - 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0c, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x2a, 0x2e, 0x67, - 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, + 0x69, 0x6e, 0x73, 0x22, 0x48, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x2b, 0x0a, + 0x13, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xf2, 0x01, 0x0a, 0x15, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x69, 0x0a, 0x10, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, + 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x31, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x42, 0x3b, 0x5a, 0x39, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, - 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, - 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f, - 0x73, 0x64, 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x67, 0x6f, + 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x6e, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x12, 0x2d, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2a, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x42, + 0x3b, 0x5a, 0x39, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, + 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -291,7 +292,7 @@ var file_gosdn_plugin_internal_plugin_internal_proto_msgTypes = make([]protoimpl var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{ (*GetAvailablePluginsRequest)(nil), // 0: gosdn.plugin_internal.GetAvailablePluginsRequest (*GetAvailablePluginsResponse)(nil), // 1: gosdn.plugin_internal.GetAvailablePluginsResponse - (*PluginSchemaRequest)(nil), // 2: gosdn.plugin_internal.PluginSchemaRequest + (*GetPluginSchemaRequest)(nil), // 2: gosdn.plugin_internal.GetPluginSchemaRequest (*PluginSchemaPayload)(nil), // 3: gosdn.plugin_internal.PluginSchemaPayload (*plugin_registry.Plugin)(nil), // 4: gosdn.plugin_registry.Plugin (*plugin_registry.GetResponse)(nil), // 5: gosdn.plugin_registry.GetResponse @@ -299,9 +300,9 @@ var file_gosdn_plugin_internal_plugin_internal_proto_goTypes = []interface{}{ var file_gosdn_plugin_internal_plugin_internal_proto_depIdxs = []int32{ 4, // 0: gosdn.plugin_internal.GetAvailablePluginsResponse.plugins:type_name -> gosdn.plugin_registry.Plugin 0, // 1: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:input_type -> gosdn.plugin_internal.GetAvailablePluginsRequest - 2, // 2: gosdn.plugin_internal.PluginInternalService.PluginSchema:input_type -> gosdn.plugin_internal.PluginSchemaRequest + 2, // 2: gosdn.plugin_internal.PluginInternalService.GetPluginSchema:input_type -> gosdn.plugin_internal.GetPluginSchemaRequest 5, // 3: gosdn.plugin_internal.PluginInternalService.AvailablePlugins:output_type -> gosdn.plugin_registry.GetResponse - 3, // 4: gosdn.plugin_internal.PluginInternalService.PluginSchema:output_type -> gosdn.plugin_internal.PluginSchemaPayload + 3, // 4: gosdn.plugin_internal.PluginInternalService.GetPluginSchema:output_type -> gosdn.plugin_internal.PluginSchemaPayload 3, // [3:5] is the sub-list for method output_type 1, // [1:3] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -340,7 +341,7 @@ func file_gosdn_plugin_internal_plugin_internal_proto_init() { } } file_gosdn_plugin_internal_plugin_internal_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PluginSchemaRequest); i { + switch v := v.(*GetPluginSchemaRequest); i { case 0: return &v.state case 1: diff --git a/api/go/gosdn/plugin-internal/plugin-internal_grpc.pb.go b/api/go/gosdn/plugin-internal/plugin-internal_grpc.pb.go index deee62b44574cbac99e05d38521bdd350996296b..48bebd8bfea9242bb871d0868b72207333059d48 100644 --- a/api/go/gosdn/plugin-internal/plugin-internal_grpc.pb.go +++ b/api/go/gosdn/plugin-internal/plugin-internal_grpc.pb.go @@ -20,7 +20,7 @@ const _ = grpc.SupportPackageIsVersion7 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type PluginInternalServiceClient interface { AvailablePlugins(ctx context.Context, in *GetAvailablePluginsRequest, opts ...grpc.CallOption) (*plugin_registry.GetResponse, error) - PluginSchema(ctx context.Context, in *PluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_PluginSchemaClient, error) + GetPluginSchema(ctx context.Context, in *GetPluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_GetPluginSchemaClient, error) } type pluginInternalServiceClient struct { @@ -40,12 +40,12 @@ func (c *pluginInternalServiceClient) AvailablePlugins(ctx context.Context, in * return out, nil } -func (c *pluginInternalServiceClient) PluginSchema(ctx context.Context, in *PluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_PluginSchemaClient, error) { - stream, err := c.cc.NewStream(ctx, &PluginInternalService_ServiceDesc.Streams[0], "/gosdn.plugin_internal.PluginInternalService/PluginSchema", opts...) +func (c *pluginInternalServiceClient) GetPluginSchema(ctx context.Context, in *GetPluginSchemaRequest, opts ...grpc.CallOption) (PluginInternalService_GetPluginSchemaClient, error) { + stream, err := c.cc.NewStream(ctx, &PluginInternalService_ServiceDesc.Streams[0], "/gosdn.plugin_internal.PluginInternalService/GetPluginSchema", opts...) if err != nil { return nil, err } - x := &pluginInternalServicePluginSchemaClient{stream} + x := &pluginInternalServiceGetPluginSchemaClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -55,16 +55,16 @@ func (c *pluginInternalServiceClient) PluginSchema(ctx context.Context, in *Plug return x, nil } -type PluginInternalService_PluginSchemaClient interface { +type PluginInternalService_GetPluginSchemaClient interface { Recv() (*PluginSchemaPayload, error) grpc.ClientStream } -type pluginInternalServicePluginSchemaClient struct { +type pluginInternalServiceGetPluginSchemaClient struct { grpc.ClientStream } -func (x *pluginInternalServicePluginSchemaClient) Recv() (*PluginSchemaPayload, error) { +func (x *pluginInternalServiceGetPluginSchemaClient) Recv() (*PluginSchemaPayload, error) { m := new(PluginSchemaPayload) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err @@ -77,7 +77,7 @@ func (x *pluginInternalServicePluginSchemaClient) Recv() (*PluginSchemaPayload, // for forward compatibility type PluginInternalServiceServer interface { AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error) - PluginSchema(*PluginSchemaRequest, PluginInternalService_PluginSchemaServer) error + GetPluginSchema(*GetPluginSchemaRequest, PluginInternalService_GetPluginSchemaServer) error mustEmbedUnimplementedPluginInternalServiceServer() } @@ -88,8 +88,8 @@ type UnimplementedPluginInternalServiceServer struct { func (UnimplementedPluginInternalServiceServer) AvailablePlugins(context.Context, *GetAvailablePluginsRequest) (*plugin_registry.GetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AvailablePlugins not implemented") } -func (UnimplementedPluginInternalServiceServer) PluginSchema(*PluginSchemaRequest, PluginInternalService_PluginSchemaServer) error { - return status.Errorf(codes.Unimplemented, "method PluginSchema not implemented") +func (UnimplementedPluginInternalServiceServer) GetPluginSchema(*GetPluginSchemaRequest, PluginInternalService_GetPluginSchemaServer) error { + return status.Errorf(codes.Unimplemented, "method GetPluginSchema not implemented") } func (UnimplementedPluginInternalServiceServer) mustEmbedUnimplementedPluginInternalServiceServer() {} @@ -122,24 +122,24 @@ func _PluginInternalService_AvailablePlugins_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } -func _PluginInternalService_PluginSchema_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(PluginSchemaRequest) +func _PluginInternalService_GetPluginSchema_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetPluginSchemaRequest) if err := stream.RecvMsg(m); err != nil { return err } - return srv.(PluginInternalServiceServer).PluginSchema(m, &pluginInternalServicePluginSchemaServer{stream}) + return srv.(PluginInternalServiceServer).GetPluginSchema(m, &pluginInternalServiceGetPluginSchemaServer{stream}) } -type PluginInternalService_PluginSchemaServer interface { +type PluginInternalService_GetPluginSchemaServer interface { Send(*PluginSchemaPayload) error grpc.ServerStream } -type pluginInternalServicePluginSchemaServer struct { +type pluginInternalServiceGetPluginSchemaServer struct { grpc.ServerStream } -func (x *pluginInternalServicePluginSchemaServer) Send(m *PluginSchemaPayload) error { +func (x *pluginInternalServiceGetPluginSchemaServer) Send(m *PluginSchemaPayload) error { return x.ServerStream.SendMsg(m) } @@ -157,8 +157,8 @@ var PluginInternalService_ServiceDesc = grpc.ServiceDesc{ }, Streams: []grpc.StreamDesc{ { - StreamName: "PluginSchema", - Handler: _PluginInternalService_PluginSchema_Handler, + StreamName: "GetPluginSchema", + Handler: _PluginInternalService_GetPluginSchema_Handler, ServerStreams: true, }, }, diff --git a/api/proto/gosdn/plugin-internal/plugin-internal.proto b/api/proto/gosdn/plugin-internal/plugin-internal.proto index 93d83bf891022dc0bd611ed3e4ee14ba2f98b80d..848a0996849260990a927c48857e14b9bc2103b8 100644 --- a/api/proto/gosdn/plugin-internal/plugin-internal.proto +++ b/api/proto/gosdn/plugin-internal/plugin-internal.proto @@ -8,7 +8,7 @@ option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-internal"; service PluginInternalService { rpc AvailablePlugins(GetAvailablePluginsRequest) returns (gosdn.plugin_registry.GetResponse); - rpc PluginSchema(PluginSchemaRequest) returns (stream PluginSchemaPayload); + rpc GetPluginSchema(GetPluginSchemaRequest) returns (stream PluginSchemaPayload); } message GetAvailablePluginsRequest { @@ -20,7 +20,7 @@ message GetAvailablePluginsResponse { repeated gosdn.plugin_registry.Plugin plugins = 2; } -message PluginSchemaRequest { +message GetPluginSchemaRequest { int64 timestamp = 1; string pid = 2; } diff --git a/controller/northbound/server/auth_interceptor_test.go b/controller/northbound/server/auth_interceptor_test.go index 8e33fafcc8234fe26b52a7ab96073df9051a68de..493e16ae27cb9a6b49689487bff0832deb2ba87b 100644 --- a/controller/northbound/server/auth_interceptor_test.go +++ b/controller/northbound/server/auth_interceptor_test.go @@ -14,8 +14,10 @@ import ( "code.fbi.h-da.de/danet/gosdn/controller/nucleus" "code.fbi.h-da.de/danet/gosdn/controller/rbac" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" ) @@ -178,6 +180,10 @@ func TestAuthInterceptor_Stream(t *testing.T) { if err != nil { t.Fatal(err) } + tokenWithMissingRights, err := createTestUserToken("testUser", true, authServer.userService, authServer.jwtManager) + if err != nil { + t.Fatal(err) + } ctx := context.Background() conn, err := grpc.DialContext( @@ -199,48 +205,74 @@ func TestAuthInterceptor_Stream(t *testing.T) { type args struct { ctx context.Context - request *pipb.PluginSchemaRequest + request *pipb.GetPluginSchemaRequest } tests := []struct { - name string - args args - want bool + name string + args args + statusCode codes.Code + wantErr bool }{ { name: "default stream interceptor", args: args{ ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", validToken)), - request: &pipb.PluginSchemaRequest{ + request: &pipb.GetPluginSchemaRequest{ + Pid: pluginID, + }, + }, + statusCode: codes.OK, + wantErr: false, + }, + { + name: "user without sufficient rights", + args: args{ + ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", tokenWithMissingRights)), + request: &pipb.GetPluginSchemaRequest{ Pid: pluginID, }, }, - want: true, + statusCode: codes.PermissionDenied, + wantErr: true, }, { - name: "error stream interceptor", + name: "user not authenticated", args: args{ ctx: metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorize", "foo")), - request: &pipb.PluginSchemaRequest{ + request: &pipb.GetPluginSchemaRequest{ Pid: pluginID, }, }, - want: false, + statusCode: codes.Unauthenticated, + wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := client.PluginSchema(tt.args.ctx, tt.args.request) + got, err := client.GetPluginSchema(tt.args.ctx, tt.args.request) if err != nil { t.Errorf("AuthInterceptor.Stream() = %v", err) return } - payload, err := got.Recv() - if (payload != nil) != tt.want { - t.Errorf("AuthInterceptor.Stream() = %v", tt.want) + _, err = got.Recv() + if (err != nil) != tt.wantErr { + t.Errorf("AuthInterceptor.Stream() = got error: %v, wantErr: %v", err, tt.wantErr) return } + + if tt.wantErr { + statusCode, ok := status.FromError(err) + if !ok { + t.Errorf("AuthInterceptor.Stream() = %v", err) + return + } + if statusCode.Code() != tt.statusCode { + t.Errorf("AuthInterceptor.Stream() = got error with status code: %v, want: %v", statusCode.Code(), tt.statusCode) + return + } + } }) } } diff --git a/controller/northbound/server/plugin.go b/controller/northbound/server/plugin.go index 8d9fd06aa0d6dce4a4d110e2de22c53e787895e1..7ccdaf2fd5a65d8f967fa8b27b767ade17b96788 100644 --- a/controller/northbound/server/plugin.go +++ b/controller/northbound/server/plugin.go @@ -12,6 +12,7 @@ import ( "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" "code.fbi.h-da.de/danet/gosdn/controller/metrics" "code.fbi.h-da.de/danet/gosdn/controller/store" + "github.com/google/uuid" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" ) @@ -40,13 +41,13 @@ func (pis *PluginInternalServer) AvailablePlugins(ctx context.Context, request * return pis.pluginRegistryClient.GetAll(ctx, getAllRequest) } -func (pis *PluginInternalServer) GetPluginSchema(ctx context.Context, stream pipb.PluginInternalService_PluginSchemaServer) error { +func (pis *PluginInternalServer) GetPluginSchema(request *pipb.GetPluginSchemaRequest, stream pipb.PluginInternalService_GetPluginSchemaServer) error { labels := prometheus.Labels{"service": "plugin", "rpc": "get plugin schema"} start := metrics.StartHook(labels, grpcRequestsTotal) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) buffer := make([]byte, int(MB)) - plugin, err := pis.pluginService.Get(store.Query{}) + plugin, err := pis.pluginService.Get(store.Query{ID: uuid.MustParse(request.GetPid())}) if err != nil { return handleRPCError(labels, err) } diff --git a/controller/northbound/server/test_util_test.go b/controller/northbound/server/test_util_test.go index e1bb2a381f136a8f734991eb22190bdfd4d3711f..df886d2967b30bfc5ebeba8720676bd25c551696 100644 --- a/controller/northbound/server/test_util_test.go +++ b/controller/northbound/server/test_util_test.go @@ -128,7 +128,7 @@ func createTestRoles(roleService rbacInterfaces.RoleService) error { "/gosdn.core.CoreService/GetPnd", "/gosdn.core.CoreService/GetPndList", "/gosdn.rbac.UserService/GetUsers", - "/gosdn.plugin_internal.PluginInternalService/PluginSchema", + "/gosdn.plugin_internal.PluginInternalService/GetPluginSchema", }, }, { @@ -253,7 +253,7 @@ func getMockPlugin(t *testing.T) plugin.Plugin { mockPlugin := &mocks.Plugin{} mockPlugin.On("ID").Return(pluginUUID) - mockPlugin.On("SchemaTreeGzip").Return([]byte("schema_test")) + mockPlugin.On("SchemaTreeGzip").Return([]byte("schema_test"), nil) return mockPlugin } diff --git a/plugins/examples/openconfig/cmd/main.go b/plugins/examples/openconfig/cmd/main.go index 45c25906c295ca2348378ac4b1128288e50ef141..7bbbd2863cf55dce994846fc690465de1b6b56e5 100644 --- a/plugins/examples/openconfig/cmd/main.go +++ b/plugins/examples/openconfig/cmd/main.go @@ -5,7 +5,7 @@ import ( "os" "code.fbi.h-da.de/danet/gosdn/controller/plugin/shared" - generated "code.fbi.h-da.de/danet/gosdn/plugins/openconfig/generated" + generated "code.fbi.h-da.de/danet/gosdn/plugins/examples/openconfig/generated" "code.fbi.h-da.de/danet/gosdn/plugins/sdk" "github.com/hashicorp/go-plugin" )