Skip to content

Commit

Permalink
Add name property to rpc (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzko authored Aug 2, 2021
1 parent 1a0cdc9 commit f9219d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXECUTABLE:=proto2yaml
DOCKER_REGISTRY:=ghcr.io
DOCKER_USER:=krzko

VERSION:=v0.0.3
VERSION:=v0.0.4
COMMIT=$(shell git describe --tags --always --long)
NOW=$(shell date +'%Y%m%d')

Expand Down
20 changes: 12 additions & 8 deletions cmd/proto2yaml/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ type PackageItem struct {
Services []ServiceItem `json:"services" yaml:"services"`
}
type ServiceItem struct {
Service string `json:"service" yaml:"service"`
RPCs []string `json:"rpc" yaml:"rpc"`
Service string `json:"service" yaml:"service"`
RPCs []RPCItem `json:"rpc" yaml:"rpc"`
}

type RPCItem struct {
Name string `json:"name" yaml:"name"`
}

func main() {
Expand Down Expand Up @@ -541,12 +545,12 @@ func generateExport(files, filter []string, filterType string) (*ProtoExport, er

i, check := findService(pe.Packages[index].Services, parent.Name)
if check {
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, rpc.Name)
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, RPCItem{Name: rpc.Name})
} else {
// Add service and rpc
pe.Packages[index].Services = append(pe.Packages[index].Services, ServiceItem{
Service: parent.Name,
RPCs: []string{rpc.Name},
RPCs: []RPCItem{RPCItem{Name: rpc.Name}},
})
}
}))
Expand Down Expand Up @@ -594,12 +598,12 @@ func generateExport(files, filter []string, filterType string) (*ProtoExport, er

i, check := findService(pe.Packages[index].Services, parent.Name)
if check {
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, rpc.Name)
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, RPCItem{Name: rpc.Name})
} else {
// Add service and rpc
pe.Packages[index].Services = append(pe.Packages[index].Services, ServiceItem{
Service: parent.Name,
RPCs: []string{rpc.Name},
RPCs: []RPCItem{RPCItem{Name: rpc.Name}},
})
}
}))
Expand Down Expand Up @@ -639,12 +643,12 @@ func generateExport(files, filter []string, filterType string) (*ProtoExport, er

i, check := findService(pe.Packages[index].Services, parent.Name)
if check {
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, rpc.Name)
pe.Packages[index].Services[i].RPCs = append(pe.Packages[index].Services[i].RPCs, RPCItem{Name: rpc.Name})
} else {
// Add service and rpc
pe.Packages[index].Services = append(pe.Packages[index].Services, ServiceItem{
Service: parent.Name,
RPCs: []string{rpc.Name},
RPCs: []RPCItem{RPCItem{Name: rpc.Name}},
})
}
}))
Expand Down

0 comments on commit f9219d7

Please sign in to comment.