mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-21 17:35:16 +03:00
refactor: switch slices to map
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// protoc v7.35.0
|
||||
// source: homeops/hub.proto
|
||||
|
||||
package homeops
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v7.34.1
|
||||
// - protoc v7.35.0
|
||||
// source: homeops/hub.proto
|
||||
|
||||
package homeops
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// protoc v7.35.0
|
||||
// source: homeops/register.proto
|
||||
|
||||
package homeops
|
||||
@@ -71,7 +71,7 @@ type RegisterAgentRequest struct {
|
||||
AgentName string `protobuf:"bytes,2,opt,name=agent_name,json=agentName,proto3" json:"agent_name,omitempty"`
|
||||
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
|
||||
Host *HostInfo `protobuf:"bytes,4,opt,name=host,proto3" json:"host,omitempty"`
|
||||
Capability []*Capability `protobuf:"bytes,5,rep,name=capability,proto3" json:"capability,omitempty"`
|
||||
Capability map[string]*Capability `protobuf:"bytes,5,rep,name=capability,proto3" json:"capability,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func (x *RegisterAgentRequest) GetHost() *HostInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RegisterAgentRequest) GetCapability() []*Capability {
|
||||
func (x *RegisterAgentRequest) GetCapability() map[string]*Capability {
|
||||
if x != nil {
|
||||
return x.Capability
|
||||
}
|
||||
@@ -205,9 +205,9 @@ type Capability struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Available bool `protobuf:"varint,1,opt,name=available,proto3" json:"available,omitempty"` // доступен ли
|
||||
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // версия раздела
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // название раздела по типу докер или управление пк
|
||||
// string name = 3; // название раздела по типу докер или управление пк
|
||||
Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason,omitempty"` // причина если раздел не доступент
|
||||
Command []*CapabilityCommand `protobuf:"bytes,5,rep,name=command,proto3" json:"command,omitempty"` // команды раздела
|
||||
Command map[string]*CapabilityCommand `protobuf:"bytes,5,rep,name=command,proto3" json:"command,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // команды раздела
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -256,13 +256,6 @@ func (x *Capability) GetVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Capability) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Capability) GetReason() string {
|
||||
if x != nil {
|
||||
return x.Reason
|
||||
@@ -270,7 +263,7 @@ func (x *Capability) GetReason() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Capability) GetCommand() []*CapabilityCommand {
|
||||
func (x *Capability) GetCommand() map[string]*CapabilityCommand {
|
||||
if x != nil {
|
||||
return x.Command
|
||||
}
|
||||
@@ -279,9 +272,9 @@ func (x *Capability) GetCommand() []*CapabilityCommand {
|
||||
|
||||
type CapabilityCommand struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // название команды
|
||||
OptArgs []*CommandsArgs `protobuf:"bytes,2,rep,name=opt_args,json=optArgs,proto3" json:"opt_args,omitempty"` // опциоанльные переменные
|
||||
ReqArgs []*CommandsArgs `protobuf:"bytes,3,rep,name=req_args,json=reqArgs,proto3" json:"req_args,omitempty"` // обязательные переменные
|
||||
// string name = 1; // название команды
|
||||
OptArgs map[string]*CommandsArgs `protobuf:"bytes,2,rep,name=opt_args,json=optArgs,proto3" json:"opt_args,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // опциоанльные переменные
|
||||
ReqArgs map[string]*CommandsArgs `protobuf:"bytes,3,rep,name=req_args,json=reqArgs,proto3" json:"req_args,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // обязательные переменные
|
||||
Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` // версия команды
|
||||
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` // описание команды для документации
|
||||
TypeOutput string `protobuf:"bytes,7,opt,name=type_output,json=typeOutput,proto3" json:"type_output,omitempty"`
|
||||
@@ -319,21 +312,14 @@ func (*CapabilityCommand) Descriptor() ([]byte, []int) {
|
||||
return file_homeops_register_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *CapabilityCommand) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CapabilityCommand) GetOptArgs() []*CommandsArgs {
|
||||
func (x *CapabilityCommand) GetOptArgs() map[string]*CommandsArgs {
|
||||
if x != nil {
|
||||
return x.OptArgs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CapabilityCommand) GetReqArgs() []*CommandsArgs {
|
||||
func (x *CapabilityCommand) GetReqArgs() map[string]*CommandsArgs {
|
||||
if x != nil {
|
||||
return x.ReqArgs
|
||||
}
|
||||
@@ -363,7 +349,7 @@ func (x *CapabilityCommand) GetTypeOutput() string {
|
||||
|
||||
type CommandsArgs struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // название аргумента
|
||||
// string name = 1; // название аргумента
|
||||
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // какой тип path int string bool
|
||||
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // описание для документации
|
||||
Default string `protobuf:"bytes,4,opt,name=default,proto3" json:"default,omitempty"` // значение по умолчанию
|
||||
@@ -403,13 +389,6 @@ func (*CommandsArgs) Descriptor() ([]byte, []int) {
|
||||
return file_homeops_register_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *CommandsArgs) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CommandsArgs) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
@@ -571,37 +550,46 @@ const file_homeops_register_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x16homeops/register.proto\"\"\n" +
|
||||
"\fPongResponse\x12\x12\n" +
|
||||
"\x04pong\x18\x01 \x01(\tR\x04pong\"\xb6\x01\n" +
|
||||
"\x04pong\x18\x01 \x01(\tR\x04pong\"\x9c\x02\n" +
|
||||
"\x14RegisterAgentRequest\x12\x19\n" +
|
||||
"\bagent_id\x18\x01 \x01(\tR\aagentId\x12\x1d\n" +
|
||||
"\n" +
|
||||
"agent_name\x18\x02 \x01(\tR\tagentName\x12\x18\n" +
|
||||
"\aversion\x18\x03 \x01(\tR\aversion\x12\x1d\n" +
|
||||
"\x04host\x18\x04 \x01(\v2\t.HostInfoR\x04host\x12+\n" +
|
||||
"\x04host\x18\x04 \x01(\v2\t.HostInfoR\x04host\x12E\n" +
|
||||
"\n" +
|
||||
"capability\x18\x05 \x03(\v2\v.CapabilityR\n" +
|
||||
"capability\"R\n" +
|
||||
"capability\x18\x05 \x03(\v2%.RegisterAgentRequest.CapabilityEntryR\n" +
|
||||
"capability\x1aJ\n" +
|
||||
"\x0fCapabilityEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12!\n" +
|
||||
"\x05value\x18\x02 \x01(\v2\v.CapabilityR\x05value:\x028\x01\"R\n" +
|
||||
"\bHostInfo\x12\x16\n" +
|
||||
"\x06system\x18\x01 \x01(\tR\x06system\x12\x1a\n" +
|
||||
"\bhostname\x18\x02 \x01(\tR\bhostname\x12\x12\n" +
|
||||
"\x04arch\x18\x03 \x01(\tR\x04arch\"\x9e\x01\n" +
|
||||
"\x04arch\x18\x03 \x01(\tR\x04arch\"\xe0\x01\n" +
|
||||
"\n" +
|
||||
"Capability\x12\x1c\n" +
|
||||
"\tavailable\x18\x01 \x01(\bR\tavailable\x12\x18\n" +
|
||||
"\aversion\x18\x02 \x01(\tR\aversion\x12\x12\n" +
|
||||
"\x04name\x18\x03 \x01(\tR\x04name\x12\x16\n" +
|
||||
"\x06reason\x18\x04 \x01(\tR\x06reason\x12,\n" +
|
||||
"\acommand\x18\x05 \x03(\v2\x12.CapabilityCommandR\acommand\"\xd8\x01\n" +
|
||||
"\x11CapabilityCommand\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name\x12(\n" +
|
||||
"\bopt_args\x18\x02 \x03(\v2\r.CommandsArgsR\aoptArgs\x12(\n" +
|
||||
"\breq_args\x18\x03 \x03(\v2\r.CommandsArgsR\areqArgs\x12\x18\n" +
|
||||
"\aversion\x18\x02 \x01(\tR\aversion\x12\x16\n" +
|
||||
"\x06reason\x18\x04 \x01(\tR\x06reason\x122\n" +
|
||||
"\acommand\x18\x05 \x03(\v2\x18.Capability.CommandEntryR\acommand\x1aN\n" +
|
||||
"\fCommandEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12(\n" +
|
||||
"\x05value\x18\x02 \x01(\v2\x12.CapabilityCommandR\x05value:\x028\x01\"\xfe\x02\n" +
|
||||
"\x11CapabilityCommand\x12:\n" +
|
||||
"\bopt_args\x18\x02 \x03(\v2\x1f.CapabilityCommand.OptArgsEntryR\aoptArgs\x12:\n" +
|
||||
"\breq_args\x18\x03 \x03(\v2\x1f.CapabilityCommand.ReqArgsEntryR\areqArgs\x12\x18\n" +
|
||||
"\aversion\x18\x04 \x01(\tR\aversion\x12 \n" +
|
||||
"\vdescription\x18\x05 \x01(\tR\vdescription\x12\x1f\n" +
|
||||
"\vtype_output\x18\a \x01(\tR\n" +
|
||||
"typeOutput\"\xb6\x01\n" +
|
||||
"typeOutput\x1aI\n" +
|
||||
"\fOptArgsEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12#\n" +
|
||||
"\x05value\x18\x02 \x01(\v2\r.CommandsArgsR\x05value:\x028\x01\x1aI\n" +
|
||||
"\fReqArgsEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12#\n" +
|
||||
"\x05value\x18\x02 \x01(\v2\r.CommandsArgsR\x05value:\x028\x01\"\xa2\x01\n" +
|
||||
"\fCommandsArgs\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" +
|
||||
"\x04type\x18\x02 \x01(\tR\x04type\x12 \n" +
|
||||
"\vdescription\x18\x03 \x01(\tR\vdescription\x12\x18\n" +
|
||||
"\adefault\x18\x04 \x01(\tR\adefault\x12\x12\n" +
|
||||
@@ -630,7 +618,7 @@ func file_homeops_register_proto_rawDescGZIP() []byte {
|
||||
return file_homeops_register_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_homeops_register_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_homeops_register_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_homeops_register_proto_goTypes = []any{
|
||||
(*PongResponse)(nil), // 0: PongResponse
|
||||
(*RegisterAgentRequest)(nil), // 1: RegisterAgentRequest
|
||||
@@ -640,19 +628,27 @@ var file_homeops_register_proto_goTypes = []any{
|
||||
(*CommandsArgs)(nil), // 5: CommandsArgs
|
||||
(*ArgValidation)(nil), // 6: ArgValidation
|
||||
(*RegisterAgentResponse)(nil), // 7: RegisterAgentResponse
|
||||
nil, // 8: RegisterAgentRequest.CapabilityEntry
|
||||
nil, // 9: Capability.CommandEntry
|
||||
nil, // 10: CapabilityCommand.OptArgsEntry
|
||||
nil, // 11: CapabilityCommand.ReqArgsEntry
|
||||
}
|
||||
var file_homeops_register_proto_depIdxs = []int32{
|
||||
2, // 0: RegisterAgentRequest.host:type_name -> HostInfo
|
||||
3, // 1: RegisterAgentRequest.capability:type_name -> Capability
|
||||
4, // 2: Capability.command:type_name -> CapabilityCommand
|
||||
5, // 3: CapabilityCommand.opt_args:type_name -> CommandsArgs
|
||||
5, // 4: CapabilityCommand.req_args:type_name -> CommandsArgs
|
||||
8, // 1: RegisterAgentRequest.capability:type_name -> RegisterAgentRequest.CapabilityEntry
|
||||
9, // 2: Capability.command:type_name -> Capability.CommandEntry
|
||||
10, // 3: CapabilityCommand.opt_args:type_name -> CapabilityCommand.OptArgsEntry
|
||||
11, // 4: CapabilityCommand.req_args:type_name -> CapabilityCommand.ReqArgsEntry
|
||||
6, // 5: CommandsArgs.validation:type_name -> ArgValidation
|
||||
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
|
||||
3, // 6: RegisterAgentRequest.CapabilityEntry.value:type_name -> Capability
|
||||
4, // 7: Capability.CommandEntry.value:type_name -> CapabilityCommand
|
||||
5, // 8: CapabilityCommand.OptArgsEntry.value:type_name -> CommandsArgs
|
||||
5, // 9: CapabilityCommand.ReqArgsEntry.value:type_name -> CommandsArgs
|
||||
10, // [10:10] is the sub-list for method output_type
|
||||
10, // [10:10] is the sub-list for method input_type
|
||||
10, // [10:10] is the sub-list for extension type_name
|
||||
10, // [10:10] is the sub-list for extension extendee
|
||||
0, // [0:10] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_homeops_register_proto_init() }
|
||||
@@ -666,7 +662,7 @@ func file_homeops_register_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_homeops_register_proto_rawDesc), len(file_homeops_register_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// protoc v7.35.0
|
||||
// source: homeops/stream.proto
|
||||
|
||||
package homeops
|
||||
|
||||
@@ -11,7 +11,7 @@ message RegisterAgentRequest {
|
||||
string agent_name = 2;
|
||||
string version = 3;
|
||||
HostInfo host = 4;
|
||||
repeated Capability capability = 5;
|
||||
map<string, Capability> capability = 5;
|
||||
}
|
||||
|
||||
message HostInfo {
|
||||
@@ -23,22 +23,22 @@ message HostInfo {
|
||||
message Capability {
|
||||
bool available = 1; // доступен ли
|
||||
string version = 2; // версия раздела
|
||||
string name = 3; // название раздела по типу докер или управление пк
|
||||
// string name = 3; // название раздела по типу докер или управление пк
|
||||
string reason = 4; // причина если раздел не доступент
|
||||
repeated CapabilityCommand command = 5; // команды раздела
|
||||
map<string, CapabilityCommand> command = 5; // команды раздела
|
||||
}
|
||||
|
||||
message CapabilityCommand {
|
||||
string name = 1; // название команды
|
||||
repeated CommandsArgs opt_args = 2; // опциоанльные переменные
|
||||
repeated CommandsArgs req_args = 3; // обязательные переменные
|
||||
// string name = 1; // название команды
|
||||
map<string, CommandsArgs> opt_args = 2; // опциоанльные переменные
|
||||
map<string, CommandsArgs> req_args = 3; // обязательные переменные
|
||||
string version = 4; // версия команды
|
||||
string description = 5; // описание команды для документации
|
||||
string type_output = 7;
|
||||
}
|
||||
|
||||
message CommandsArgs {
|
||||
string name = 1; // название аргумента
|
||||
// string name = 1; // название аргумента
|
||||
string type = 2; // какой тип path int string bool
|
||||
string description = 3; // описание для документации
|
||||
string default = 4; // значение по умолчанию
|
||||
|
||||
@@ -5,7 +5,7 @@ type RegisterAgentRequest struct {
|
||||
AgentName string
|
||||
AgentVersion string
|
||||
Host HostInfo
|
||||
Capabilities []Capability
|
||||
Capabilities map[string]Capability
|
||||
}
|
||||
|
||||
type HostInfo struct {
|
||||
@@ -17,22 +17,19 @@ type HostInfo struct {
|
||||
type Capability struct {
|
||||
Available bool
|
||||
Version string
|
||||
Name string
|
||||
Reason string
|
||||
Command []CapabilityCommand
|
||||
Command map[string]CapabilityCommand
|
||||
}
|
||||
|
||||
type CapabilityCommand struct {
|
||||
Name string
|
||||
OptionalArgs []CommandArgs
|
||||
RequiredArgs []CommandArgs
|
||||
OptionalArgs map[string]CommandArgs
|
||||
RequiredArgs map[string]CommandArgs
|
||||
Version string
|
||||
Description string
|
||||
TypeOutput string
|
||||
}
|
||||
|
||||
type CommandArgs struct {
|
||||
Name string
|
||||
Type string
|
||||
Description string
|
||||
Default string
|
||||
|
||||
@@ -36,16 +36,15 @@ func ToDomainAgentResponse(response *pb.RegisterAgentResponse) (domain.RegisterA
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ToDomainCapabilities(capabilities []*pb.Capability) []domain.Capability {
|
||||
domainCaps := make([]domain.Capability, len(capabilities))
|
||||
func ToDomainCapabilities(capabilities map[string]*pb.Capability) map[string]domain.Capability {
|
||||
domainCaps := make(map[string]domain.Capability, len(capabilities))
|
||||
|
||||
for id, capability := range capabilities {
|
||||
for name, capability := range capabilities {
|
||||
if capability == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
domainCaps[id] = domain.Capability{
|
||||
Name: capability.Name,
|
||||
domainCaps[name] = domain.Capability{
|
||||
Version: capability.Version,
|
||||
Reason: capability.Reason,
|
||||
Available: capability.Available,
|
||||
@@ -56,16 +55,15 @@ func ToDomainCapabilities(capabilities []*pb.Capability) []domain.Capability {
|
||||
return domainCaps
|
||||
}
|
||||
|
||||
func ToDomainCapabilityCommands(commands []*pb.CapabilityCommand) []domain.CapabilityCommand {
|
||||
domainCommand := make([]domain.CapabilityCommand, len(commands))
|
||||
func ToDomainCapabilityCommands(commands map[string]*pb.CapabilityCommand) map[string]domain.CapabilityCommand {
|
||||
domainCommand := make(map[string]domain.CapabilityCommand, len(commands))
|
||||
|
||||
for id, command := range commands {
|
||||
for name, command := range commands {
|
||||
if command == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
domainCommand[id] = domain.CapabilityCommand{
|
||||
Name: command.Name,
|
||||
domainCommand[name] = domain.CapabilityCommand{
|
||||
OptionalArgs: ToDomainCommandArgs(command.OptArgs),
|
||||
RequiredArgs: ToDomainCommandArgs(command.ReqArgs),
|
||||
Version: command.Version,
|
||||
@@ -74,12 +72,11 @@ func ToDomainCapabilityCommands(commands []*pb.CapabilityCommand) []domain.Capab
|
||||
return domainCommand
|
||||
}
|
||||
|
||||
func ToDomainCommandArgs(args []*pb.CommandsArgs) []domain.CommandArgs {
|
||||
DomainArgs := make([]domain.CommandArgs, len(args))
|
||||
func ToDomainCommandArgs(args map[string]*pb.CommandsArgs) map[string]domain.CommandArgs {
|
||||
DomainArgs := make(map[string]domain.CommandArgs, len(args))
|
||||
|
||||
for id, arg := range args {
|
||||
DomainArgs[id] = domain.CommandArgs{
|
||||
Name: arg.Name,
|
||||
for name, arg := range args {
|
||||
DomainArgs[name] = domain.CommandArgs{
|
||||
Type: arg.Type,
|
||||
Default: arg.Default,
|
||||
Description: arg.Description,
|
||||
@@ -114,12 +111,11 @@ func ToGRPCAgentResponse(response domain.RegisterAgentResponse) *pb.RegisterAgen
|
||||
return &pb.RegisterAgentResponse{AgentId: response.AgentID, HeartbeatIntervalSecond: int64(response.Heartbeat)}
|
||||
}
|
||||
|
||||
func ToGRPCCapability(capabilities []domain.Capability) []*pb.Capability {
|
||||
GRPCCapabilities := make([]*pb.Capability, len(capabilities))
|
||||
func ToGRPCCapability(capabilities map[string]domain.Capability) map[string]*pb.Capability {
|
||||
GRPCCapabilities := make(map[string]*pb.Capability, len(capabilities))
|
||||
|
||||
for id, capability := range capabilities {
|
||||
GRPCCapabilities[id] = &pb.Capability{
|
||||
Name: capability.Name,
|
||||
for name, capability := range capabilities {
|
||||
GRPCCapabilities[name] = &pb.Capability{
|
||||
Available: capability.Available,
|
||||
Version: capability.Version,
|
||||
Reason: capability.Reason,
|
||||
@@ -129,12 +125,11 @@ func ToGRPCCapability(capabilities []domain.Capability) []*pb.Capability {
|
||||
return GRPCCapabilities
|
||||
}
|
||||
|
||||
func ToGRPCCapabilityCommands(commands []domain.CapabilityCommand) []*pb.CapabilityCommand {
|
||||
GRPCCommands := make([]*pb.CapabilityCommand, len(commands))
|
||||
func ToGRPCCapabilityCommands(commands map[string]domain.CapabilityCommand) map[string]*pb.CapabilityCommand {
|
||||
GRPCCommands := make(map[string]*pb.CapabilityCommand, len(commands))
|
||||
|
||||
for id, command := range commands {
|
||||
GRPCCommands[id] = &pb.CapabilityCommand{
|
||||
Name: command.Name,
|
||||
for name, command := range commands {
|
||||
GRPCCommands[name] = &pb.CapabilityCommand{
|
||||
Version: command.Version,
|
||||
OptArgs: ToGRPCCommandArgs(command.OptionalArgs),
|
||||
ReqArgs: ToGRPCCommandArgs(command.RequiredArgs),
|
||||
@@ -145,12 +140,11 @@ func ToGRPCCapabilityCommands(commands []domain.CapabilityCommand) []*pb.Capabil
|
||||
return GRPCCommands
|
||||
}
|
||||
|
||||
func ToGRPCCommandArgs(args []domain.CommandArgs) []*pb.CommandsArgs {
|
||||
GRPCArgs := make([]*pb.CommandsArgs, len(args))
|
||||
func ToGRPCCommandArgs(args map[string]domain.CommandArgs) map[string]*pb.CommandsArgs {
|
||||
GRPCArgs := make(map[string]*pb.CommandsArgs, len(args))
|
||||
|
||||
for id, arg := range args {
|
||||
GRPCArgs[id] = &pb.CommandsArgs{
|
||||
Name: arg.Name,
|
||||
for name, arg := range args {
|
||||
GRPCArgs[name] = &pb.CommandsArgs{
|
||||
Type: arg.Type,
|
||||
Default: arg.Default,
|
||||
Description: arg.Description,
|
||||
|
||||
Reference in New Issue
Block a user