Unverified Commit 13fa409c authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

Add `Online Help` link to gRPC interface's `Platform` (#2009)

* Add online help field to rpc platform

* Add online help field to the output of `core search --format json`

* Add tests for the changes
parent de905799
......@@ -56,6 +56,7 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
Maintainer: platformRelease.Platform.Package.Maintainer,
Website: platformRelease.Platform.Package.WebsiteURL,
Email: platformRelease.Platform.Package.Email,
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
Boards: boards,
Latest: platformRelease.Version.String(),
ManuallyInstalled: platformRelease.Platform.ManuallyInstalled,
......
......@@ -62,6 +62,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
require.Contains(t, res.SearchOutput, &rpc.Platform{
Id: "Retrokits-RK002:arm",
......@@ -73,6 +74,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
res, stat = PlatformSearch(&rpc.PlatformSearchRequest{
......@@ -93,6 +95,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
// Search the Package Maintainer
......@@ -114,6 +117,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
require.Contains(t, res.SearchOutput, &rpc.Platform{
Id: "Retrokits-RK002:arm",
......@@ -125,6 +129,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
// Search using the Package name
......@@ -146,6 +151,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
require.Contains(t, res.SearchOutput, &rpc.Platform{
Id: "Retrokits-RK002:arm",
......@@ -157,6 +163,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
// Search using the Platform name
......@@ -178,6 +185,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
require.Contains(t, res.SearchOutput, &rpc.Platform{
Id: "Retrokits-RK002:arm",
......@@ -189,6 +197,7 @@ func TestPlatformSearch(t *testing.T) {
Email: "info@retrokits.com",
Boards: []*rpc.Board{{Name: "RK002"}},
Type: []string{"Contributed"},
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
})
// Search using a board name
......@@ -237,6 +246,7 @@ func TestPlatformSearch(t *testing.T) {
{Name: "Arduino Industrial 101"},
{Name: "Linino One"},
},
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
})
res, stat = PlatformSearch(&rpc.PlatformSearchRequest{
......@@ -284,6 +294,7 @@ func TestPlatformSearch(t *testing.T) {
{Name: "Arduino Industrial 101"},
{Name: "Linino One"},
},
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
})
}
......
......@@ -520,6 +520,9 @@ type Platform struct {
Deprecated bool `protobuf:"varint,10,opt,name=deprecated,proto3" json:"deprecated,omitempty"`
// Type of the platform.
Type []string `protobuf:"bytes,11,rep,name=type,proto3" json:"type,omitempty"`
// A URL provided by the author of the platform's package, intended to point
// to their online help service.
Help *HelpResources `protobuf:"bytes,12,opt,name=help,proto3" json:"help,omitempty"`
}
func (x *Platform) Reset() {
......@@ -631,6 +634,13 @@ func (x *Platform) GetType() []string {
return nil
}
func (x *Platform) GetHelp() *HelpResources {
if x != nil {
return x.Help
}
return nil
}
type InstalledPlatformReference struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
......@@ -821,6 +831,55 @@ func (x *Profile) GetFqbn() string {
return ""
}
type HelpResources struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// A URL provided by the author of the platform's package, intended to point
// to their online help service.
Online string `protobuf:"bytes,1,opt,name=online,proto3" json:"online,omitempty"`
}
func (x *HelpResources) Reset() {
*x = HelpResources{}
if protoimpl.UnsafeEnabled {
mi := &file_cc_arduino_cli_commands_v1_common_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelpResources) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelpResources) ProtoMessage() {}
func (x *HelpResources) ProtoReflect() protoreflect.Message {
mi := &file_cc_arduino_cli_commands_v1_common_proto_msgTypes[11]
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 HelpResources.ProtoReflect.Descriptor instead.
func (*HelpResources) Descriptor() ([]byte, []int) {
return file_cc_arduino_cli_commands_v1_common_proto_rawDescGZIP(), []int{11}
}
func (x *HelpResources) GetOnline() string {
if x != nil {
return x.Online
}
return ""
}
var File_cc_arduino_cli_commands_v1_common_proto protoreflect.FileDescriptor
var file_cc_arduino_cli_commands_v1_common_proto_rawDesc = []byte{
......@@ -872,7 +931,7 @@ var file_cc_arduino_cli_commands_v1_common_proto_rawDesc = []byte{
0x66, 0x6f, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74,
0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xd2, 0x02, 0x0a, 0x08, 0x50, 0x6c, 0x61,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x91, 0x03, 0x0a, 0x08, 0x50, 0x6c, 0x61,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c,
0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c,
......@@ -893,27 +952,34 @@ var file_cc_arduino_cli_commands_v1_common_proto_rawDesc = []byte{
0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70,
0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64,
0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x88, 0x01,
0x0a, 0x1a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c,
0x6c, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73,
0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x61,
0x67, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61,
0x63, 0x6b, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72,
0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, 0x0a, 0x07, 0x50, 0x72, 0x6f,
0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x42, 0x48, 0x5a, 0x46,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69,
0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72,
0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c,
0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f,
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3d, 0x0a,
0x04, 0x68, 0x65, 0x6c, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x63,
0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x6c, 0x70, 0x52, 0x65, 0x73,
0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x22, 0x88, 0x01, 0x0a,
0x1a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f,
0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c,
0x5f, 0x64, 0x69, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74,
0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67,
0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x63,
0x6b, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66,
0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x27, 0x0a, 0x0d, 0x48,
0x65, 0x6c, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06,
0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x6e,
0x6c, 0x69, 0x6e, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69,
0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72,
0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......@@ -928,7 +994,7 @@ func file_cc_arduino_cli_commands_v1_common_proto_rawDescGZIP() []byte {
return file_cc_arduino_cli_commands_v1_common_proto_rawDescData
}
var file_cc_arduino_cli_commands_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_cc_arduino_cli_commands_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_cc_arduino_cli_commands_v1_common_proto_goTypes = []interface{}{
(*Instance)(nil), // 0: cc.arduino.cli.commands.v1.Instance
(*DownloadProgress)(nil), // 1: cc.arduino.cli.commands.v1.DownloadProgress
......@@ -941,17 +1007,19 @@ var file_cc_arduino_cli_commands_v1_common_proto_goTypes = []interface{}{
(*InstalledPlatformReference)(nil), // 8: cc.arduino.cli.commands.v1.InstalledPlatformReference
(*Board)(nil), // 9: cc.arduino.cli.commands.v1.Board
(*Profile)(nil), // 10: cc.arduino.cli.commands.v1.Profile
(*HelpResources)(nil), // 11: cc.arduino.cli.commands.v1.HelpResources
}
var file_cc_arduino_cli_commands_v1_common_proto_depIdxs = []int32{
2, // 0: cc.arduino.cli.commands.v1.DownloadProgress.start:type_name -> cc.arduino.cli.commands.v1.DownloadProgressStart
3, // 1: cc.arduino.cli.commands.v1.DownloadProgress.update:type_name -> cc.arduino.cli.commands.v1.DownloadProgressUpdate
4, // 2: cc.arduino.cli.commands.v1.DownloadProgress.end:type_name -> cc.arduino.cli.commands.v1.DownloadProgressEnd
9, // 3: cc.arduino.cli.commands.v1.Platform.boards:type_name -> cc.arduino.cli.commands.v1.Board
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
11, // 4: cc.arduino.cli.commands.v1.Platform.help:type_name -> cc.arduino.cli.commands.v1.HelpResources
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_cc_arduino_cli_commands_v1_common_proto_init() }
......@@ -1092,6 +1160,18 @@ func file_cc_arduino_cli_commands_v1_common_proto_init() {
return nil
}
}
file_cc_arduino_cli_commands_v1_common_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelpResources); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_cc_arduino_cli_commands_v1_common_proto_msgTypes[1].OneofWrappers = []interface{}{
(*DownloadProgress_Start)(nil),
......@@ -1104,7 +1184,7 @@ func file_cc_arduino_cli_commands_v1_common_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cc_arduino_cli_commands_v1_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumMessages: 12,
NumExtensions: 0,
NumServices: 0,
},
......
......@@ -99,6 +99,9 @@ message Platform {
bool deprecated = 10;
// Type of the platform.
repeated string type = 11;
// A URL provided by the author of the platform's package, intended to point
// to their online help service.
HelpResources help = 12;
}
message InstalledPlatformReference {
......@@ -126,3 +129,9 @@ message Profile {
// FQBN specified in the profile.
string fqbn = 2;
}
message HelpResources {
// A URL provided by the author of the platform's package, intended to point
// to their online help service.
string online = 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment