diff --git a/interface/grpc/core/proto.go b/interface/grpc/core/proto.go index 6a6beedc6..6bf3c7c37 100644 --- a/interface/grpc/core/proto.go +++ b/interface/grpc/core/proto.go @@ -16,14 +16,15 @@ func toProtoServices(ss []*service.Service) []*definition.Service { func toProtoService(s *service.Service) *definition.Service { return &definition.Service{ - Hash: s.Hash, - Sid: s.Sid, - Name: s.Name, - Description: s.Description, - Repository: s.Repository, - Tasks: toProtoTasks(s.Tasks), - Events: toProtoEvents(s.Events), - Dependencies: toProtoDependencies(s.Dependencies), + Hash: s.Hash, + Sid: s.Sid, + Name: s.Name, + Description: s.Description, + Repository: s.Repository, + Tasks: toProtoTasks(s.Tasks), + Events: toProtoEvents(s.Events), + Configuration: toProtoConfiguration(s.Configuration), + Dependencies: toProtoDependencies(s.Dependencies), } } @@ -95,6 +96,19 @@ func toProtoParameters(params []*service.Parameter) []*definition.Parameter { return ps } +func toProtoConfiguration(configuration *service.Dependency) *definition.Configuration { + if configuration == nil { + return nil + } + return &definition.Configuration{ + Args: configuration.Args, + Command: configuration.Command, + Ports: configuration.Ports, + Volumes: configuration.Volumes, + Volumesfrom: configuration.VolumesFrom, + } +} + func toProtoDependency(dep *service.Dependency) *definition.Dependency { if dep == nil { return nil diff --git a/protobuf/definition/service.pb.go b/protobuf/definition/service.pb.go index bea81ed33..b63e49e6c 100644 --- a/protobuf/definition/service.pb.go +++ b/protobuf/definition/service.pb.go @@ -20,24 +20,25 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // Service represents the service's definition. type Service struct { - Hash string `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty"` - Sid string `protobuf:"bytes,12,opt,name=sid,proto3" json:"sid,omitempty"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Tasks []*Task `protobuf:"bytes,5,rep,name=tasks,proto3" json:"tasks,omitempty"` - Events []*Event `protobuf:"bytes,6,rep,name=events,proto3" json:"events,omitempty"` - Dependencies []*Dependency `protobuf:"bytes,7,rep,name=dependencies,proto3" json:"dependencies,omitempty"` - Repository string `protobuf:"bytes,9,opt,name=repository,proto3" json:"repository,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Hash string `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty"` + Sid string `protobuf:"bytes,12,opt,name=sid,proto3" json:"sid,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Configuration *Configuration `protobuf:"bytes,8,opt,name=configuration,proto3" json:"configuration,omitempty"` + Tasks []*Task `protobuf:"bytes,5,rep,name=tasks,proto3" json:"tasks,omitempty"` + Events []*Event `protobuf:"bytes,6,rep,name=events,proto3" json:"events,omitempty"` + Dependencies []*Dependency `protobuf:"bytes,7,rep,name=dependencies,proto3" json:"dependencies,omitempty"` + Repository string `protobuf:"bytes,9,opt,name=repository,proto3" json:"repository,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Service) Reset() { *m = Service{} } func (m *Service) String() string { return proto.CompactTextString(m) } func (*Service) ProtoMessage() {} func (*Service) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{0} + return fileDescriptor_service_c543e920957ebb96, []int{0} } func (m *Service) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Service.Unmarshal(m, b) @@ -85,6 +86,13 @@ func (m *Service) GetDescription() string { return "" } +func (m *Service) GetConfiguration() *Configuration { + if m != nil { + return m.Configuration + } + return nil +} + func (m *Service) GetTasks() []*Task { if m != nil { return m.Tasks @@ -128,7 +136,7 @@ func (m *Event) Reset() { *m = Event{} } func (m *Event) String() string { return proto.CompactTextString(m) } func (*Event) ProtoMessage() {} func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{1} + return fileDescriptor_service_c543e920957ebb96, []int{1} } func (m *Event) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Event.Unmarshal(m, b) @@ -192,7 +200,7 @@ func (m *Task) Reset() { *m = Task{} } func (m *Task) String() string { return proto.CompactTextString(m) } func (*Task) ProtoMessage() {} func (*Task) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{2} + return fileDescriptor_service_c543e920957ebb96, []int{2} } func (m *Task) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Task.Unmarshal(m, b) @@ -262,7 +270,7 @@ func (m *Output) Reset() { *m = Output{} } func (m *Output) String() string { return proto.CompactTextString(m) } func (*Output) ProtoMessage() {} func (*Output) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{3} + return fileDescriptor_service_c543e920957ebb96, []int{3} } func (m *Output) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Output.Unmarshal(m, b) @@ -328,7 +336,7 @@ func (m *Parameter) Reset() { *m = Parameter{} } func (m *Parameter) String() string { return proto.CompactTextString(m) } func (*Parameter) ProtoMessage() {} func (*Parameter) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{4} + return fileDescriptor_service_c543e920957ebb96, []int{4} } func (m *Parameter) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Parameter.Unmarshal(m, b) @@ -397,6 +405,76 @@ func (m *Parameter) GetObject() []*Parameter { return nil } +type Configuration struct { + Volumes []string `protobuf:"bytes,1,rep,name=volumes,proto3" json:"volumes,omitempty"` + Volumesfrom []string `protobuf:"bytes,2,rep,name=volumesfrom,proto3" json:"volumesfrom,omitempty"` + Ports []string `protobuf:"bytes,3,rep,name=ports,proto3" json:"ports,omitempty"` + Args []string `protobuf:"bytes,4,rep,name=args,proto3" json:"args,omitempty"` + Command string `protobuf:"bytes,5,opt,name=command,proto3" json:"command,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Configuration) Reset() { *m = Configuration{} } +func (m *Configuration) String() string { return proto.CompactTextString(m) } +func (*Configuration) ProtoMessage() {} +func (*Configuration) Descriptor() ([]byte, []int) { + return fileDescriptor_service_c543e920957ebb96, []int{5} +} +func (m *Configuration) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Configuration.Unmarshal(m, b) +} +func (m *Configuration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Configuration.Marshal(b, m, deterministic) +} +func (dst *Configuration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Configuration.Merge(dst, src) +} +func (m *Configuration) XXX_Size() int { + return xxx_messageInfo_Configuration.Size(m) +} +func (m *Configuration) XXX_DiscardUnknown() { + xxx_messageInfo_Configuration.DiscardUnknown(m) +} + +var xxx_messageInfo_Configuration proto.InternalMessageInfo + +func (m *Configuration) GetVolumes() []string { + if m != nil { + return m.Volumes + } + return nil +} + +func (m *Configuration) GetVolumesfrom() []string { + if m != nil { + return m.Volumesfrom + } + return nil +} + +func (m *Configuration) GetPorts() []string { + if m != nil { + return m.Ports + } + return nil +} + +func (m *Configuration) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +func (m *Configuration) GetCommand() string { + if m != nil { + return m.Command + } + return "" +} + // A dependency is a configuration of an other container that runs separately from the service. type Dependency struct { Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty"` @@ -415,7 +493,7 @@ func (m *Dependency) Reset() { *m = Dependency{} } func (m *Dependency) String() string { return proto.CompactTextString(m) } func (*Dependency) ProtoMessage() {} func (*Dependency) Descriptor() ([]byte, []int) { - return fileDescriptor_service_1b145be26108d61d, []int{5} + return fileDescriptor_service_c543e920957ebb96, []int{6} } func (m *Dependency) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Dependency.Unmarshal(m, b) @@ -490,44 +568,48 @@ func init() { proto.RegisterType((*Task)(nil), "definition.Task") proto.RegisterType((*Output)(nil), "definition.Output") proto.RegisterType((*Parameter)(nil), "definition.Parameter") + proto.RegisterType((*Configuration)(nil), "definition.Configuration") proto.RegisterType((*Dependency)(nil), "definition.Dependency") } func init() { - proto.RegisterFile("protobuf/definition/service.proto", fileDescriptor_service_1b145be26108d61d) -} - -var fileDescriptor_service_1b145be26108d61d = []byte{ - // 483 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x4d, 0x8f, 0xd3, 0x30, - 0x10, 0x55, 0x9b, 0x8f, 0x36, 0xb3, 0x7b, 0x58, 0x2c, 0x40, 0x16, 0x07, 0x54, 0x72, 0x40, 0x5d, - 0x89, 0x6d, 0x25, 0x56, 0x5c, 0x38, 0x22, 0x38, 0x83, 0x0c, 0x27, 0x6e, 0x6e, 0x32, 0x6d, 0x4d, - 0x37, 0x71, 0x64, 0x3b, 0x95, 0x02, 0x7f, 0x83, 0x7f, 0xc1, 0x95, 0xdf, 0xc1, 0x6f, 0x42, 0x1e, - 0x37, 0x6d, 0x90, 0x16, 0x0e, 0x80, 0xb4, 0xb7, 0x99, 0xf7, 0x9e, 0x3d, 0xf3, 0x9e, 0x2c, 0xc3, - 0x93, 0xc6, 0x68, 0xa7, 0x57, 0xed, 0x7a, 0x59, 0xe2, 0x5a, 0xd5, 0xca, 0x29, 0x5d, 0x2f, 0x2d, - 0x9a, 0xbd, 0x2a, 0x70, 0x41, 0x1c, 0x83, 0x13, 0x93, 0x7f, 0x1d, 0xc3, 0xe4, 0x7d, 0x60, 0x19, - 0x83, 0x78, 0x2b, 0xed, 0x96, 0xc3, 0x6c, 0x34, 0xcf, 0x04, 0xd5, 0xec, 0x02, 0x22, 0xab, 0x4a, - 0x7e, 0x4e, 0x90, 0x2f, 0xbd, 0xaa, 0x96, 0x15, 0xf2, 0x51, 0x50, 0xf9, 0x9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ae, 0x41, 0x1e, 0x85, 0x53, 0xbe, 0x66, 0x8f, 0x60, 0xaa, 0x89, 0x95, 0x37, - 0xe4, 0x70, 0x2a, 0x8e, 0xbd, 0xe7, 0x0c, 0x36, 0x28, 0x1d, 0x96, 0xf4, 0x94, 0xa6, 0xe2, 0xd8, - 0xfb, 0xec, 0xf5, 0xea, 0x13, 0x16, 0x8e, 0xc3, 0x1f, 0xb3, 0x0f, 0xa2, 0xfc, 0xfb, 0x08, 0xe0, - 0xf4, 0x68, 0x6f, 0x71, 0x74, 0x1f, 0x12, 0x55, 0xc9, 0x4d, 0x6f, 0x29, 0x34, 0x8c, 0xc3, 0x64, - 0xaf, 0x6f, 0xda, 0x0a, 0x2d, 0x1f, 0xcf, 0xa2, 0x79, 0x26, 0xfa, 0xd6, 0xbb, 0x3d, 0x94, 0x6b, - 0xa3, 0x2b, 0xca, 0x34, 0x13, 0x43, 0xc8, 0xdf, 0xd8, 0x68, 0xe3, 0x2c, 0x8f, 0x89, 0x0b, 0x8d, - 0xcf, 0x40, 0x9a, 0x4d, 0x78, 0x31, 0x99, 0xa0, 0xda, 0x4f, 0x29, 0x74, 0x55, 0xc9, 0xba, 0xe4, - 0x09, 0x4d, 0xef, 0xdb, 0x57, 0x2f, 0x3e, 0x5e, 0x6f, 0x94, 0xdb, 0xb6, 0xab, 0x45, 0xa1, 0xab, - 0x65, 0x85, 0x76, 0x73, 0xb5, 0xd6, 0x6d, 0x5d, 0x4a, 0xfa, 0x7d, 0x0a, 0x6d, 0x70, 0x79, 0xcb, - 0xb7, 0xb4, 0x4a, 0x09, 0xbc, 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0x11, 0x2a, 0xb7, 0x3e, 0xb4, - 0x04, 0x00, 0x00, + proto.RegisterFile("protobuf/definition/service.proto", fileDescriptor_service_c543e920957ebb96) +} + +var fileDescriptor_service_c543e920957ebb96 = []byte{ + // 536 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00,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d, 0xb4, 0x4b, 0xcb, + 0xe3, 0x51, 0x38, 0x3e, 0xba, 0x3c, 0xed, 0x0e, 0xbe, 0x97, 0x76, 0x29, 0x1a, 0x9a, 0x9d, 0x43, + 0x82, 0xb7, 0x58, 0x3a, 0xcb, 0x13, 0x12, 0xde, 0xe9, 0x0a, 0x5f, 0x7b, 0x46, 0xac, 0x05, 0xec, + 0x19, 0x1c, 0xe7, 0x58, 0x61, 0x99, 0x63, 0x99, 0x29, 0xb4, 0xbc, 0x4f, 0x03, 0xf7, 0xba, 0x03, + 0xaf, 0x5a, 0x7e, 0x25, 0x76, 0xb4, 0xec, 0x21, 0x80, 0xc1, 0x4a, 0x5b, 0xe5, 0xb4, 0x59, 0xf1, + 0x21, 0x1d, 0xdc, 0x41, 0xd2, 0x4f, 0x10, 0xd3, 0x32, 0x1f, 0xe0, 0x12, 0x57, 0x3c, 0x6a, 0x02, + 0x5c, 0xe2, 0xea, 0x0f, 0x03, 0x3c, 0x87, 0x28, 0x97, 0x4e, 0xf2, 0x90, 0x4c, 0xde, 0xed, 0x9a, + 0x7c, 0x2b, 0x8d, 0x2c, 0xd0, 0xa1, 0x11, 0x24, 0x49, 0xbf, 0x06, 0x10, 0xf9, 0x48, 0xda, 0xdd, + 0x83, 0xbf, 0xdd, 0x7d, 0x01, 0x89, 0x2a, 0xab, 0x7a, 0x93, 0xe9, 0x2f, 0xb6, 0xaf, 0x45, 0xec, + 0x09, 0xf4, 0x75, 0xed, 0x48, 0xdf, 0x44, 0xca, 0xba, 0xfa, 0x37, 0x44, 0x89, 0x56, 0x92, 0x7e, + 0x86, 0xa4, 0x81, 0xfe, 0x47, 0x54, 0xdf, 0x03, 0x18, 0x6e, 0xb0, 0x7f, 0x96, 0x17, 0x83, 0xc8, + 0xad, 0x2a, 0xe4, 0x61, 0x33, 0xe5, 0x6b, 0xf6, 0x00, 0x06, 0x9a, 0x58, 0x79, 0x43, 0x17, 0x0e, + 0xc4, 0xa6, 0xf7, 0x9c, 0xc1, 0x0a, 0xa5, 0xc3, 0x9c, 0xfe, 0x4a, 0x03, 0xb1, 0xe9, 0x7d, 0xf6, + 0x7a, 0xf6, 0x11, 0x33, 0xc7, 0xe1, 0x60, 0xf6, 0x8d, 0x28, 0xfd, 0x12, 0xc0, 0xc9, 0xce, 0x3b, + 0x62, 0x1c, 0xfa, 0xb7, 0xfa, 0xa6, 0x2e, 0xd0, 0xf2, 0x60, 0x14, 0x8e, 0x87, 0xa2, 0x6d, 0xfd, + 0x21, 0xeb, 0x72, 0x6e, 0x74, 0xc1, 0x7b, 0xc4, 0x76, 0x21, 0x76, 0x06, 0x71, 0xa5, 0x8d, 0xb3, + 0x14, 0xe5, 0x50, 0x34, 0x8d, 0x3f, 0x4f, 0x9a, 0x85, 0xe5, 0x11, 0x81, 0x54, 0xfb, 0x2d, 0x99, + 0x2e, 0x0a, 0x59, 0xe6, 0x3c, 0xa6, 0xab, 0xdb, 0x36, 0xfd, 0x16, 0x00, 0x6c, 0x9f, 0xd1, 0x9e, + 0x8c, 0xcf, 0x20, 0x56, 0x85, 0x5c, 0xb4, 0x21, 0x37, 0x4d, 0xd7, 0x76, 0xef, 0xa0, 0xed, 0xf0, + 0x80, 0xed, 0x68, 0x9f, 0xed, 0xe4, 0x77, 0x6c, 0xbf, 0x78, 0xfa, 0xe1, 0x6a, 0xa1, 0xdc, 0x75, + 0x3d, 0x9b, 0x64, 0xba, 0x98, 0x16, 0x68, 0x17, 0x17, 0x73, 0x5d, 0x97, 0x39, 0x85, 0x3a, 0xcd, + 0xb4, 0xc1, 0xe9, 0x9e, 0x2f, 0xed, 0x2c, 0x21, 0xf0, 0xea, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x5e, 0xa2, 0x91, 0x46, 0x87, 0x05, 0x00, 0x00, } diff --git a/protobuf/definition/service.proto b/protobuf/definition/service.proto index c996a0285..115c0288d 100644 --- a/protobuf/definition/service.proto +++ b/protobuf/definition/service.proto @@ -9,6 +9,7 @@ message Service { string sid = 12; // Service's sid. string name = 1; // Service's name. string description = 2; // Service's description. + Configuration configuration = 8; // Configurations related to the service repeated Task tasks = 5; // The list of tasks this service can execute. repeated Event events = 6; // The list of events this service can emit. repeated Dependency dependencies = 7; // The container dependencies this service requires. @@ -51,6 +52,14 @@ message Parameter { repeated Parameter object = 10; // Optional object structure definition when type is set to `Object` } +message Configuration { + repeated string volumes = 1; // List of volumes. + repeated string volumesfrom = 2; // List of volumes mounted from other dependencies. + repeated string ports = 3; // List of ports the container exposes. + repeated string args = 4; // Args to pass to the container. + string command = 5; // Command to run the container. +} + // A dependency is a configuration of an other container that runs separately from the service. message Dependency { string key = 8; // Dependency's key. diff --git a/service/inject_definition.go b/service/inject_definition.go index ed2bec177..869fc177f 100644 --- a/service/inject_definition.go +++ b/service/inject_definition.go @@ -17,18 +17,17 @@ func (s *Service) injectDefinition(def *importer.ServiceDefinition) { s.Tasks = s.defTasksToService(def.Tasks) s.Dependencies = s.defDependenciesToService(def.Dependencies) - configuration := &Dependency{ - Key: importer.ConfigurationDependencyKey, + s.Configuration = &Dependency{ + Key: MainServiceKey, } if def.Configuration != nil { - configuration.Command = def.Configuration.Command - configuration.Args = def.Configuration.Args - configuration.Ports = def.Configuration.Ports - configuration.Volumes = def.Configuration.Volumes - configuration.VolumesFrom = def.Configuration.VolumesFrom - configuration.Env = def.Configuration.Env + s.Configuration.Command = def.Configuration.Command + s.Configuration.Args = def.Configuration.Args + s.Configuration.Ports = def.Configuration.Ports + s.Configuration.Volumes = def.Configuration.Volumes + s.Configuration.VolumesFrom = def.Configuration.VolumesFrom + s.Configuration.Env = def.Configuration.Env } - s.Dependencies = append(s.Dependencies, configuration) } func (s *Service) defTasksToService(tasks map[string]*importer.Task) []*Task { diff --git a/service/service.go b/service/service.go index 4df42f9ac..b4dbca39b 100644 --- a/service/service.go +++ b/service/service.go @@ -21,6 +21,9 @@ import ( // * this is required for not breaking Service IDs unless there is a behavioral // change. +// MainServiceKey is key for main service. +const MainServiceKey = importer.ConfigurationDependencyKey + // Service represents a MESG service. type Service struct { // Hash is calculated from the combination of service's source and mesg.yml. @@ -46,6 +49,9 @@ type Service struct { // Dependencies are the Docker containers that service can depend on. Dependencies []*Dependency `hash:"name:6"` + // Configuration of the service + Configuration *Dependency `hash:"name:8"` + // Repository holds the service's repository url if it's living on // a Git host. Repository string `hash:"name:7"` @@ -102,8 +108,8 @@ func New(contextDir string, c container.Container, statuses chan DeployStatus, e } // replace default env with new one. - defenv := xos.EnvSliceToMap(s.configuration().Env) - s.configuration().Env = xos.EnvMapToSlice(xos.EnvMergeMaps(defenv, env)) + defenv := xos.EnvSliceToMap(s.Configuration.Env) + s.Configuration.Env = xos.EnvMapToSlice(xos.EnvMergeMaps(defenv, env)) if err := s.deploy(contextDir, c, statuses); err != nil { return nil, err @@ -123,7 +129,7 @@ func (s *Service) deploy(contextDir string, c container.Container, statuses chan s.sendStatus(statuses, "Image built with success", DDonePositive) - s.configuration().Image = imageHash + s.Configuration.Image = imageHash // TODO: the following test should be moved in New function if s.Sid == "" { // make sure that sid doesn't have the same length with id. @@ -165,7 +171,7 @@ func (s *Service) validateConfigurationEnv(env map[string]string) error { for key := range env { exists := false // check if "key=" exists in configuration - for _, env := range s.configuration().Env { + for _, env := range s.Configuration.Env { if strings.HasPrefix(env, key+"=") { exists = true } @@ -181,16 +187,6 @@ func (s *Service) validateConfigurationEnv(env map[string]string) error { return nil } -// helper to return the configuration of the service from the dependencies array -func (s *Service) configuration() *Dependency { - for _, dep := range s.Dependencies { - if dep.Key == importer.ConfigurationDependencyKey { - return dep - } - } - return nil -} - // ErrNotDefinedEnv error returned when optionally given env variables // are not defined in the mesg.yml file. type ErrNotDefinedEnv struct { diff --git a/service/service_test.go b/service/service_test.go index aefb24da7..dc34ce23e 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -23,9 +23,9 @@ func TestNew(t *testing.T) { s, err := New(path, mc, statuses, nil) require.NoError(t, err) - require.Equal(t, "service", s.Dependencies[0].Key) - require.Equal(t, hash, s.Dependencies[0].Image) - require.Len(t, s.Dependencies[0].Env, 0) + require.Equal(t, "service", s.Configuration.Key) + require.Equal(t, hash, s.Configuration.Image) + require.Len(t, s.Configuration.Env, 0) require.Equal(t, DeployStatus{ Message: "Building Docker image...", @@ -52,9 +52,9 @@ func TestNewWithDefaultEnv(t *testing.T) { s, err := New(path, mc, nil, nil) require.NoError(t, err) - require.Equal(t, "service", s.Dependencies[0].Key) - require.Equal(t, hash, s.Dependencies[0].Image) - require.Equal(t, env, s.Dependencies[0].Env) + require.Equal(t, "service", s.Configuration.Key) + require.Equal(t, hash, s.Configuration.Image) + require.Equal(t, env, s.Configuration.Env) mc.AssertExpectations(t) } @@ -71,9 +71,9 @@ func TestNewWithOverwrittenEnv(t *testing.T) { s, err := New(path, mc, nil, xos.EnvSliceToMap(env)) require.NoError(t, err) - require.Equal(t, "service", s.Dependencies[0].Key) - require.Equal(t, hash, s.Dependencies[0].Image) - require.Equal(t, env, s.Dependencies[0].Env) + require.Equal(t, "service", s.Configuration.Key) + require.Equal(t, hash, s.Configuration.Image) + require.Equal(t, env, s.Configuration.Env) mc.AssertExpectations(t) } @@ -106,7 +106,7 @@ func TestInjectDefinitionWithConfig(t *testing.T) { Command: command, }, }) - require.Equal(t, command, s.configuration().Command) + require.Equal(t, command, s.Configuration.Command) } func TestInjectDefinitionWithDependency(t *testing.T) { diff --git a/service/start.go b/service/start.go index 42dd18710..5a1f8021f 100644 --- a/service/start.go +++ b/service/start.go @@ -27,16 +27,29 @@ func (s *Service) Start(c container.Container) (serviceIDs []string, err error) if err != nil { return nil, err } - // BUG: https://github.com/mesg-foundation/core/issues/382 - // After solving this by docker, switch back to deploy in parallel - serviceIDs = make([]string, len(s.Dependencies)) - for i, dep := range s.Dependencies { + + start := func(dep *Dependency) error { serviceID, err := dep.Start(c, s, networkID) if err != nil { s.Stop(c) + return err + } + serviceIDs = append(serviceIDs, serviceID) + return nil + } + + // BUG: https://github.com/mesg-foundation/core/issues/382 + // After solving this by docker, switch back to deploy in parallel + serviceIDs = make([]string, 0) + for _, dep := range s.Dependencies { + if err := start(dep); err != nil { + return nil, err + } + } + if s.Configuration != nil { + if err := start(s.Configuration); err != nil { return nil, err } - serviceIDs[i] = serviceID } return serviceIDs, err } @@ -117,7 +130,11 @@ func (d *Dependency) extractVolumesFrom(s *Service) ([]container.Mount, error) { for _, depName := range d.VolumesFrom { dep, err := s.getDependency(depName) if err != nil { - return nil, err + if depName == MainServiceKey { + dep = s.Configuration + } else { + return nil, err + } } for _, volume := range dep.Volumes { volumesFrom = append(volumesFrom, container.Mount{ diff --git a/service/status.go b/service/status.go index e38f583dc..256427697 100644 --- a/service/status.go +++ b/service/status.go @@ -42,7 +42,10 @@ var containerStatusTypeMappings = map[container.StatusType]StatusType{ // Status returns StatusType of all dependency. func (s *Service) Status(c container.Container) (StatusType, error) { statuses := make(map[container.StatusType]bool) - for _, dep := range s.Dependencies { + for _, dep := range append(s.Dependencies, s.Configuration) { + if dep == nil { + continue + } status, err := dep.Status(c, s) if err != nil { return UNKNOWN, err diff --git a/service/stop.go b/service/stop.go index 0ec346013..ce87d45ec 100644 --- a/service/stop.go +++ b/service/stop.go @@ -24,17 +24,22 @@ func (s *Service) StopDependencies(c container.Container) error { var mutex sync.Mutex var wg sync.WaitGroup var err error + stop := func(d *Dependency) { + defer wg.Done() + errStop := d.Stop(c, s) + mutex.Lock() + defer mutex.Unlock() + if errStop != nil && err == nil { + err = errStop + } + } + if s.Configuration != nil { + wg.Add(1) + go stop(s.Configuration) + } for _, dep := range s.Dependencies { wg.Add(1) - go func(d *Dependency) { - defer wg.Done() - errStop := d.Stop(c, s) - mutex.Lock() - defer mutex.Unlock() - if errStop != nil && err == nil { - err = errStop - } - }(dep) + go stop(dep) } wg.Wait() return err diff --git a/service/volume.go b/service/volume.go index 7f2e59f5f..4087251b2 100644 --- a/service/volume.go +++ b/service/volume.go @@ -13,14 +13,19 @@ func (s *Service) DeleteVolumes(c container.Container) error { wg sync.WaitGroup errs xerrors.SyncErrors ) + delete := func(d *Dependency) { + defer wg.Done() + if err := d.DeleteVolumes(c, s); err != nil { + errs.Append(err) + } + } for _, d := range s.Dependencies { wg.Add(1) - go func(d *Dependency) { - defer wg.Done() - if err := d.DeleteVolumes(c, s); err != nil { - errs.Append(err) - } - }(d) + go delete(d) + } + if s.Configuration != nil { + wg.Add(1) + go delete(s.Configuration) } wg.Wait() return errs.ErrorOrNil()