Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename protobuf/definitions to protobuf/definition #852

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands/service_detail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"testing"

"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/protobuf/definitions"
"github.com/mesg-foundation/core/protobuf/definition"
"github.com/mesg-foundation/core/utils/pretty"
"github.com/stretchr/testify/require"
)

func TestServiceDetail(t *testing.T) {
var (
id = "1"
service = &coreapi.Service{Definition: &definitions.Service{Hash: "2", Name: "3", Events: []*definitions.Event{{Key: "4"}}}}
service = &coreapi.Service{Definition: &definition.Service{Hash: "2", Name: "3", Events: []*definition.Event{{Key: "4"}}}}
m = newMockExecutor()
c = newServiceDetailCmd(m)
)
Expand Down
8 changes: 4 additions & 4 deletions commands/service_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/protobuf/definitions"
"github.com/mesg-foundation/core/protobuf/definition"
"github.com/mesg-foundation/core/utils/pretty"
casting "github.com/mesg-foundation/core/utils/servicecasting"
"github.com/mesg-foundation/core/x/xjson"
Expand Down Expand Up @@ -117,7 +117,7 @@ func (c *serviceExecuteCmd) runE(cmd *cobra.Command, args []string) error {
return nil
}

func (c *serviceExecuteCmd) getTaskKey(s *definitions.Service) error {
func (c *serviceExecuteCmd) getTaskKey(s *definition.Service) error {
keys := taskKeysFromService(s)

if c.taskKey != "" {
Expand All @@ -141,7 +141,7 @@ func (c *serviceExecuteCmd) getTaskKey(s *definitions.Service) error {
return nil
}

func (c *serviceExecuteCmd) getData(s *definitions.Service) (string, error) {
func (c *serviceExecuteCmd) getData(s *definition.Service) (string, error) {
if c.jsonFile != "" {
return c.readFile()
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func (c *serviceExecuteCmd) readFile() (string, error) {
return string(content), err
}

func taskKeysFromService(s *definitions.Service) []string {
func taskKeysFromService(s *definition.Service) []string {
var taskKeys []string
for _, task := range s.Tasks {
taskKeys = append(taskKeys, task.Key)
Expand Down
6 changes: 3 additions & 3 deletions commands/service_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"testing"

"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/protobuf/definitions"
"github.com/mesg-foundation/core/protobuf/definition"
"github.com/stretchr/testify/require"
)

func TestServiceList(t *testing.T) {
var (
services = []*coreapi.Service{
{Definition: &definitions.Service{Hash: "1", Name: "a"}, Status: coreapi.Service_RUNNING},
{Definition: &definitions.Service{Hash: "2", Name: "b"}, Status: coreapi.Service_PARTIAL},
{Definition: &definition.Service{Hash: "1", Name: "a"}, Status: coreapi.Service_RUNNING},
{Definition: &definition.Service{Hash: "2", Name: "b"}, Status: coreapi.Service_PARTIAL},
}
m = newMockExecutor()
c = newServiceListCmd(m)
Expand Down
40 changes: 20 additions & 20 deletions interface/grpc/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package core

import (
"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/protobuf/definitions"
"github.com/mesg-foundation/core/protobuf/definition"
service "github.com/mesg-foundation/core/service"
)

func toProtoServices(ss []*service.Service) []*definitions.Service {
services := make([]*definitions.Service, len(ss))
func toProtoServices(ss []*service.Service) []*definition.Service {
services := make([]*definition.Service, len(ss))
for i, s := range ss {
services[i] = toProtoService(s)
}
return services
}

func toProtoService(s *service.Service) *definitions.Service {
return &definitions.Service{
func toProtoService(s *service.Service) *definition.Service {
return &definition.Service{
Hash: s.Hash,
Sid: s.Sid,
Name: s.Name,
Expand All @@ -42,18 +42,18 @@ func toProtoServiceStatusType(s service.StatusType) coreapi.Service_Status {
}
}

func toProtoTasks(tasks []*service.Task) []*definitions.Task {
ts := make([]*definitions.Task, len(tasks))
func toProtoTasks(tasks []*service.Task) []*definition.Task {
ts := make([]*definition.Task, len(tasks))
for i, task := range tasks {
t := &definitions.Task{
t := &definition.Task{
Key: task.Key,
Name: task.Name,
Description: task.Description,
Inputs: toProtoParameters(task.Inputs),
Outputs: []*definitions.Output{},
Outputs: []*definition.Output{},
}
for _, output := range task.Outputs {
o := &definitions.Output{
o := &definition.Output{
Key: output.Key,
Name: output.Name,
Description: output.Description,
Expand All @@ -66,10 +66,10 @@ func toProtoTasks(tasks []*service.Task) []*definitions.Task {
return ts
}

func toProtoEvents(events []*service.Event) []*definitions.Event {
es := make([]*definitions.Event, len(events))
func toProtoEvents(events []*service.Event) []*definition.Event {
es := make([]*definition.Event, len(events))
for i, event := range events {
es[i] = &definitions.Event{
es[i] = &definition.Event{
Key: event.Key,
Name: event.Name,
Description: event.Description,
Expand All @@ -79,10 +79,10 @@ func toProtoEvents(events []*service.Event) []*definitions.Event {
return es
}

func toProtoParameters(params []*service.Parameter) []*definitions.Parameter {
ps := make([]*definitions.Parameter, len(params))
func toProtoParameters(params []*service.Parameter) []*definition.Parameter {
ps := make([]*definition.Parameter, len(params))
for i, param := range params {
ps[i] = &definitions.Parameter{
ps[i] = &definition.Parameter{
Key: param.Key,
Name: param.Name,
Description: param.Description,
Expand All @@ -95,11 +95,11 @@ func toProtoParameters(params []*service.Parameter) []*definitions.Parameter {
return ps
}

func toProtoDependency(dep *service.Dependency) *definitions.Dependency {
func toProtoDependency(dep *service.Dependency) *definition.Dependency {
if dep == nil {
return nil
}
return &definitions.Dependency{
return &definition.Dependency{
Key: dep.Key,
Image: dep.Image,
Volumes: dep.Volumes,
Expand All @@ -109,8 +109,8 @@ func toProtoDependency(dep *service.Dependency) *definitions.Dependency {
}
}

func toProtoDependencies(deps []*service.Dependency) []*definitions.Dependency {
ds := make([]*definitions.Dependency, len(deps))
func toProtoDependencies(deps []*service.Dependency) []*definition.Dependency {
ds := make([]*definition.Dependency, len(deps))
for i, dep := range deps {
ds[i] = toProtoDependency(dep)
}
Expand Down
Loading