From 95001f6a11e948aeb81f3f9657921b585095f0c4 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 10:55:47 +0100 Subject: [PATCH 01/13] Move MapToEnv to xos + Add MergeMapEnvs --- container/service_options_test.go | 18 ----------------- daemon/daemon.go | 3 ++- service/start.go | 3 ++- service/start_test.go | 3 ++- x/xos/env.go | 29 +++++++++++++++++++++++++++- x/xos/env_test.go | 32 +++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 22 deletions(-) diff --git a/container/service_options_test.go b/container/service_options_test.go index 0b79c8c65..08096936f 100644 --- a/container/service_options_test.go +++ b/container/service_options_test.go @@ -123,21 +123,3 @@ func TestServiceOptionNetworks(t *testing.T) { require.Equal(t, 1, len(networks[1].Aliases)) require.Equal(t, "test", networks[1].Aliases[0]) } - -func contains(list []string, item string) bool { - for _, itemInList := range list { - if itemInList == item { - return true - } - } - return false -} - -func TestMapToEnv(t *testing.T) { - env := MapToEnv(map[string]string{ - "first": "first_value", - "second": "second_value", - }) - require.True(t, contains(env, "first=first_value")) - require.True(t, contains(env, "second=second_value")) -} diff --git a/daemon/daemon.go b/daemon/daemon.go index 224cdcc02..09184a1de 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -7,6 +7,7 @@ import ( "github.com/mesg-foundation/core/config" "github.com/mesg-foundation/core/container" "github.com/mesg-foundation/core/x/xnet" + "github.com/mesg-foundation/core/x/xos" ) // Daemon is an interface that start, stop etc core as daemon. @@ -61,7 +62,7 @@ func (d *ContainerDaemon) buildServiceOptions(sharedNetworkID string) container. return container.ServiceOptions{ Namespace: []string{}, Image: d.cfg.Core.Image, - Env: container.MapToEnv(d.cfg.DaemonEnv()), + Env: xos.MapToEnv(d.cfg.DaemonEnv()), Mounts: []container.Mount{ { Source: d.cfg.Docker.Socket, diff --git a/service/start.go b/service/start.go index ba6f45aa5..51ff08890 100644 --- a/service/start.go +++ b/service/start.go @@ -7,6 +7,7 @@ import ( "github.com/mesg-foundation/core/config" "github.com/mesg-foundation/core/container" "github.com/mesg-foundation/core/x/xnet" + "github.com/mesg-foundation/core/x/xos" "github.com/mesg-foundation/core/x/xstructhash" ) @@ -68,7 +69,7 @@ func (d *Dependency) Start(networkID string) (containerServiceID string, err err Image: d.Image, Args: d.Args, Command: d.Command, - Env: container.MapToEnv(map[string]string{ + Env: xos.MapToEnv(map[string]string{ "MESG_TOKEN": d.service.Hash, "MESG_ENDPOINT": endpoint, "MESG_ENDPOINT_TCP": endpoint, diff --git a/service/start_test.go b/service/start_test.go index 51fe4dfc7..6ab87a080 100644 --- a/service/start_test.go +++ b/service/start_test.go @@ -9,6 +9,7 @@ import ( "github.com/mesg-foundation/core/container" "github.com/mesg-foundation/core/container/mocks" "github.com/mesg-foundation/core/x/xnet" + "github.com/mesg-foundation/core/x/xos" "github.com/stretchr/testify/require" ) @@ -318,7 +319,7 @@ func mockStartService(d *Dependency, mc *mocks.Container, Image: d.Image, Command: d.Command, Args: d.Args, - Env: container.MapToEnv(map[string]string{ + Env: xos.MapToEnv(map[string]string{ "MESG_TOKEN": d.service.Hash, "MESG_ENDPOINT": endpoint, "MESG_ENDPOINT_TCP": endpoint, diff --git a/x/xos/env.go b/x/xos/env.go index 646ef2f13..cd4386e8e 100644 --- a/x/xos/env.go +++ b/x/xos/env.go @@ -1,6 +1,10 @@ package xos -import "os" +import ( + "fmt" + "os" + "sort" +) // GetenvDefault retrieves the value of the environment variable named by the key. // It returns the value, which will be set to fallback if the variable is empty. @@ -10,3 +14,26 @@ func GetenvDefault(key, fallback string) string { } return fallback } + +// MapToEnv transform a map of key value to a slice of env in the form "key=value". +// Env vars are sorted by names to get an accurate order while testing. +func MapToEnv(data map[string]string) []string { + env := make([]string, 0, len(data)) + for key, value := range data { + env = append(env, fmt.Sprintf("%s=%s", key, value)) + } + sort.Strings(env) + return env +} + +// MergeMapEnvs merges multiple maps storing environment varialbes into single one. +// If the same key exist multiple time, it will be overwritten by the latest occurrence. +func MergeMapEnvs(envs ...map[string]string) map[string]string { + env := make(map[string]string) + for _, e := range envs { + for k, v := range e { + env[k] = v + } + } + return env +} diff --git a/x/xos/env_test.go b/x/xos/env_test.go index b73c8a71b..b0490b379 100644 --- a/x/xos/env_test.go +++ b/x/xos/env_test.go @@ -3,6 +3,8 @@ package xos import ( "os" "testing" + + "github.com/mesg-foundation/core/x/xstrings" ) func TestGetenvDefault(t *testing.T) { @@ -20,3 +22,33 @@ func TestGetenvDefault(t *testing.T) { } } } + +func TestMapToEnv(t *testing.T) { + env := MapToEnv(map[string]string{ + "a": "1", + "b": "2", + }) + for _, v := range []string{"a=1", "b=2"} { + if !xstrings.SliceContains(env, v) { + t.Errorf("envs dosen't contain %s", v) + } + } +} +func TestMergeMapEnvs(t *testing.T) { + envs := []map[string]string{ + { + "a": "1", + "b": "2", + }, + { + "a": "2", + "c": "3", + }, + } + env := MergeMapEnvs(envs...) + for k, v := range map[string]string{"a": "2", "b": "2", "c": "3"} { + if env[k] != v { + t.Errorf("envs dosen't contain %s=%s", k, v) + } + } +} From 78e99814c7bff16c4332f1aba845667a1cabaa97 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 15:59:10 +0100 Subject: [PATCH 02/13] Add env field to grpc deploy request --- interface/grpc/core/deploy.go | 72 ++++----- protobuf/coreapi/api.pb.go | 275 ++++++++++++++++++---------------- protobuf/coreapi/api.proto | 7 + 3 files changed, 189 insertions(+), 165 deletions(-) diff --git a/interface/grpc/core/deploy.go b/interface/grpc/core/deploy.go index 4b4473feb..270b3c1c0 100644 --- a/interface/grpc/core/deploy.go +++ b/interface/grpc/core/deploy.go @@ -1,6 +1,7 @@ package core import ( + "errors" "sync" "github.com/mesg-foundation/core/api" @@ -15,6 +16,10 @@ func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error { var ( statuses = make(chan api.DeployStatus) wg sync.WaitGroup + + service *service.Service + validationError *importer.ValidationError + err error ) wg.Add(1) @@ -23,21 +28,23 @@ func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error { sendDeployStatus(statuses, stream) }() - var ( - service *service.Service - validationError *importer.ValidationError - err error - ) - - sr := newDeployServiceStreamReader(stream) - url, err := sr.GetURL() + // read first requesest from stream and check if it's url or tarball + in, err := stream.Recv() if err != nil { return err } - if url != "" { - service, validationError, err = s.api.DeployServiceFromURL(url, api.DeployServiceStatusOption(statuses)) + + // env must go always with first package + env := in.GetEnv() + + if url := in.GetUrl(); url != "" { + service, validationError, err = s.api.DeployServiceFromURL(url, env, api.DeployServiceStatusOption(statuses)) } else { - service, validationError, err = s.api.DeployService(sr, api.DeployServiceStatusOption(statuses)) + tarball := &deployChunkReader{ + stream: stream, + buf: in.GetChunk(), + } + service, validationError, err = s.api.DeployService(tarball, env, api.DeployServiceStatusOption(statuses)) } wg.Wait() @@ -46,12 +53,16 @@ func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error { } if validationError != nil { return stream.Send(&coreapi.DeployServiceReply{ - Value: &coreapi.DeployServiceReply_ValidationError{ValidationError: validationError.Error()}, + Value: &coreapi.DeployServiceReply_ValidationError{ + ValidationError: validationError.Error(), + }, }) } return stream.Send(&coreapi.DeployServiceReply{ - Value: &coreapi.DeployServiceReply_ServiceID{ServiceID: service.Hash}, + Value: &coreapi.DeployServiceReply_ServiceID{ + ServiceID: service.Hash, + }, }) } @@ -77,37 +88,26 @@ func sendDeployStatus(statuses chan api.DeployStatus, stream coreapi.Core_Deploy } } -type deployServiceStreamReader struct { +type deployChunkReader struct { stream coreapi.Core_DeployServiceServer - data []byte - i int64 -} - -func newDeployServiceStreamReader(stream coreapi.Core_DeployServiceServer) *deployServiceStreamReader { - return &deployServiceStreamReader{stream: stream} + buf []byte + i int } -func (r *deployServiceStreamReader) GetURL() (url string, err error) { - message, err := r.stream.Recv() - if err != nil { - return "", err - } - r.data = message.GetChunk() - return message.GetUrl(), err -} - -func (r *deployServiceStreamReader) Read(p []byte) (n int, err error) { - if r.i >= int64(len(r.data)) { - message, err := r.stream.Recv() +func (r *deployChunkReader) Read(p []byte) (n int, err error) { + if r.i >= len(r.buf) { + in, err := r.stream.Recv() if err != nil { return 0, err } - r.data = message.GetChunk() + if in.GetUrl() != "" { + return 0, errors.New("deploy: got url after tarball stream") + } + r.buf = in.GetChunk() r.i = 0 - return r.Read(p) } - n = copy(p, r.data[r.i:]) - r.i += int64(n) + n = copy(p, r.buf[r.i:]) + r.i += n return n, nil } diff --git a/protobuf/coreapi/api.pb.go b/protobuf/coreapi/api.pb.go index f78bf1cba..0779de2fe 100644 --- a/protobuf/coreapi/api.pb.go +++ b/protobuf/coreapi/api.pb.go @@ -46,7 +46,7 @@ func (x DeployServiceReply_Status_Type) String() string { return proto.EnumName(DeployServiceReply_Status_Type_name, int32(x)) } func (DeployServiceReply_Status_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{15, 0, 0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{15, 0, 0} } type LogData_Type int32 @@ -69,7 +69,7 @@ func (x LogData_Type) String() string { return proto.EnumName(LogData_Type_name, int32(x)) } func (LogData_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{23, 0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{23, 0} } type Service_Status int32 @@ -101,7 +101,7 @@ func (x Service_Status) String() string { return proto.EnumName(Service_Status_name, int32(x)) } func (Service_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{24, 0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{24, 0} } // The request's data for the `CreateWorkflow` API. @@ -125,7 +125,7 @@ func (m *CreateWorkflowRequest) Reset() { *m = CreateWorkflowRequest{} } func (m *CreateWorkflowRequest) String() string { return proto.CompactTextString(m) } func (*CreateWorkflowRequest) ProtoMessage() {} func (*CreateWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{0} } func (m *CreateWorkflowRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateWorkflowRequest.Unmarshal(m, b) @@ -171,7 +171,7 @@ func (m *CreateWorkflowRequest_WorkflowDefinition) Reset() { func (m *CreateWorkflowRequest_WorkflowDefinition) String() string { return proto.CompactTextString(m) } func (*CreateWorkflowRequest_WorkflowDefinition) ProtoMessage() {} func (*CreateWorkflowRequest_WorkflowDefinition) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{0, 0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{0, 0} } func (m *CreateWorkflowRequest_WorkflowDefinition) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateWorkflowRequest_WorkflowDefinition.Unmarshal(m, b) @@ -210,7 +210,7 @@ func (m *CreateWorkflowReply) Reset() { *m = CreateWorkflowReply{} } func (m *CreateWorkflowReply) String() string { return proto.CompactTextString(m) } func (*CreateWorkflowReply) ProtoMessage() {} func (*CreateWorkflowReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{1} + return fileDescriptor_api_8c146b1d59bb46e0, []int{1} } func (m *CreateWorkflowReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateWorkflowReply.Unmarshal(m, b) @@ -256,7 +256,7 @@ func (m *DeleteWorkflowRequest) Reset() { *m = DeleteWorkflowRequest{} } func (m *DeleteWorkflowRequest) String() string { return proto.CompactTextString(m) } func (*DeleteWorkflowRequest) ProtoMessage() {} func (*DeleteWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{2} + return fileDescriptor_api_8c146b1d59bb46e0, []int{2} } func (m *DeleteWorkflowRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteWorkflowRequest.Unmarshal(m, b) @@ -294,7 +294,7 @@ func (m *DeleteWorkflowReply) Reset() { *m = DeleteWorkflowReply{} } func (m *DeleteWorkflowReply) String() string { return proto.CompactTextString(m) } func (*DeleteWorkflowReply) ProtoMessage() {} func (*DeleteWorkflowReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{3} + return fileDescriptor_api_8c146b1d59bb46e0, []int{3} } func (m *DeleteWorkflowReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteWorkflowReply.Unmarshal(m, b) @@ -335,7 +335,7 @@ func (m *ListenEventRequest) Reset() { *m = ListenEventRequest{} } func (m *ListenEventRequest) String() string { return proto.CompactTextString(m) } func (*ListenEventRequest) ProtoMessage() {} func (*ListenEventRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{4} + return fileDescriptor_api_8c146b1d59bb46e0, []int{4} } func (m *ListenEventRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListenEventRequest.Unmarshal(m, b) @@ -391,7 +391,7 @@ func (m *EventData) Reset() { *m = EventData{} } func (m *EventData) String() string { return proto.CompactTextString(m) } func (*EventData) ProtoMessage() {} func (*EventData) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{5} + return fileDescriptor_api_8c146b1d59bb46e0, []int{5} } func (m *EventData) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_EventData.Unmarshal(m, b) @@ -450,7 +450,7 @@ func (m *ListenResultRequest) Reset() { *m = ListenResultRequest{} } func (m *ListenResultRequest) String() string { return proto.CompactTextString(m) } func (*ListenResultRequest) ProtoMessage() {} func (*ListenResultRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{6} + return fileDescriptor_api_8c146b1d59bb46e0, []int{6} } func (m *ListenResultRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListenResultRequest.Unmarshal(m, b) @@ -526,7 +526,7 @@ func (m *ResultData) Reset() { *m = ResultData{} } func (m *ResultData) String() string { return proto.CompactTextString(m) } func (*ResultData) ProtoMessage() {} func (*ResultData) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{7} + return fileDescriptor_api_8c146b1d59bb46e0, []int{7} } func (m *ResultData) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResultData.Unmarshal(m, b) @@ -606,7 +606,7 @@ func (m *ExecuteTaskRequest) Reset() { *m = ExecuteTaskRequest{} } func (m *ExecuteTaskRequest) String() string { return proto.CompactTextString(m) } func (*ExecuteTaskRequest) ProtoMessage() {} func (*ExecuteTaskRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{8} + return fileDescriptor_api_8c146b1d59bb46e0, []int{8} } func (m *ExecuteTaskRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecuteTaskRequest.Unmarshal(m, b) @@ -673,7 +673,7 @@ func (m *ExecuteTaskReply) Reset() { *m = ExecuteTaskReply{} } func (m *ExecuteTaskReply) String() string { return proto.CompactTextString(m) } func (*ExecuteTaskReply) ProtoMessage() {} func (*ExecuteTaskReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{9} + return fileDescriptor_api_8c146b1d59bb46e0, []int{9} } func (m *ExecuteTaskReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecuteTaskReply.Unmarshal(m, b) @@ -719,7 +719,7 @@ func (m *StartServiceRequest) Reset() { *m = StartServiceRequest{} } func (m *StartServiceRequest) String() string { return proto.CompactTextString(m) } func (*StartServiceRequest) ProtoMessage() {} func (*StartServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{10} + return fileDescriptor_api_8c146b1d59bb46e0, []int{10} } func (m *StartServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StartServiceRequest.Unmarshal(m, b) @@ -757,7 +757,7 @@ func (m *StartServiceReply) Reset() { *m = StartServiceReply{} } func (m *StartServiceReply) String() string { return proto.CompactTextString(m) } func (*StartServiceReply) ProtoMessage() {} func (*StartServiceReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{11} + return fileDescriptor_api_8c146b1d59bb46e0, []int{11} } func (m *StartServiceReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StartServiceReply.Unmarshal(m, b) @@ -796,7 +796,7 @@ func (m *StopServiceRequest) Reset() { *m = StopServiceRequest{} } func (m *StopServiceRequest) String() string { return proto.CompactTextString(m) } func (*StopServiceRequest) ProtoMessage() {} func (*StopServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{12} + return fileDescriptor_api_8c146b1d59bb46e0, []int{12} } func (m *StopServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StopServiceRequest.Unmarshal(m, b) @@ -834,7 +834,7 @@ func (m *StopServiceReply) Reset() { *m = StopServiceReply{} } func (m *StopServiceReply) String() string { return proto.CompactTextString(m) } func (*StopServiceReply) ProtoMessage() {} func (*StopServiceReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{13} + return fileDescriptor_api_8c146b1d59bb46e0, []int{13} } func (m *StopServiceReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StopServiceReply.Unmarshal(m, b) @@ -860,12 +860,18 @@ var xxx_messageInfo_StopServiceReply proto.InternalMessageInfo // **Example** // ```json // { +// "env": { +// "key": "value" +// }, // "url": "__SERVICE_GIT_URL__" // } // ``` // or // ```json // { +// "env": { +// "key": "value" +// }, // "chunk": "__SERVICE_GZIPPED_TAR_FILE_CHUNK__" // } // ``` @@ -874,6 +880,7 @@ type DeployServiceRequest struct { // *DeployServiceRequest_Url // *DeployServiceRequest_Chunk Value isDeployServiceRequest_Value `protobuf_oneof:"value"` + Env map[string]string `protobuf:"bytes,4,rep,name=env,proto3" json:"env,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -883,7 +890,7 @@ func (m *DeployServiceRequest) Reset() { *m = DeployServiceRequest{} } func (m *DeployServiceRequest) String() string { return proto.CompactTextString(m) } func (*DeployServiceRequest) ProtoMessage() {} func (*DeployServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{14} + return fileDescriptor_api_8c146b1d59bb46e0, []int{14} } func (m *DeployServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeployServiceRequest.Unmarshal(m, b) @@ -940,6 +947,13 @@ func (m *DeployServiceRequest) GetChunk() []byte { return nil } +func (m *DeployServiceRequest) GetEnv() map[string]string { + if m != nil { + return m.Env + } + return nil +} + // XXX_OneofFuncs is for the internal use of the proto package. func (*DeployServiceRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _DeployServiceRequest_OneofMarshaler, _DeployServiceRequest_OneofUnmarshaler, _DeployServiceRequest_OneofSizer, []interface{}{ @@ -1045,7 +1059,7 @@ func (m *DeployServiceReply) Reset() { *m = DeployServiceReply{} } func (m *DeployServiceReply) String() string { return proto.CompactTextString(m) } func (*DeployServiceReply) ProtoMessage() {} func (*DeployServiceReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{15} + return fileDescriptor_api_8c146b1d59bb46e0, []int{15} } func (m *DeployServiceReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeployServiceReply.Unmarshal(m, b) @@ -1212,7 +1226,7 @@ func (m *DeployServiceReply_Status) Reset() { *m = DeployServiceReply_St func (m *DeployServiceReply_Status) String() string { return proto.CompactTextString(m) } func (*DeployServiceReply_Status) ProtoMessage() {} func (*DeployServiceReply_Status) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{15, 0} + return fileDescriptor_api_8c146b1d59bb46e0, []int{15, 0} } func (m *DeployServiceReply_Status) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeployServiceReply_Status.Unmarshal(m, b) @@ -1266,7 +1280,7 @@ func (m *DeleteServiceRequest) Reset() { *m = DeleteServiceRequest{} } func (m *DeleteServiceRequest) String() string { return proto.CompactTextString(m) } func (*DeleteServiceRequest) ProtoMessage() {} func (*DeleteServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{16} + return fileDescriptor_api_8c146b1d59bb46e0, []int{16} } func (m *DeleteServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteServiceRequest.Unmarshal(m, b) @@ -1311,7 +1325,7 @@ func (m *DeleteServiceReply) Reset() { *m = DeleteServiceReply{} } func (m *DeleteServiceReply) String() string { return proto.CompactTextString(m) } func (*DeleteServiceReply) ProtoMessage() {} func (*DeleteServiceReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{17} + return fileDescriptor_api_8c146b1d59bb46e0, []int{17} } func (m *DeleteServiceReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteServiceReply.Unmarshal(m, b) @@ -1342,7 +1356,7 @@ func (m *ListServicesRequest) Reset() { *m = ListServicesRequest{} } func (m *ListServicesRequest) String() string { return proto.CompactTextString(m) } func (*ListServicesRequest) ProtoMessage() {} func (*ListServicesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{18} + return fileDescriptor_api_8c146b1d59bb46e0, []int{18} } func (m *ListServicesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListServicesRequest.Unmarshal(m, b) @@ -1422,7 +1436,7 @@ func (m *ListServicesReply) Reset() { *m = ListServicesReply{} } func (m *ListServicesReply) String() string { return proto.CompactTextString(m) } func (*ListServicesReply) ProtoMessage() {} func (*ListServicesReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{19} + return fileDescriptor_api_8c146b1d59bb46e0, []int{19} } func (m *ListServicesReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListServicesReply.Unmarshal(m, b) @@ -1468,7 +1482,7 @@ func (m *GetServiceRequest) Reset() { *m = GetServiceRequest{} } func (m *GetServiceRequest) String() string { return proto.CompactTextString(m) } func (*GetServiceRequest) ProtoMessage() {} func (*GetServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{20} + return fileDescriptor_api_8c146b1d59bb46e0, []int{20} } func (m *GetServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetServiceRequest.Unmarshal(m, b) @@ -1555,7 +1569,7 @@ func (m *GetServiceReply) Reset() { *m = GetServiceReply{} } func (m *GetServiceReply) String() string { return proto.CompactTextString(m) } func (*GetServiceReply) ProtoMessage() {} func (*GetServiceReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{21} + return fileDescriptor_api_8c146b1d59bb46e0, []int{21} } func (m *GetServiceReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetServiceReply.Unmarshal(m, b) @@ -1603,7 +1617,7 @@ func (m *ServiceLogsRequest) Reset() { *m = ServiceLogsRequest{} } func (m *ServiceLogsRequest) String() string { return proto.CompactTextString(m) } func (*ServiceLogsRequest) ProtoMessage() {} func (*ServiceLogsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{22} + return fileDescriptor_api_8c146b1d59bb46e0, []int{22} } func (m *ServiceLogsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ServiceLogsRequest.Unmarshal(m, b) @@ -1661,7 +1675,7 @@ func (m *LogData) Reset() { *m = LogData{} } func (m *LogData) String() string { return proto.CompactTextString(m) } func (*LogData) ProtoMessage() {} func (*LogData) Descriptor() ([]byte, []int) { - return fileDescriptor_api_6c3db8a9ae613837, []int{23} + return fileDescriptor_api_8c146b1d59bb46e0, []int{23} } func (m *LogData) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LogData.Unmarshal(m, b) @@ -1723,7 +1737,7 @@ 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_api_6c3db8a9ae613837, []int{24} + return fileDescriptor_api_8c146b1d59bb46e0, []int{24} } func (m *Service) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Service.Unmarshal(m, b) @@ -1828,7 +1842,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_api_6c3db8a9ae613837, []int{25} + return fileDescriptor_api_8c146b1d59bb46e0, []int{25} } func (m *Event) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Event.Unmarshal(m, b) @@ -1892,7 +1906,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_api_6c3db8a9ae613837, []int{26} + return fileDescriptor_api_8c146b1d59bb46e0, []int{26} } func (m *Task) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Task.Unmarshal(m, b) @@ -1962,7 +1976,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_api_6c3db8a9ae613837, []int{27} + return fileDescriptor_api_8c146b1d59bb46e0, []int{27} } func (m *Output) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Output.Unmarshal(m, b) @@ -2026,7 +2040,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_api_6c3db8a9ae613837, []int{28} + return fileDescriptor_api_8c146b1d59bb46e0, []int{28} } func (m *Parameter) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Parameter.Unmarshal(m, b) @@ -2098,7 +2112,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_api_6c3db8a9ae613837, []int{29} + return fileDescriptor_api_8c146b1d59bb46e0, []int{29} } func (m *Dependency) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Dependency.Unmarshal(m, b) @@ -2177,6 +2191,7 @@ func init() { proto.RegisterType((*StopServiceRequest)(nil), "api.StopServiceRequest") proto.RegisterType((*StopServiceReply)(nil), "api.StopServiceReply") proto.RegisterType((*DeployServiceRequest)(nil), "api.DeployServiceRequest") + proto.RegisterMapType((map[string]string)(nil), "api.DeployServiceRequest.EnvEntry") proto.RegisterType((*DeployServiceReply)(nil), "api.DeployServiceReply") proto.RegisterType((*DeployServiceReply_Status)(nil), "api.DeployServiceReply.Status") proto.RegisterType((*DeleteServiceRequest)(nil), "api.DeleteServiceRequest") @@ -2772,98 +2787,100 @@ var _Core_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("github.com/mesg-foundation/core/protobuf/coreapi/api.proto", fileDescriptor_api_6c3db8a9ae613837) -} - -var fileDescriptor_api_6c3db8a9ae613837 = []byte{ - // 1409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xdf, 0x6f, 0x1b, 0xc5, - 0x13, 0xbf, 0x8b, 0x7f, 0xcf, 0x39, 0xa9, 0xb3, 0x49, 0xda, 0xfb, 0x5a, 0x5f, 0xb5, 0xd1, 0x42, - 0x4b, 0x04, 0x6a, 0x52, 0x5c, 0x10, 0x6d, 0x45, 0x55, 0xb5, 0xb5, 0x69, 0x4c, 0x83, 0x13, 0x9d, - 0xdd, 0x56, 0xe2, 0x05, 0x5d, 0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xb0, 0xd3, 0x66, 0x53, 0x96, 0x77, 0x7c, - 0x59, 0x70, 0x07, 0xb6, 0x96, 0x05, 0xfd, 0xe9, 0x9c, 0x0e, 0x80, 0x1c, 0x39, 0x61, 0xc4, 0xdc, - 0xce, 0x39, 0x73, 0xa3, 0xe4, 0xf0, 0xff, 0xa1, 0x16, 0xb2, 0xe0, 0xdc, 0x19, 0xb2, 0x54, 0xc7, - 0x02, 0x20, 0xbb, 0x60, 0x30, 0x2e, 0xfd, 0x99, 0x33, 0x8d, 0x58, 0x20, 0xef, 0xa2, 0x42, 0xb4, - 0x03, 0x35, 0xd4, 0xd7, 0xb6, 0x23, 0x9b, 0x34, 0xa1, 0x8a, 0xbc, 0xe7, 0x6c, 0x2e, 0x75, 0xa5, - 0x34, 0x37, 0xc4, 0x12, 0x41, 0xa9, 0x68, 0x01, 0xd0, 0x9f, 0x74, 0xd8, 0x12, 0xde, 0x59, 0x2c, - 0x8c, 0xa7, 0x17, 0x74, 0xef, 0x3a, 0x40, 0x64, 0x87, 0x67, 0x19, 0xef, 0x14, 0x84, 0x50, 0xa8, - 0x7b, 0x71, 0xe4, 0xc7, 0x89, 0xff, 0x05, 0x94, 0xc8, 0x60, 0x42, 0xc7, 0x44, 0x10, 0xa1, 0x59, - 0xdc, 0x2d, 0x08, 0x1d, 0x09, 0x42, 0x7f, 0xd3, 0x01, 0x84, 0x4f, 0x78, 0x45, 0x1e, 0x91, 0x6f, - 0xd9, 0x30, 0xe6, 0x99, 0x4b, 0x5d, 0x52, 0x21, 0x62, 0x42, 0x85, 0xbb, 0xc0, 0x63, 0x20, 0x3c, - 0x4a, 0x48, 0x7e, 0x19, 0x61, 0x9a, 0xf3, 0x84, 0x2f, 0x0b, 0x80, 0x3b, 0x22, 0x08, 0x8c, 0x50, - 0x51, 0x5c, 0x66, 0x81, 0x90, 0x77, 0x61, 0x3d, 0x35, 0x33, 0xb0, 0x27, 0xa1, 0x59, 0x42, 0x5f, - 0xb3, 0x20, 0xaf, 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 0x6e, 0xe7, 0x70, 0x71, 0xfa, 0x1e, 0x18, 0xca, 0x8c, 0x4e, 0x82, 0x9a, 0x9b, - 0xda, 0xcd, 0xba, 0x3a, 0x39, 0xb1, 0x26, 0x0e, 0x61, 0x23, 0xfb, 0x07, 0x49, 0x9a, 0x6f, 0xfe, - 0x71, 0x6d, 0x9a, 0x2b, 0x79, 0xc2, 0x87, 0x43, 0xd8, 0xc8, 0xfe, 0x3b, 0x4a, 0x4d, 0x2b, 0xff, - 0x3c, 0xa5, 0xa6, 0x55, 0x3f, 0x9b, 0xda, 0x93, 0xda, 0x97, 0x15, 0xf9, 0x0b, 0xfe, 0xba, 0x8c, - 0xff, 0xdf, 0x77, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x46, 0x17, 0xab, 0xbd, 0x0f, 0x00, - 0x00, + proto.RegisterFile("github.com/mesg-foundation/core/protobuf/coreapi/api.proto", fileDescriptor_api_8c146b1d59bb46e0) +} + +var fileDescriptor_api_8c146b1d59bb46e0 = []byte{ + // 1453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcb, 0x8f, 0xdb, 0x54, + 0x17, 0xb7, 0xf3, 0xce, 0x71, 0x66, 0x9a, 0xb9, 0x33, 0xd3, 0xfa, 0xb3, 0x3e, 0xb5, 0xa3, 0xfb, + 0x7d, 0x2d, 0x23, 0x50, 0x33, 0x25, 0x2d, 0xd0, 0x56, 0x54, 0x55, 0xdb, 0x84, 0x4e, 0xe8, 0x90, + 0x19, 0x39, 0x69, 0x2b, 0xb1, 0x41, 0x6e, 0x72, 0x27, 0x63, 0x8d, 0x63, 0x1b, 0x3f, 0x02, 0x59, + 0x23, 0xf6, 0xac, 0x60, 0x85, 0xc4, 0x16, 0x09, 0x89, 0x35, 0x12, 0x7f, 0x1c, 0xba, 0x0f, 0xdb, + 0xd7, 0x71, 0x5a, 0xa6, 0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, 0x7b, 0x42, 0x52, 0x19, 0x19, 0x80, + 0xf6, 0x40, 0x23, 0xf4, 0xf4, 0x27, 0xb6, 0x13, 0x91, 0x40, 0xbc, 0x45, 0x86, 0x70, 0x1f, 0x9a, + 0x4c, 0x5e, 0xcf, 0x8a, 0x2c, 0x64, 0x40, 0x83, 0xf1, 0x9e, 0x91, 0xa5, 0x90, 0x95, 0xd2, 0x54, + 0x11, 0x49, 0x0e, 0x0a, 0x41, 0x19, 0x80, 0x7f, 0x50, 0x61, 0x9b, 0x5b, 0x67, 0x92, 0x30, 0x76, + 0x2e, 0x68, 0xde, 0x55, 0x80, 0xc8, 0x0a, 0xcf, 0x73, 0xd6, 0x49, 0x08, 0xc2, 0xd0, 0xf2, 0xe2, + 0xc8, 0x8f, 0x13, 0xfb, 0xcb, 0xec, 0x44, 0x0e, 0xe3, 0x32, 0x66, 0x9c, 0x08, 0xf5, 0xca, 0x5e, + 0x99, 0xcb, 0x48, 0x10, 0xfc, 0x8b, 0x0a, 0xc0, 0x6d, 0x62, 0x4f, 0xa4, 0x1e, 0xf9, 0x9a, 0x4c, + 0x62, 0x1a, 0xb9, 0xd4, 0x24, 0x19, 0x42, 0x3a, 0xd4, 0xa9, 0x09, 0xd4, 0x07, 0xdc, 0xa2, 0x84, + 0xa4, 0x8f, 0xe1, 0xaa, 0x29, 0x8f, 0xdb, 0x92, 0x01, 0xd4, 0x10, 0x4e, 0x30, 0x0f, 0x55, 0xf8, + 0x63, 0x32, 0x04, 0xfd, 0x1f, 0x36, 0x52, 0x35, 0x63, 0x6b, 0x16, 0xea, 0x55, 0x66, 0x6b, 0x1e, + 0xa4, 0xf9, 0x8d, 0xfa, 0x0c, 0x21, 0x63, 0x2b, 0x3c, 0xbf, 0x98, 0x1f, 0xdf, 0x68, 0xb2, 0xed, + 0x26, 0x36, 0x09, 0x93, 0x53, 0xa0, 0x68, 0x52, 0x65, 0x9d, 0x49, 0x77, 0xa0, 0x9d, 0xb3, 0x88, + 0x26, 0xf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e, + 0x29, 0xcc, 0x7e, 0xac, 0xa0, 0x8f, 0x01, 0xb2, 0x01, 0x8d, 0xf8, 0xb9, 0xc2, 0x90, 0x37, 0x76, + 0x0a, 0x38, 0xbf, 0x7d, 0x17, 0x34, 0x69, 0x46, 0x27, 0x4e, 0x2d, 0x4c, 0x6d, 0xa3, 0x25, 0x4f, + 0x4e, 0x96, 0x13, 0x87, 0xb0, 0x99, 0xff, 0x61, 0x45, 0xc6, 0xeb, 0xff, 0x93, 0x0d, 0x7d, 0x2d, + 0x8f, 0xdb, 0x70, 0x08, 0x9b, 0xf9, 0x5f, 0x55, 0x21, 0x69, 0xed, 0x8f, 0xae, 0x90, 0xb4, 0xee, + 0xdf, 0x56, 0x79, 0xdc, 0xfc, 0xbc, 0x2e, 0xfe, 0xf8, 0x5f, 0xd5, 0xd8, 0xef, 0xfe, 0xed, 0x3f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x1c, 0xdf, 0x45, 0x2c, 0x10, 0x00, 0x00, } diff --git a/protobuf/coreapi/api.proto b/protobuf/coreapi/api.proto index dc2a40a55..ef647cd22 100644 --- a/protobuf/coreapi/api.proto +++ b/protobuf/coreapi/api.proto @@ -230,12 +230,18 @@ message StopServiceReply { // **Example** // ```json // { +// "env": { +// "key": "value" +// }, // "url": "__SERVICE_GIT_URL__" // } // ``` // or // ```json // { +// "env": { +// "key": "value" +// }, // "chunk": "__SERVICE_GZIPPED_TAR_FILE_CHUNK__" // } // ``` @@ -244,6 +250,7 @@ message DeployServiceRequest { string url = 2; // Git repo url of service. When url provided, stream will be closed after the first receive. bytes chunk = 3; // Chunks of gzipped tar archive of service. If chunk provided, stream should be closed by client after all chunks sent. } + map env = 4; // Env used to deploy service. } // The data received from the reply stream of the `DeployService` API. From bc600051592e96aa41e0850e2220b49cff36a21b Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 15:59:36 +0100 Subject: [PATCH 03/13] Support env in commands for deploy service --- commands/commands.go | 2 +- commands/provider/service_deployer.go | 13 ++++++++++--- commands/service_deploy.go | 7 +++++-- commands/service_deploy_test.go | 15 +++++++++++++++ commands/service_dev.go | 5 ++++- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 commands/service_deploy_test.go diff --git a/commands/commands.go b/commands/commands.go index 224ba3646..3dc7e9b4a 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -24,7 +24,7 @@ type ServiceExecutor interface { ServiceByID(id string) (*coreapi.Service, error) ServiceDeleteAll(deleteData bool) error ServiceDelete(deleteData bool, ids ...string) error - ServiceDeploy(path string, statuses chan provider.DeployStatus) (id string, validationError, err error) + ServiceDeploy(path string, env map[string]string, statuses chan provider.DeployStatus) (id string, validationError, err error) ServiceListenEvents(id, eventFilter string) (chan *coreapi.EventData, chan error, error) ServiceListenResults(id, taskFilter, outputFilter string, tagFilters []string) (chan *coreapi.ResultData, chan error, error) ServiceLogs(id string, dependencies ...string) (logs []*provider.Log, closer func(), err error) diff --git a/commands/provider/service_deployer.go b/commands/provider/service_deployer.go index 9d476885b..fe753d91b 100644 --- a/commands/provider/service_deployer.go +++ b/commands/provider/service_deployer.go @@ -40,7 +40,7 @@ type deploymentResult struct { } // ServiceDeploy deploys service from given path. -func (p *ServiceProvider) ServiceDeploy(path string, statuses chan DeployStatus) (id string, +func (p *ServiceProvider) ServiceDeploy(path string, env map[string]string, statuses chan DeployStatus) (id string, validationError, err error) { stream, err := p.client.DeployService(context.Background()) if err != nil { @@ -53,11 +53,12 @@ func (p *ServiceProvider) ServiceDeploy(path string, statuses chan DeployStatus) if govalidator.IsURL(path) { if err := stream.Send(&coreapi.DeployServiceRequest{ Value: &coreapi.DeployServiceRequest_Url{Url: path}, + Env: env, }); err != nil { return "", nil, err } } else { - if err := deployServiceSendServiceContext(path, stream); err != nil { + if err := deployServiceSendServiceContext(path, env, stream); err != nil { return "", nil, err } } @@ -71,7 +72,7 @@ func (p *ServiceProvider) ServiceDeploy(path string, statuses chan DeployStatus) return result.serviceID, result.validationError, result.err } -func deployServiceSendServiceContext(path string, stream coreapi.Core_DeployServiceClient) error { +func deployServiceSendServiceContext(path string, env map[string]string, stream coreapi.Core_DeployServiceClient) error { archive, err := archive.TarWithOptions(path, &archive.TarOptions{ Compression: archive.Gzip, }) @@ -79,6 +80,12 @@ func deployServiceSendServiceContext(path string, stream coreapi.Core_DeployServ return err } + if len(env) > 0 { + if err := stream.Send(&coreapi.DeployServiceRequest{Env: env}); err != nil { + return err + } + } + buf := make([]byte, 1024) for { n, err := archive.Read(buf) diff --git a/commands/service_deploy.go b/commands/service_deploy.go index f4823a627..63f68649b 100644 --- a/commands/service_deploy.go +++ b/commands/service_deploy.go @@ -8,6 +8,7 @@ import ( "github.com/mesg-foundation/core/commands/provider" "github.com/mesg-foundation/core/utils/pretty" "github.com/mesg-foundation/core/x/xerrors" + "github.com/mesg-foundation/core/x/xpflag" "github.com/spf13/cobra" ) @@ -15,6 +16,7 @@ type serviceDeployCmd struct { baseCmd path string + env map[string]string e ServiceExecutor } @@ -27,11 +29,12 @@ func newServiceDeployCmd(e ServiceExecutor) *serviceDeployCmd { Long: `Deploy a service. To get more information, see the [deploy page from the documentation](https://docs.mesg.com/guide/service/deploy-a-service.html)`, - Example: `mesg-core service deploy PATH_TO_SERVICE`, + Example: `mesg-core service deploy [PATH_TO_SERVICE|URL_TO_SERVICE]`, PreRunE: c.preRunE, RunE: c.runE, Args: cobra.MaximumNArgs(1), }) + c.cmd.Flags().Var(xpflag.NewStringToStringValue(&c.env, nil), "env", "set env defined in mesg.yml (configuration.env)") return c } @@ -52,7 +55,7 @@ func (c *serviceDeployCmd) runE(cmd *cobra.Command, args []string) error { printDeployStatuses(statuses) }() - id, validationError, err := c.e.ServiceDeploy(c.path, statuses) + id, validationError, err := c.e.ServiceDeploy(c.path, c.env, statuses) wg.Wait() pretty.DestroySpinner() diff --git a/commands/service_deploy_test.go b/commands/service_deploy_test.go new file mode 100644 index 000000000..0c1355951 --- /dev/null +++ b/commands/service_deploy_test.go @@ -0,0 +1,15 @@ +package commands + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestServiceDeployCmdFlags(t *testing.T) { + c := newServiceDeployCmd(nil) + + flags := c.cmd.Flags() + flags.Set("env", "a=1,b=2") + require.Equal(t, map[string]string{"a": "1", "b": "2"}, c.env) +} diff --git a/commands/service_dev.go b/commands/service_dev.go index 072eb0eb1..f74f91735 100644 --- a/commands/service_dev.go +++ b/commands/service_dev.go @@ -10,6 +10,7 @@ import ( "github.com/mesg-foundation/core/commands/provider" "github.com/mesg-foundation/core/utils/pretty" "github.com/mesg-foundation/core/x/xerrors" + "github.com/mesg-foundation/core/x/xpflag" "github.com/mesg-foundation/core/x/xsignal" "github.com/spf13/cobra" ) @@ -21,6 +22,7 @@ type serviceDevCmd struct { taskFilter string outputFilter string path string + env map[string]string e ServiceExecutor } @@ -42,6 +44,7 @@ func newServiceDevCmd(e ServiceExecutor) *serviceDevCmd { c.cmd.Flags().StringVarP(&c.eventFilter, "event-filter", "e", c.eventFilter, "Only log the data of the given event") c.cmd.Flags().StringVarP(&c.taskFilter, "task-filter", "t", "", "Only log the result of the given task") c.cmd.Flags().StringVarP(&c.outputFilter, "output-filter", "o", "", "Only log the data of the given output of a task result. If set, you also need to set the task in --task-filter") + c.cmd.Flags().Var(xpflag.NewStringToStringValue(&c.env, nil), "env", "set env defined in mesg.yml (configuration.env)") return c } @@ -62,7 +65,7 @@ func (c *serviceDevCmd) runE(cmd *cobra.Command, args []string) error { printDeployStatuses(statuses) }() - id, validationError, err := c.e.ServiceDeploy(c.path, statuses) + id, validationError, err := c.e.ServiceDeploy(c.path, c.env, statuses) wg.Wait() pretty.DestroySpinner() From f3481711e07f967b99a51500d7f21c0811ca1085 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 16:00:20 +0100 Subject: [PATCH 04/13] Add+validate env field in mesg.yml --- service/importer/assets/schema.go | 4 ++-- service/importer/assets/schema.json | 3 +++ service/importer/definition.go | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/service/importer/assets/schema.go b/service/importer/assets/schema.go index 89c2c3046..91a3c3313 100644 --- a/service/importer/assets/schema.go +++ b/service/importer/assets/schema.go @@ -66,7 +66,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _serviceImporterAssetsSchemaJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x57\x4f\x4f\xdc\x3e\x10\xbd\xe7\x53\x58\x86\xdb\xef\xb7\x2c\x55\xa5\x4a\xec\xad\xbd\x55\xaa\x0a\x12\xb7\x42\x5a\x99\x64\xb2\x98\x26\xb6\xf1\x1f\xd4\x2d\xda\xef\x5e\xc5\xd9\xcd\x3a\xb1\x9d\x04\xd8\xa2\xaa\xdb\x9c\x12\x8f\x67\xc6\xef\xcd\xf8\xd9\x79\x4c\x10\xc2\xc7\x2a\xbb\x85\x8a\xe0\x05\xc2\xb7\x5a\x8b\xc5\x7c\x7e\xa7\x38\x9b\x35\xa3\x27\x5c\x2e\xe7\xb9\x24\x85\x9e\x9d\xbe\x9b\x37\x63\x47\xf8\xff\xda\x4f\xaf\x04\xd4\x4e\xfc\xe6\x0e\x32\xdd\x8c\x49\xb8\x37\x54\x42\x8e\x17\xe8\x2a\x41\x08\x21\xcc\x48\x05\x38\x41\x28\xb5\x76\x92\xe7\x54\x53\xce\x48\x79\x21\xb9\x00\xa9\x29\x28\xbc\x40\x05\x29\x15\xd8\x09\xc2\x1d\x7e\x74\x42\x6c\xbf\x9c\xc4\x4a\x4b\xca\x96\x36\xb1\x1d\xaf\x28\xfb\x04\x6c\xa9\x6f\xf1\x02\xbd\xb1\x83\xeb\xc6\x86\x15\xcd\x27\x05\x20\x3f\xda\x00\x6f\xcf\xda\x61\x41\xb4\x06\xc9\x6a\x8f\xaf\x57\xa7\xb3\x33\x32\xfb\xf9\x7e\xf6\xe5\xfa\xfa\xe4\xdb\x2c\xfd\xef\x18\x77\x32\xe5\xa0\x32\x49\x45\x8d\x71\x20\x63\xc7\x45\x82\xe0\x8a\x6a\x2e\x57\x53\x3d\xe0\x01\x98\x56\xee\x6c\xce\xe0\xbc\x68\x49\xaf\x9f\xc7\x5d\x08\x66\xca\x12\x6f\x9d\xad\xad\x7d\x0b\x97\xb1\xb5\x8d\x95\xab\x9d\xb8\xa1\xe8\xc2\xaf\x5e\x3b\xc5\xa1\xae\xe1\xad\x3f\xa3\x6e\x45\x09\x35\x0a\x7c\x34\xcf\xa1\xa0\xcc\xe6\x56\x73\x0b\x17\x77\xe6\xae\x93\xd0\xfb\xf6\x2d\xed\xb0\xa5\x89\xfa\x7e\x38\x64\xd5\x68\x9f\xcf\x55\x0e\x02\x58\x0e\x2c\xeb\xae\x2a\x86\x7b\x12\xe6\x11\xbc\x63\x58\x23\x38\xdb\x95\xae\xba\x55\xf0\x14\xa8\xb5\xd0\x8a\x2c\xc1\xa5\x26\xf5\xc8\x58\x77\xc8\xc8\x38\x2b\xe8\xd2\x48\xd2\xdf\xcd\xa3\x2b\x4a\xb6\xc1\x6c\x28\xec\xcc\xda\xa9\x9a\x20\x92\x54\xa0\x41\xfe\x8d\xbd\x39\xb0\x96\x27\xad\x67\xb8\xa4\xbb\x54\xbd\xe1\xd4\x8b\x11\x38\x57\x3a\xf6\xde\x19\x13\x04\xe3\x4a\xb1\xfb\xac\xfb\xd9\xa2\xe7\xc0\x8b\xc3\x72\xd1\xb0\x36\x16\xf3\x86\xf3\x12\x08\x9b\x16\x74\xe3\x34\x65\x91\xbe\x77\x7d\x1c\x31\x53\x05\x6b\x63\xad\x97\x71\x4f\x84\xf0\x67\x53\xdd\x80\x8c\x59\x3f\x6c\x60\x44\xcc\xe7\x4d\x77\x05\x8c\x5e\x03\xa0\xa6\x28\x05\x31\xa5\xae\xf1\x5c\xc6\x48\x4f\x86\xbe\x9f\x7a\xec\xec\x4d\x42\x83\x5b\x00\x73\xa3\x85\xd1\x6a\x8b\x22\xdd\x29\x6e\x44\x6a\x03\x5d\x1e\x6d\x43\xa7\x53\x06\xba\x79\x92\x3b\x65\x76\x99\x93\x74\xdd\x91\xc5\x60\x2c\x05\x99\x84\x7d\x05\xdb\x12\x18\xc1\x74\x60\x4a\x9a\x13\x4d\x0e\x46\x49\x2d\xd8\x48\xbc\xe9\xcd\xd4\x66\x78\x81\x6c\xac\xfd\xbb\xfd\x6f\xd6\x0d\xb7\xd0\x7f\xac\x68\x04\x0a\xf4\x94\x5d\x1e\x24\xd7\xb9\xa2\xed\xed\x72\x1b\x61\xad\xb9\x6d\x0e\xe3\xee\xe8\x85\xff\xf7\xda\x67\x24\xe3\x55\x45\x58\xfe\x1c\x32\x89\x5c\x7a\x2a\xe7\x5f\x35\xd1\xc8\x75\x13\xf5\xae\x9c\x9d\xf4\x44\x4a\xb2\xf2\xf5\x89\x6a\xa8\x22\x4a\x31\xbc\x6d\xe3\x5b\x28\x0d\x42\x7c\xe0\xa5\xa9\x3c\x51\x7a\x25\x94\x86\xd1\x7b\x03\x1f\x37\x58\xb5\x34\xbe\xf6\xbe\x36\x11\x85\xe4\xd5\x3f\x32\x04\x97\xfe\xf9\x7e\x20\x34\x74\x25\xb0\xfe\x1b\x4d\xd6\xc9\xaf\x00\x00\x00\xff\xff\xa2\xc0\xe3\xdf\xf3\x13\x00\x00") +var _serviceImporterAssetsSchemaJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x57\x4f\x4f\xdc\x3e\x10\xbd\xe7\x53\x58\x86\xdb\xef\xb7\x2c\x55\xa5\x4a\xec\xad\xbd\x55\xaa\x0a\x12\xb7\x42\x5a\x99\x64\xb2\x98\x26\xb6\xf1\x1f\xd4\x2d\xda\xef\x5e\xc5\xd9\xcd\x3a\xb1\x9d\x04\xd8\xa2\xaa\xdb\x9c\x12\x8f\x67\xc6\xef\xcd\xf8\xd9\x79\x4c\x10\xc2\xc7\x2a\xbb\x85\x8a\xe0\x05\xc2\xb7\x5a\x8b\xc5\x7c\x7e\xa7\x38\x9b\x35\xa3\x27\x5c\x2e\xe7\xb9\x24\x85\x9e\x9d\xbe\x9b\x37\x63\x47\xf8\xff\xda\x4f\xaf\x04\xd4\x4e\xfc\xe6\x0e\x32\xdd\x8c\x49\xb8\x37\x54\x42\x8e\x17\xe8\x2a\x41\x08\x21\xcc\x48\x05\x38\x41\x28\xb5\x76\x92\xe7\x54\x53\xce\x48\x79\x21\xb9\x00\xa9\x29\x28\xbc\x40\x05\x29\x15\xd8\x09\xc2\x1d\x7e\x74\x42\x6c\xbf\x9c\xc4\x4a\x4b\xca\x96\x36\xb1\x1d\xaf\x28\xfb\x04\x6c\xa9\x6f\xf1\x02\xbd\xb1\x83\xeb\xc6\x86\x15\xcd\x27\x05\x20\x3f\xda\x00\x6f\xcf\xda\x61\x41\xb4\x06\xc9\x6a\x8f\xaf\x57\xa7\xb3\x33\x32\xfb\xf9\x7e\xf6\xe5\xfa\xfa\xe4\xdb\x2c\xfd\xef\x18\x77\x32\xe5\xa0\x32\x49\x45\x8d\x71\x20\x63\xc7\x45\x82\xe0\x8a\x6a\x2e\x57\x53\x3d\xe0\x01\x98\x56\xee\x6c\xce\xe0\xbc\x68\x49\xaf\x9f\xc7\x5d\x08\x66\xca\x12\x6f\x9d\xad\xad\x7d\x0b\x97\xb1\xb5\x8d\x95\xab\x9d\xb8\xa1\xe8\xc2\xaf\x5e\x3b\xc5\xa1\xae\xe1\xad\x3f\xa3\x6e\x45\x09\x35\x0a\x7c\x34\xcf\xa1\xa0\xcc\xe6\x56\x73\x0b\x17\x77\xe6\xae\x93\xd0\xfb\xf6\x2d\xed\xb0\xa5\x89\xfa\x7e\x38\x64\xd5\x68\x9f\xcf\x55\x0e\x02\x58\x0e\x2c\xeb\xae\x2a\x86\x7b\x12\xe6\x11\xbc\x63\x58\x23\x38\xdb\x95\xae\xba\x55\xf0\x14\xa8\xb5\xd0\x8a\x2c\xc1\xa5\x26\xf5\xc8\x58\x77\xc8\xc8\x38\x2b\xe8\xd2\x48\xd2\xdf\xcd\xa3\x2b\x4a\xb6\xc1\x6c\x28\xec\xcc\xda\xa9\x9a\x20\x92\x54\xa0\x41\xfe\x8d\xbd\x39\xb0\x96\x27\xad\x67\xb8\xa4\xbb\x54\xbd\xe1\xd4\x8b\x11\x38\x57\x3a\xf6\xde\x19\x13\x04\xe3\x4a\xb1\xfb\xac\xfb\xd9\xa2\xe7\xc0\x8b\xc3\x72\xd1\xb0\x36\x16\xf3\x86\xf3\x12\x08\x9b\x16\x74\xe3\x34\x65\x91\xbe\x77\x7d\x1c\x31\x53\x05\x6b\x63\xad\x97\x71\x4f\x84\xf0\x67\x53\xdd\x80\x8c\x59\x3f\x6c\x60\x44\xcc\xe7\x4d\x77\x05\x8c\x5e\x03\xa0\xa6\x28\x05\x31\xa5\xae\xf1\x5c\xc6\x48\x4f\x86\xbe\x9f\x7a\xec\xec\x4d\x42\x83\x5b\x00\x73\xa3\x85\xd1\x6a\x8b\x22\xdd\x29\x6e\x44\x6a\x03\x5d\x1e\x6d\x43\xa7\x53\x06\xba\x79\x92\x3b\x65\x76\x99\x93\x74\xdd\x91\xc5\x60\x2c\x05\x99\x84\x7d\x05\xdb\x12\x18\xc1\x74\x60\x4a\x9a\x13\x4d\x0e\x46\x49\x2d\xd8\x48\xbc\xe9\xcd\xd4\x66\x78\x81\x6c\xac\xfd\xbb\xfd\x6f\xd6\x0d\xb7\xd0\x7f\xac\x68\x04\x0a\xf4\x94\x5d\x1e\x24\xd7\xb9\xa2\xed\xed\x72\x1b\x61\xad\xb9\x6d\x0e\xe3\xee\xe8\x85\xff\xf7\xda\x67\x24\xe3\x55\x45\x58\xfe\x1c\x32\x89\x5c\x7a\x2a\xe7\x5f\x35\xd1\xc8\x75\x13\xf5\xae\x9c\x9d\xf4\x44\x4a\xb2\xf2\xf5\x89\x6a\xa8\x22\x4a\x31\xbc\x6d\xe3\x5b\x28\x0d\x42\x7c\xe0\xa5\xa9\x3c\x51\x7a\x25\x94\x86\xd1\x7b\x03\x1f\x37\x58\xb5\x34\xbe\xf6\xbe\x36\x11\x85\xe4\xd5\x3f\x32\x04\x97\xfe\xf9\x7e\x78\x34\x00\x7b\x18\xb9\xe4\xc4\x94\xb3\xfe\x89\x4d\xd6\xc9\xaf\x00\x00\x00\xff\xff\xa6\x34\xa7\xa3\x2a\x14\x00\x00") func serviceImporterAssetsSchemaJsonBytes() ([]byte, error) { return bindataRead( @@ -81,7 +81,7 @@ func serviceImporterAssetsSchemaJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "service/importer/assets/schema.json", size: 5107, mode: os.FileMode(420), modTime: time.Unix(1544151489, 0)} + info := bindataFileInfo{name: "service/importer/assets/schema.json", size: 5162, mode: os.FileMode(420), modTime: time.Unix(1544626110, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/service/importer/assets/schema.json b/service/importer/assets/schema.json index a740b4831..192cd1dd6 100644 --- a/service/importer/assets/schema.json +++ b/service/importer/assets/schema.json @@ -225,6 +225,9 @@ } } ] + }, + "env": { + "type": "object" } } } diff --git a/service/importer/definition.go b/service/importer/definition.go index be0f59c5d..f4284d620 100644 --- a/service/importer/definition.go +++ b/service/importer/definition.go @@ -60,6 +60,9 @@ type Dependency struct { // Args hold the args to pass to the Docker container Args []string `yaml:"args"` + + // Env is map of all defiend environments variables. + Env map[string]*Parameter `yaml:"env"` } // Task describes a service task. From 4f9271a525eba527d6253da619a47b493a0b3504 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 16:00:48 +0100 Subject: [PATCH 05/13] Supply env in api and service --- api/deploy.go | 15 +++++++++------ service/dependency.go | 6 ++++++ service/inject_definition.go | 10 ++++++++-- service/service.go | 20 ++++++++++++++++++-- service/start.go | 4 ++-- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/api/deploy.go b/api/deploy.go index 28d072212..8d5f3d131 100644 --- a/api/deploy.go +++ b/api/deploy.go @@ -25,18 +25,18 @@ func DeployServiceStatusOption(statuses chan DeployStatus) DeployServiceOption { } // DeployService deploys a service from a gzipped tarball. -func (a *API) DeployService(r io.Reader, options ...DeployServiceOption) (*service.Service, +func (a *API) DeployService(r io.Reader, env map[string]string, options ...DeployServiceOption) (*service.Service, *importer.ValidationError, error) { - return newServiceDeployer(a, options...).FromGzippedTar(r) + return newServiceDeployer(a, env, options...).FromGzippedTar(r) } // DeployServiceFromURL deploys a service living at a Git host. // Supported URL types: // - https://github.com/mesg-foundation/service-ethereum // - https://github.com/mesg-foundation/service-ethereum#branchName -func (a *API) DeployServiceFromURL(url string, options ...DeployServiceOption) (*service.Service, +func (a *API) DeployServiceFromURL(url string, env map[string]string, options ...DeployServiceOption) (*service.Service, *importer.ValidationError, error) { - return newServiceDeployer(a, options...).FromGitURL(url) + return newServiceDeployer(a, env, options...).FromGitURL(url) } // serviceDeployer provides functionalities to deploy a MESG service. @@ -44,6 +44,8 @@ type serviceDeployer struct { // statuses receives status messages produced during deployment. statuses chan DeployStatus + env map[string]string + api *API } @@ -70,9 +72,10 @@ type DeployStatus struct { } // newServiceDeployer creates a new serviceDeployer with given api and options. -func newServiceDeployer(api *API, options ...DeployServiceOption) *serviceDeployer { +func newServiceDeployer(api *API, env map[string]string, options ...DeployServiceOption) *serviceDeployer { d := &serviceDeployer{ api: api, + env: env, } for _, option := range options { option(d) @@ -126,7 +129,7 @@ func (d *serviceDeployer) deploy(r io.Reader) (*service.Service, *importer.Valid d.forwardDeployStatuses(statuses) }() - s, err := service.New(r, + s, err := service.New(r, d.env, service.ContainerOption(d.api.container), service.DeployStatusOption(statuses), ) diff --git a/service/dependency.go b/service/dependency.go index 65b5ccca1..21a2c9bf6 100644 --- a/service/dependency.go +++ b/service/dependency.go @@ -31,6 +31,12 @@ type Dependency struct { // Argument holds the args to pass to the Docker container Args []string `hash:"name:7"` + // Env is map of all defiend environments variables. + Env []*Parameter `hash:"name:8"` + + // EnvValue is map of all values for Env + EnvValue map[string]string `hash:"name:9"` + // service is the dependency's service. service *Service `hash:"-"` } diff --git a/service/inject_definition.go b/service/inject_definition.go index 00caaca32..d5ed4dcd3 100644 --- a/service/inject_definition.go +++ b/service/inject_definition.go @@ -8,7 +8,7 @@ import ( ) // injectDefinition applies service definition to Service type. -func (s *Service) injectDefinition(def *importer.ServiceDefinition) { +func (s *Service) injectDefinition(def *importer.ServiceDefinition, env map[string]string) { s.Name = def.Name s.SID = def.SID s.Description = def.Description @@ -17,6 +17,11 @@ func (s *Service) injectDefinition(def *importer.ServiceDefinition) { s.Tasks = s.defTasksToService(def.Tasks) s.Dependencies = s.defDependenciesToService(def.Dependencies) + // insert env into dependencies + for _, d := range s.Dependencies { + d.EnvValue = env + } + s.configuration = &Dependency{} if def.Configuration != nil { s.configuration.Command = def.Configuration.Command @@ -24,6 +29,8 @@ func (s *Service) injectDefinition(def *importer.ServiceDefinition) { s.configuration.Ports = def.Configuration.Ports s.configuration.Volumes = def.Configuration.Volumes s.configuration.VolumesFrom = def.Configuration.VolumesFrom + s.configuration.Env = s.defParametersToService(def.Configuration.Env) + s.configuration.EnvValue = env } } @@ -47,7 +54,6 @@ func (s *Service) defTasksToService(tasks map[string]*importer.Task) []*Task { Inputs: s.defParametersToService(task.Inputs), Outputs: s.defOutputsToService(task.Outputs), } - } return ts } diff --git a/service/service.go b/service/service.go index 9fde0f923..e21720136 100644 --- a/service/service.go +++ b/service/service.go @@ -90,7 +90,7 @@ type DeployStatus struct { } // New creates a new service from a gzipped tarball. -func New(tarball io.Reader, options ...Option) (*Service, error) { +func New(tarball io.Reader, env map[string]string, options ...Option) (*Service, error) { s := &Service{} defer s.closeStatus() @@ -107,7 +107,11 @@ func New(tarball io.Reader, options ...Option) (*Service, error) { if err != nil { return nil, err } - s.injectDefinition(def) + s.injectDefinition(def, env) + + if err := s.validateEnv(); err != nil { + return nil, err + } if err := s.deploy(); err != nil { return nil, err @@ -239,3 +243,15 @@ func (s *Service) getDependency(dependencyKey string) (*Dependency, error) { } return nil, fmt.Errorf("dependency %s do not exist", dependencyKey) } + +func (s *Service) validateEnv() error { + for _, p := range s.configuration.Env { + if p.Optional { + continue + } + if s.configuration.EnvValue[p.Key] == "" { + return fmt.Errorf("service env %s is empty", p.Key) + } + } + return nil +} diff --git a/service/start.go b/service/start.go index 51ff08890..872ccd5a2 100644 --- a/service/start.go +++ b/service/start.go @@ -69,11 +69,11 @@ func (d *Dependency) Start(networkID string) (containerServiceID string, err err Image: d.Image, Args: d.Args, Command: d.Command, - Env: xos.MapToEnv(map[string]string{ + Env: xos.MapToEnv(xos.MergeMapEnvs(map[string]string{ "MESG_TOKEN": d.service.Hash, "MESG_ENDPOINT": endpoint, "MESG_ENDPOINT_TCP": endpoint, - }), + }, d.EnvValue)), Mounts: append(volumes, volumesFrom...), Ports: d.extractPorts(), Networks: []container.Network{ From 76540ead1036ab732e568922bdb082f8b47bd0dc Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 16:00:58 +0100 Subject: [PATCH 06/13] Update systemservice deploy --- systemservices/deployer/deployer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemservices/deployer/deployer.go b/systemservices/deployer/deployer.go index 22a0ad875..a76b5289d 100644 --- a/systemservices/deployer/deployer.go +++ b/systemservices/deployer/deployer.go @@ -100,7 +100,7 @@ func (d *Deployer) deployService(relativePath string) (*service.Service, error) return nil, err } - sr, validationErr, err := d.api.DeployService(archive) + sr, validationErr, err := d.api.DeployService(archive, nil) if err != nil { return nil, err } From 312fc32d61675b5131bae1d672138b43334efd45 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 16:01:06 +0100 Subject: [PATCH 07/13] Regenerate docs --- docs/api/core.md | 55 ++++++++++++++++++++++++++++ docs/cli/mesg-core_service_deploy.md | 5 ++- docs/cli/mesg-core_service_dev.md | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/docs/api/core.md b/docs/api/core.md index 7a330dfcb..3b0594aef 100644 --- a/docs/api/core.md +++ b/docs/api/core.md @@ -67,6 +67,8 @@ Subscribe to a stream that listens for events from a service. + + @@ -142,6 +144,8 @@ The request's data for the `ListenEvent` stream's API. + + @@ -254,6 +258,8 @@ Subscribe to a stream that listens for task's result from a service. + + @@ -355,6 +361,8 @@ The request's data for the `ListenResult` stream API. + + @@ -437,6 +445,8 @@ Execute a service's task through Core. + + @@ -528,6 +538,8 @@ The request's data for the `ExecuteTask` API. + + @@ -651,6 +663,8 @@ Start a service. The service must be already deployed to Core. + + @@ -736,6 +750,8 @@ The request's data for the `StartService` API. + + @@ -823,6 +839,8 @@ Stop a service. The service must be already deployed to Core. + + @@ -908,6 +926,8 @@ The request's data for the `StopService` API. + + @@ -961,12 +981,18 @@ Stream should be closed after url or all chunks sent to server. **Example** ```json { + "env": { + "key": "value" + }, "url": "__SERVICE_GIT_URL__" } ``` or ```json { + "env": { + "key": "value" + }, "chunk": "__SERVICE_GZIPPED_TAR_FILE_CHUNK__" } ``` @@ -976,6 +1002,9 @@ or | ----- | ---- | ----------- | | url | [string](#string) | Git repo url of service. When url provided, stream will be closed after the first receive. | | chunk | [bytes](#bytes) | Chunks of gzipped tar archive of service. If chunk provided, stream should be closed by client after all chunks sent. | +| env | [DeployServiceRequest.EnvEntry](#api.DeployServiceRequest.EnvEntry)[] | Env used to deploy service. | + + @@ -1125,6 +1154,8 @@ or + + @@ -1219,6 +1250,8 @@ Request's data of the `DeleteService` API. + + @@ -1294,6 +1327,8 @@ Reply of `DeleteService` API doesn't contain any data. + + @@ -1342,6 +1377,8 @@ List all services already deployed in Core. + + @@ -1415,6 +1452,8 @@ Reply of `ListServices` API doesn't contain any data. + + @@ -1547,6 +1586,8 @@ Get the definition of an already-deployed service from its ID. + + @@ -1632,6 +1673,8 @@ The request's data for the `GetService` API. + + @@ -1788,6 +1831,8 @@ ServiceLogs gives a stream for dependency logs of a service. + + @@ -1867,6 +1912,8 @@ The request's data for `ServiceLogs` API. + + @@ -2006,6 +2053,8 @@ The request's data for the `CreateWorkflow` API. + + @@ -2093,6 +2142,8 @@ The reply's data of the `CreateWorkflow` API. + + @@ -2186,6 +2237,8 @@ The request's data for the `DeleteWorkflow` API. + + @@ -2261,6 +2314,8 @@ Reply of `DeleteWorkflow` API doesn't contain any data. + + diff --git a/docs/cli/mesg-core_service_deploy.md b/docs/cli/mesg-core_service_deploy.md index 3098728f4..98d01d2fb 100644 --- a/docs/cli/mesg-core_service_deploy.md +++ b/docs/cli/mesg-core_service_deploy.md @@ -15,13 +15,14 @@ mesg-core service deploy [flags] ### Examples ``` -mesg-core service deploy PATH_TO_SERVICE +mesg-core service deploy [PATH_TO_SERVICE|URL_TO_SERVICE] ``` ### Options ``` - -h, --help help for deploy + --env key=value set env defined in mesg.yml (configuration.env) + -h, --help help for deploy ``` ### Options inherited from parent commands diff --git a/docs/cli/mesg-core_service_dev.md b/docs/cli/mesg-core_service_dev.md index 7bb63f7d6..28a35aaaf 100644 --- a/docs/cli/mesg-core_service_dev.md +++ b/docs/cli/mesg-core_service_dev.md @@ -19,6 +19,7 @@ mesg-core service dev PATH ### Options ``` + --env key=value set env defined in mesg.yml (configuration.env) -e, --event-filter string Only log the data of the given event (default "*") -h, --help help for dev -o, --output-filter string Only log the data of the given output of a task result. If set, you also need to set the task in --task-filter From 434c1c19aab7c9e7583b735adab8384efd344a40 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 12 Dec 2018 18:30:33 +0100 Subject: [PATCH 08/13] Fix tests --- api/deploy_test.go | 10 +++++----- commands/mocks/Executor.go | 18 +++++++++--------- interface/grpc/core/delete_test.go | 2 +- interface/grpc/core/execute_test.go | 10 +++++----- interface/grpc/core/get_service_test.go | 2 +- interface/grpc/core/start_test.go | 2 +- interface/grpc/core/stop_test.go | 2 +- interface/grpc/service/emit_event_test.go | 10 +++++----- interface/grpc/service/submit_result_test.go | 8 ++++---- service/service_test.go | 6 +++--- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/api/deploy_test.go b/api/deploy_test.go index a075f01d4..cbd358bbc 100644 --- a/api/deploy_test.go +++ b/api/deploy_test.go @@ -30,7 +30,7 @@ func TestDeployService(t *testing.T) { archive, err := xarchive.GzippedTar(path) require.NoError(t, err) - service, validationError, err := a.DeployService(archive, DeployServiceStatusOption(statuses)) + service, validationError, err := a.DeployService(archive, nil, DeployServiceStatusOption(statuses)) require.Nil(t, validationError) require.NoError(t, err) require.Len(t, service.Hash, 40) @@ -76,7 +76,7 @@ func TestDeployInvalidService(t *testing.T) { archive, err := xarchive.GzippedTar(path) require.NoError(t, err) - service, validationError, err := a.DeployService(archive, DeployServiceStatusOption(statuses)) + service, validationError, err := a.DeployService(archive, nil, DeployServiceStatusOption(statuses)) require.Nil(t, service) require.NoError(t, err) require.Equal(t, (&importer.ValidationError{}).Error(), validationError.Error()) @@ -114,7 +114,7 @@ func TestDeployServiceFromURL(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - service, validationError, err := a.DeployServiceFromURL(url, DeployServiceStatusOption(statuses)) + service, validationError, err := a.DeployServiceFromURL(url, nil, DeployServiceStatusOption(statuses)) require.Nil(t, validationError) require.NoError(t, err) require.Len(t, service.Hash, 40) @@ -156,7 +156,7 @@ func TestDeployServiceFromURL(t *testing.T) { func TestCreateTempFolder(t *testing.T) { a, _, closer := newAPIAndDockerTest(t) defer closer() - deployer := newServiceDeployer(a) + deployer := newServiceDeployer(a, nil) path, err := deployer.createTempDir() defer os.RemoveAll(path) @@ -167,7 +167,7 @@ func TestCreateTempFolder(t *testing.T) { func TestRemoveTempFolder(t *testing.T) { a, _, closer := newAPIAndDockerTest(t) defer closer() - deployer := newServiceDeployer(a) + deployer := newServiceDeployer(a, nil) path, _ := deployer.createTempDir() err := os.RemoveAll(path) diff --git a/commands/mocks/Executor.go b/commands/mocks/Executor.go index 017f73d81..df2a6553d 100644 --- a/commands/mocks/Executor.go +++ b/commands/mocks/Executor.go @@ -130,27 +130,27 @@ func (_m *Executor) ServiceDeleteAll(deleteData bool) error { return r0 } -// ServiceDeploy provides a mock function with given fields: path, statuses -func (_m *Executor) ServiceDeploy(path string, statuses chan provider.DeployStatus) (string, error, error) { - ret := _m.Called(path, statuses) +// ServiceDeploy provides a mock function with given fields: path, env, statuses +func (_m *Executor) ServiceDeploy(path string, env map[string]string, statuses chan provider.DeployStatus) (string, error, error) { + ret := _m.Called(path, env, statuses) var r0 string - if rf, ok := ret.Get(0).(func(string, chan provider.DeployStatus) string); ok { - r0 = rf(path, statuses) + if rf, ok := ret.Get(0).(func(string, map[string]string, chan provider.DeployStatus) string); ok { + r0 = rf(path, env, statuses) } else { r0 = ret.Get(0).(string) } var r1 error - if rf, ok := ret.Get(1).(func(string, chan provider.DeployStatus) error); ok { - r1 = rf(path, statuses) + if rf, ok := ret.Get(1).(func(string, map[string]string, chan provider.DeployStatus) error); ok { + r1 = rf(path, env, statuses) } else { r1 = ret.Error(1) } var r2 error - if rf, ok := ret.Get(2).(func(string, chan provider.DeployStatus) error); ok { - r2 = rf(path, statuses) + if rf, ok := ret.Get(2).(func(string, map[string]string, chan provider.DeployStatus) error); ok { + r2 = rf(path, env, statuses) } else { r2 = ret.Error(2) } diff --git a/interface/grpc/core/delete_test.go b/interface/grpc/core/delete_test.go index b544d9c0a..6b1579cc9 100644 --- a/interface/grpc/core/delete_test.go +++ b/interface/grpc/core/delete_test.go @@ -16,7 +16,7 @@ func TestDeleteService(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, path)) + s, validationErr, err := server.api.DeployService(serviceTar(t, path), nil) require.Zero(t, validationErr) require.NoError(t, err) diff --git a/interface/grpc/core/execute_test.go b/interface/grpc/core/execute_test.go index a06d513d3..dbc168577 100644 --- a/interface/grpc/core/execute_test.go +++ b/interface/grpc/core/execute_test.go @@ -18,7 +18,7 @@ func TestExecute(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -39,7 +39,7 @@ func TestExecuteWithInvalidJSON(t *testing.T) { server, closer := newServer(t) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -60,7 +60,7 @@ func TestExecuteWithInvalidTask(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -88,7 +88,7 @@ func TestExecuteWithInvalidTaskInput(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -112,7 +112,7 @@ func TestExecuteWithNonRunningService(t *testing.T) { server, closer := newServer(t) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/interface/grpc/core/get_service_test.go b/interface/grpc/core/get_service_test.go index a4a0241a2..8eecfe6e1 100644 --- a/interface/grpc/core/get_service_test.go +++ b/interface/grpc/core/get_service_test.go @@ -12,7 +12,7 @@ func TestGetService(t *testing.T) { server, closer := newServer(t) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/interface/grpc/core/start_test.go b/interface/grpc/core/start_test.go index 1f5736fce..1113278ce 100644 --- a/interface/grpc/core/start_test.go +++ b/interface/grpc/core/start_test.go @@ -16,7 +16,7 @@ func TestStartService(t *testing.T) { // we use a test service without tasks definition here otherwise we need to // spin up the gRPC server in order to prevent service exit with a failure // because it'll try to listen for tasks. - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/interface/grpc/core/stop_test.go b/interface/grpc/core/stop_test.go index bcc2be543..198a15d62 100644 --- a/interface/grpc/core/stop_test.go +++ b/interface/grpc/core/stop_test.go @@ -16,7 +16,7 @@ func TestStopService(t *testing.T) { // we use a test service without tasks definition here otherwise we need to // spin up the gRPC server in order to prevent service exit with a failure // because it'll try to listen for tasks. - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/interface/grpc/service/emit_event_test.go b/interface/grpc/service/emit_event_test.go index a61a4686a..087f692e1 100644 --- a/interface/grpc/service/emit_event_test.go +++ b/interface/grpc/service/emit_event_test.go @@ -17,7 +17,7 @@ func TestEmit(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -51,7 +51,7 @@ func TestEmitNoData(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -70,7 +70,7 @@ func TestEmitWrongData(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -90,7 +90,7 @@ func TestEmitWrongEvent(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -115,7 +115,7 @@ func TestEmitInvalidData(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, eventServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/interface/grpc/service/submit_result_test.go b/interface/grpc/service/submit_result_test.go index 4041d59d7..b0d8fe816 100644 --- a/interface/grpc/service/submit_result_test.go +++ b/interface/grpc/service/submit_result_test.go @@ -23,7 +23,7 @@ func TestSubmit(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -69,7 +69,7 @@ func TestSubmitWithInvalidJSON(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -119,7 +119,7 @@ func TestSubmitWithNonExistentOutputKey(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) @@ -156,7 +156,7 @@ func TestSubmitWithInvalidTaskOutputs(t *testing.T) { ) defer closer() - s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath)) + s, validationErr, err := server.api.DeployService(serviceTar(t, taskServicePath), nil) require.Zero(t, validationErr) require.NoError(t, err) defer server.api.DeleteService(s.Hash, false) diff --git a/service/service_test.go b/service/service_test.go index 7c7a7be21..b9cb7dfed 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -51,7 +51,7 @@ func TestNew(t *testing.T) { statuses := make(chan DeployStatus, 4) - s, err := New(archive, + s, err := New(archive, nil, ContainerOption(mc), DeployStatusOption(statuses), ) @@ -89,7 +89,7 @@ func TestInjectDefinitionWithConfig(t *testing.T) { Configuration: &importer.Dependency{ Command: command, }, - }) + }, nil) require.Equal(t, command, s.configuration.Command) } @@ -104,6 +104,6 @@ func TestInjectDefinitionWithDependency(t *testing.T) { Image: image, }, }, - }) + }, nil) require.Equal(t, s.Dependencies[0].Image, image) } From 62934d5d94f418669f2a960480ca143f11703921 Mon Sep 17 00:00:00 2001 From: krhubert Date: Fri, 14 Dec 2018 16:03:49 +0100 Subject: [PATCH 09/13] Replace env.Parametr with key=value syntax --- container/service_options.go | 14 ---------- daemon/daemon.go | 2 +- interface/grpc/core/deploy.go | 12 ++++++--- service/dependency.go | 7 ++--- service/importer/assets/schema.go | 4 +-- service/importer/assets/schema.json | 6 ++++- service/importer/definition.go | 4 +-- service/inject_definition.go | 10 ++----- service/service.go | 31 ++++++++++++++++------ service/service_test.go | 4 +-- service/start.go | 10 +++---- service/start_test.go | 11 ++++---- x/xos/env.go | 41 ++++++++++++++++++++++------- x/xos/env_test.go | 36 ++++++++++++++++++++----- 14 files changed, 119 insertions(+), 73 deletions(-) diff --git a/container/service_options.go b/container/service_options.go index 579d85b8a..36741e0b5 100644 --- a/container/service_options.go +++ b/container/service_options.go @@ -1,9 +1,7 @@ package container import ( - "fmt" "os" - "sort" "strconv" "strings" @@ -137,15 +135,3 @@ func mergeLabels(l1 map[string]string, l2 map[string]string) map[string]string { } return l1 } - -// MapToEnv transform a map of key value to a array of env string. -// env vars sorted by names to get an accurate order while testing, otherwise -// comparing a string slice with different orders will fail. -func MapToEnv(data map[string]string) []string { - env := make([]string, 0, len(data)) - for key, value := range data { - env = append(env, fmt.Sprintf("%s=%s", key, value)) - } - sort.Strings(env) - return env -} diff --git a/daemon/daemon.go b/daemon/daemon.go index 09184a1de..3bf5e0bc1 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -62,7 +62,7 @@ func (d *ContainerDaemon) buildServiceOptions(sharedNetworkID string) container. return container.ServiceOptions{ Namespace: []string{}, Image: d.cfg.Core.Image, - Env: xos.MapToEnv(d.cfg.DaemonEnv()), + Env: xos.EnvMapToSlice(d.cfg.DaemonEnv()), Mounts: []container.Mount{ { Source: d.cfg.Docker.Socket, diff --git a/interface/grpc/core/deploy.go b/interface/grpc/core/deploy.go index 270b3c1c0..7e69bed12 100644 --- a/interface/grpc/core/deploy.go +++ b/interface/grpc/core/deploy.go @@ -15,6 +15,7 @@ import ( func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error { var ( statuses = make(chan api.DeployStatus) + option = api.DeployServiceStatusOption(statuses) wg sync.WaitGroup service *service.Service @@ -34,18 +35,22 @@ func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error { return err } - // env must go always with first package + // env must be set with first package (always) env := in.GetEnv() if url := in.GetUrl(); url != "" { - service, validationError, err = s.api.DeployServiceFromURL(url, env, api.DeployServiceStatusOption(statuses)) + service, validationError, err = s.api.DeployServiceFromURL(url, env, option) } else { + // create tarball reader with first chunk of bytes tarball := &deployChunkReader{ stream: stream, buf: in.GetChunk(), } - service, validationError, err = s.api.DeployService(tarball, env, api.DeployServiceStatusOption(statuses)) + service, validationError, err = s.api.DeployService(tarball, env, option) } + + // wait for statuses to be sent first, otherwise sending multiple messages at the + // same time may cause messages to be sent in different order. wg.Wait() if err != nil { @@ -88,6 +93,7 @@ func sendDeployStatus(statuses chan api.DeployStatus, stream coreapi.Core_Deploy } } +// deployChunkReader implements io.Reader for stream chunks. type deployChunkReader struct { stream coreapi.Core_DeployServiceServer diff --git a/service/dependency.go b/service/dependency.go index 21a2c9bf6..a53bcbd22 100644 --- a/service/dependency.go +++ b/service/dependency.go @@ -31,11 +31,8 @@ type Dependency struct { // Argument holds the args to pass to the Docker container Args []string `hash:"name:7"` - // Env is map of all defiend environments variables. - Env []*Parameter `hash:"name:8"` - - // EnvValue is map of all values for Env - EnvValue map[string]string `hash:"name:9"` + // Env is a slice of all key=value. + Env []string `hash:"name:8"` // service is the dependency's service. service *Service `hash:"-"` diff --git a/service/importer/assets/schema.go b/service/importer/assets/schema.go index 91a3c3313..b822d6de4 100644 --- a/service/importer/assets/schema.go +++ b/service/importer/assets/schema.go @@ -66,7 +66,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _serviceImporterAssetsSchemaJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x57\x4f\x4f\xdc\x3e\x10\xbd\xe7\x53\x58\x86\xdb\xef\xb7\x2c\x55\xa5\x4a\xec\xad\xbd\x55\xaa\x0a\x12\xb7\x42\x5a\x99\x64\xb2\x98\x26\xb6\xf1\x1f\xd4\x2d\xda\xef\x5e\xc5\xd9\xcd\x3a\xb1\x9d\x04\xd8\xa2\xaa\xdb\x9c\x12\x8f\x67\xc6\xef\xcd\xf8\xd9\x79\x4c\x10\xc2\xc7\x2a\xbb\x85\x8a\xe0\x05\xc2\xb7\x5a\x8b\xc5\x7c\x7e\xa7\x38\x9b\x35\xa3\x27\x5c\x2e\xe7\xb9\x24\x85\x9e\x9d\xbe\x9b\x37\x63\x47\xf8\xff\xda\x4f\xaf\x04\xd4\x4e\xfc\xe6\x0e\x32\xdd\x8c\x49\xb8\x37\x54\x42\x8e\x17\xe8\x2a\x41\x08\x21\xcc\x48\x05\x38\x41\x28\xb5\x76\x92\xe7\x54\x53\xce\x48\x79\x21\xb9\x00\xa9\x29\x28\xbc\x40\x05\x29\x15\xd8\x09\xc2\x1d\x7e\x74\x42\x6c\xbf\x9c\xc4\x4a\x4b\xca\x96\x36\xb1\x1d\xaf\x28\xfb\x04\x6c\xa9\x6f\xf1\x02\xbd\xb1\x83\xeb\xc6\x86\x15\xcd\x27\x05\x20\x3f\xda\x00\x6f\xcf\xda\x61\x41\xb4\x06\xc9\x6a\x8f\xaf\x57\xa7\xb3\x33\x32\xfb\xf9\x7e\xf6\xe5\xfa\xfa\xe4\xdb\x2c\xfd\xef\x18\x77\x32\xe5\xa0\x32\x49\x45\x8d\x71\x20\x63\xc7\x45\x82\xe0\x8a\x6a\x2e\x57\x53\x3d\xe0\x01\x98\x56\xee\x6c\xce\xe0\xbc\x68\x49\xaf\x9f\xc7\x5d\x08\x66\xca\x12\x6f\x9d\xad\xad\x7d\x0b\x97\xb1\xb5\x8d\x95\xab\x9d\xb8\xa1\xe8\xc2\xaf\x5e\x3b\xc5\xa1\xae\xe1\xad\x3f\xa3\x6e\x45\x09\x35\x0a\x7c\x34\xcf\xa1\xa0\xcc\xe6\x56\x73\x0b\x17\x77\xe6\xae\x93\xd0\xfb\xf6\x2d\xed\xb0\xa5\x89\xfa\x7e\x38\x64\xd5\x68\x9f\xcf\x55\x0e\x02\x58\x0e\x2c\xeb\xae\x2a\x86\x7b\x12\xe6\x11\xbc\x63\x58\x23\x38\xdb\x95\xae\xba\x55\xf0\x14\xa8\xb5\xd0\x8a\x2c\xc1\xa5\x26\xf5\xc8\x58\x77\xc8\xc8\x38\x2b\xe8\xd2\x48\xd2\xdf\xcd\xa3\x2b\x4a\xb6\xc1\x6c\x28\xec\xcc\xda\xa9\x9a\x20\x92\x54\xa0\x41\xfe\x8d\xbd\x39\xb0\x96\x27\xad\x67\xb8\xa4\xbb\x54\xbd\xe1\xd4\x8b\x11\x38\x57\x3a\xf6\xde\x19\x13\x04\xe3\x4a\xb1\xfb\xac\xfb\xd9\xa2\xe7\xc0\x8b\xc3\x72\xd1\xb0\x36\x16\xf3\x86\xf3\x12\x08\x9b\x16\x74\xe3\x34\x65\x91\xbe\x77\x7d\x1c\x31\x53\x05\x6b\x63\xad\x97\x71\x4f\x84\xf0\x67\x53\xdd\x80\x8c\x59\x3f\x6c\x60\x44\xcc\xe7\x4d\x77\x05\x8c\x5e\x03\xa0\xa6\x28\x05\x31\xa5\xae\xf1\x5c\xc6\x48\x4f\x86\xbe\x9f\x7a\xec\xec\x4d\x42\x83\x5b\x00\x73\xa3\x85\xd1\x6a\x8b\x22\xdd\x29\x6e\x44\x6a\x03\x5d\x1e\x6d\x43\xa7\x53\x06\xba\x79\x92\x3b\x65\x76\x99\x93\x74\xdd\x91\xc5\x60\x2c\x05\x99\x84\x7d\x05\xdb\x12\x18\xc1\x74\x60\x4a\x9a\x13\x4d\x0e\x46\x49\x2d\xd8\x48\xbc\xe9\xcd\xd4\x66\x78\x81\x6c\xac\xfd\xbb\xfd\x6f\xd6\x0d\xb7\xd0\x7f\xac\x68\x04\x0a\xf4\x94\x5d\x1e\x24\xd7\xb9\xa2\xed\xed\x72\x1b\x61\xad\xb9\x6d\x0e\xe3\xee\xe8\x85\xff\xf7\xda\x67\x24\xe3\x55\x45\x58\xfe\x1c\x32\x89\x5c\x7a\x2a\xe7\x5f\x35\xd1\xc8\x75\x13\xf5\xae\x9c\x9d\xf4\x44\x4a\xb2\xf2\xf5\x89\x6a\xa8\x22\x4a\x31\xbc\x6d\xe3\x5b\x28\x0d\x42\x7c\xe0\xa5\xa9\x3c\x51\x7a\x25\x94\x86\xd1\x7b\x03\x1f\x37\x58\xb5\x34\xbe\xf6\xbe\x36\x11\x85\xe4\xd5\x3f\x32\x04\x97\xfe\xf9\x7e\x78\x34\x00\x7b\x18\xb9\xe4\xc4\x94\xb3\xfe\x89\x4d\xd6\xc9\xaf\x00\x00\x00\xff\xff\xa6\x34\xa7\xa3\x2a\x14\x00\x00") +var _serviceImporterAssetsSchemaJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x57\x5d\x4f\xdb\x3c\x14\xbe\xcf\xaf\xb0\x0c\x77\xef\x5b\xca\x34\x69\x12\xbd\xdb\xee\x26\x4d\x03\x89\xbb\x41\x36\x99\xe4\xa4\x98\x25\xb6\xf1\x07\x5a\x87\xfa\xdf\xa7\x38\x6d\xea\xc4\x76\x12\xa0\x43\xd3\xba\x5e\xb5\x3e\x3e\x1f\xcf\x73\x8e\x1f\xbb\x8f\x09\x42\xf8\x58\x65\xb7\x50\x11\xbc\x40\xf8\x56\x6b\xb1\x98\xcf\xef\x14\x67\xb3\x66\xf5\x84\xcb\xe5\x3c\x97\xa4\xd0\xb3\xd3\x77\xf3\x66\xed\x08\xff\x5f\xfb\xe9\x95\x80\xda\x89\xdf\xdc\x41\xa6\x9b\x35\x09\xf7\x86\x4a\xc8\xf1\x02\x5d\x25\x08\x21\x84\x19\xa9\x00\x27\x08\xa5\xd6\x4e\xf2\x9c\x6a\xca\x19\x29\x2f\x24\x17\x20\x35\x05\x85\x17\xa8\x20\xa5\x02\xbb\x41\xb8\xcb\x8f\x4e\x88\xed\x2f\x27\xb1\xd2\x92\xb2\xa5\x4d\x6c\xd7\x2b\xca\x3e\x01\x5b\xea\x5b\xbc\x40\x6f\xec\xe2\xba\xb1\x61\x45\xf3\x49\x01\xc8\x8f\x36\xc0\xdb\xb3\x76\x59\x10\xad\x41\xb2\xda\xe3\xeb\xd5\xe9\xec\x8c\xcc\x7e\xbe\x9f\x7d\xb9\xbe\x3e\xf9\x36\x4b\xff\x3b\xc6\x9d\x4c\x39\xa8\x4c\x52\x51\x63\x1c\xc8\xd8\x71\x91\x20\xb8\xa2\x9a\xcb\xd5\x54\x0f\x78\x00\xa6\x95\xbb\x9b\x33\x38\x2f\x5a\xd2\xeb\xcf\xe3\x2e\x04\x33\x65\x89\xb7\xce\xd6\xd6\x7e\x0b\xb7\xb1\xb5\x8d\xb5\xab\xdd\xb8\xa1\xe8\xc2\xef\x5e\xbb\xc5\xa1\xae\xe1\xad\xbf\xa3\x1e\x45\x09\x35\x0a\x7c\x34\xcf\xa1\xa0\xcc\xe6\x56\x73\x0b\x17\x77\xf6\xae\x93\xd0\xf7\xed\xb7\xb4\xc3\x96\x26\xea\xfb\xe1\x90\x55\xa3\x7d\x3e\x57\x39\x08\x60\x39\xb0\xac\x5b\x55\x0c\xf7\x24\xcc\x23\x78\xc7\xb0\x46\x70\xb6\x95\xae\xba\x5d\xf0\x14\xa8\xb5\xd0\x8a\x2c\xc1\xa5\x26\xf5\xc8\x58\x77\xc8\xc8\x38\x2b\xe8\xd2\x48\xd2\x3f\xcd\xa3\x15\x25\xdb\x60\x36\x14\x76\x76\xed\x54\x4d\x10\x49\x2a\xd0\x20\xff\xc6\xd9\x1c\xa8\xe5\x49\xf5\x0c\xb7\x74\x97\xaa\xb7\x9c\x7a\x31\x02\xf7\x4a\xc7\xde\xbb\x63\x82\x60\x5c\x29\x76\x3f\xeb\x7e\xb6\xe8\x3d\xf0\xe2\xb0\x5c\x34\xac\x8d\xc5\xbc\xe1\xbc\x04\xc2\xa6\x05\xdd\x38\x4d\x29\xd2\xf7\xae\xaf\x23\x66\xaa\x60\x6f\xac\xf5\x32\xee\x89\x10\xfe\x6c\xaa\x1b\x90\x31\xeb\x87\x0d\x8c\x88\xf9\xbc\x99\xae\x80\xd1\x1b\x00\xd4\x34\xa5\x20\xa6\xd4\x35\x9e\xcb\x18\xe9\xc9\xd0\xef\xa7\x5e\x3b\x7b\x93\xd0\xe0\x11\xc0\xdc\x68\x61\xb4\xda\xa2\x48\x77\x8a\x1b\x91\xda\xc0\x94\x47\xc7\xd0\x99\x94\x81\x69\x9e\xe4\x4e\x99\x2d\x73\x92\xae\x3b\xb2\x18\x8c\xa5\x20\x93\xb0\xaf\x60\x5b\x02\x23\x98\x0e\x4c\x49\x73\xa2\xc9\xc1\x28\xa9\x05\x1b\x89\x37\x7d\x98\xda\x0c\x2f\x90\x8d\xb5\xff\xb6\xff\xcd\xba\xe1\x36\xfa\x8f\x15\x8d\x40\x83\x9e\x72\xca\x83\xe4\x3a\x4f\xb4\xbd\x3d\x6e\x23\xac\x35\xaf\xcd\x61\xdc\x1d\xbd\xf0\xff\xbd\xf6\x19\xc9\x78\x55\x11\x96\x3f\x87\x4c\x22\x97\x9e\xca\xf9\x4f\x4d\x34\xf2\xdc\x44\xbd\x27\x67\x27\x3d\x91\x92\xac\x7c\x7d\xa2\x1a\xaa\x88\x52\x0c\x1f\xdb\xf8\x11\x4a\x83\x10\x1f\x78\x69\x2a\x4f\x94\x5e\x09\xa5\x61\xf4\xde\xc0\xc7\x0d\x56\x2d\x8d\xaf\xbd\xaf\x4d\x44\x21\x79\xf5\x8f\x0c\xc1\xa5\x7f\xbf\x1f\x1e\x0d\xc0\x1e\x62\xb2\xe1\x57\x3f\x52\x79\xa4\xea\x81\x8a\xa3\x77\x5e\xfd\x0f\x39\x59\x27\xbf\x02\x00\x00\xff\xff\x19\x00\xfb\x06\x87\x14\x00\x00") func serviceImporterAssetsSchemaJsonBytes() ([]byte, error) { return bindataRead( @@ -81,7 +81,7 @@ func serviceImporterAssetsSchemaJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "service/importer/assets/schema.json", size: 5162, mode: os.FileMode(420), modTime: time.Unix(1544626110, 0)} + info := bindataFileInfo{name: "service/importer/assets/schema.json", size: 5255, mode: os.FileMode(420), modTime: time.Unix(1544790675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/service/importer/assets/schema.json b/service/importer/assets/schema.json index 192cd1dd6..7bb0e2b2f 100644 --- a/service/importer/assets/schema.json +++ b/service/importer/assets/schema.json @@ -227,7 +227,11 @@ ] }, "env": { - "type": "object" + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } } } } diff --git a/service/importer/definition.go b/service/importer/definition.go index f4284d620..037af5949 100644 --- a/service/importer/definition.go +++ b/service/importer/definition.go @@ -61,8 +61,8 @@ type Dependency struct { // Args hold the args to pass to the Docker container Args []string `yaml:"args"` - // Env is map of all defiend environments variables. - Env map[string]*Parameter `yaml:"env"` + // Env is a slice of all defiend environments variables in format key=value. + Env []string `yaml:"env"` } // Task describes a service task. diff --git a/service/inject_definition.go b/service/inject_definition.go index d5ed4dcd3..d9f517b2d 100644 --- a/service/inject_definition.go +++ b/service/inject_definition.go @@ -8,7 +8,7 @@ import ( ) // injectDefinition applies service definition to Service type. -func (s *Service) injectDefinition(def *importer.ServiceDefinition, env map[string]string) { +func (s *Service) injectDefinition(def *importer.ServiceDefinition) { s.Name = def.Name s.SID = def.SID s.Description = def.Description @@ -17,11 +17,6 @@ func (s *Service) injectDefinition(def *importer.ServiceDefinition, env map[stri s.Tasks = s.defTasksToService(def.Tasks) s.Dependencies = s.defDependenciesToService(def.Dependencies) - // insert env into dependencies - for _, d := range s.Dependencies { - d.EnvValue = env - } - s.configuration = &Dependency{} if def.Configuration != nil { s.configuration.Command = def.Configuration.Command @@ -29,8 +24,7 @@ func (s *Service) injectDefinition(def *importer.ServiceDefinition, env map[stri s.configuration.Ports = def.Configuration.Ports s.configuration.Volumes = def.Configuration.Volumes s.configuration.VolumesFrom = def.Configuration.VolumesFrom - s.configuration.Env = s.defParametersToService(def.Configuration.Env) - s.configuration.EnvValue = env + s.configuration.Env = def.Configuration.Env } } diff --git a/service/service.go b/service/service.go index e21720136..18f80d100 100644 --- a/service/service.go +++ b/service/service.go @@ -5,11 +5,13 @@ import ( "io" "io/ioutil" "os" + "strings" "time" "github.com/docker/docker/pkg/archive" "github.com/mesg-foundation/core/container" "github.com/mesg-foundation/core/service/importer" + "github.com/mesg-foundation/core/x/xos" "github.com/mesg-foundation/core/x/xstructhash" uuid "github.com/satori/go.uuid" ) @@ -107,12 +109,18 @@ func New(tarball io.Reader, env map[string]string, options ...Option) (*Service, if err != nil { return nil, err } - s.injectDefinition(def, env) - if err := s.validateEnv(); err != nil { + s.injectDefinition(def) + + if err := s.validateConfigurationEnv(env); err != nil { return nil, err } + // if the all keys exists append to configuration env. + // The order of variables allows to safely append new variables + // without removing previous one. The last variable in slice will take precedens. + s.configuration.Env = append(s.configuration.Env, xos.EnvMapToSlice(env)...) + if err := s.deploy(); err != nil { return nil, err } @@ -244,13 +252,20 @@ func (s *Service) getDependency(dependencyKey string) (*Dependency, error) { return nil, fmt.Errorf("dependency %s do not exist", dependencyKey) } -func (s *Service) validateEnv() error { - for _, p := range s.configuration.Env { - if p.Optional { - continue +// validateConfigurationEnv checks if every variable from env map +// has been defiend in mesg.yml in env section. +func (s *Service) validateConfigurationEnv(env map[string]string) error { + for key := range env { + exist := false + // check if "key=" exists in configuration + for _, env := range s.configuration.Env { + if strings.HasPrefix(env, key+"=") { + exist = true + break + } } - if s.configuration.EnvValue[p.Key] == "" { - return fmt.Errorf("service env %s is empty", p.Key) + if !exist { + return fmt.Errorf("service environment variable %q dosen't exist in mesg.yml (under configuration.env key)", key) } } return nil diff --git a/service/service_test.go b/service/service_test.go index b9cb7dfed..eda158847 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -89,7 +89,7 @@ func TestInjectDefinitionWithConfig(t *testing.T) { Configuration: &importer.Dependency{ Command: command, }, - }, nil) + }) require.Equal(t, command, s.configuration.Command) } @@ -104,6 +104,6 @@ func TestInjectDefinitionWithDependency(t *testing.T) { Image: image, }, }, - }, nil) + }) require.Equal(t, s.Dependencies[0].Image, image) } diff --git a/service/start.go b/service/start.go index 872ccd5a2..86afc0d77 100644 --- a/service/start.go +++ b/service/start.go @@ -69,11 +69,11 @@ func (d *Dependency) Start(networkID string) (containerServiceID string, err err Image: d.Image, Args: d.Args, Command: d.Command, - Env: xos.MapToEnv(xos.MergeMapEnvs(map[string]string{ - "MESG_TOKEN": d.service.Hash, - "MESG_ENDPOINT": endpoint, - "MESG_ENDPOINT_TCP": endpoint, - }, d.EnvValue)), + Env: xos.EnvMergeSlices(d.Env, []string{ + "MESG_TOKEN=" + d.service.Hash, + "MESG_ENDPOINT=" + endpoint, + "MESG_ENDPOINT_TCP=" + endpoint, + }), Mounts: append(volumes, volumesFrom...), Ports: d.extractPorts(), Networks: []container.Network{ diff --git a/service/start_test.go b/service/start_test.go index 6ab87a080..b1c4f1ebb 100644 --- a/service/start_test.go +++ b/service/start_test.go @@ -9,7 +9,6 @@ import ( "github.com/mesg-foundation/core/container" "github.com/mesg-foundation/core/container/mocks" "github.com/mesg-foundation/core/x/xnet" - "github.com/mesg-foundation/core/x/xos" "github.com/stretchr/testify/require" ) @@ -319,11 +318,11 @@ func mockStartService(d *Dependency, mc *mocks.Container, Image: d.Image, Command: d.Command, Args: d.Args, - Env: xos.MapToEnv(map[string]string{ - "MESG_TOKEN": d.service.Hash, - "MESG_ENDPOINT": endpoint, - "MESG_ENDPOINT_TCP": endpoint, - }), + Env: []string{ + "MESG_TOKEN=" + d.service.Hash, + "MESG_ENDPOINT=" + endpoint, + "MESG_ENDPOINT_TCP=" + endpoint, + }, Mounts: append(volumes, volumesFrom...), Ports: d.extractPorts(), Networks: []container.Network{ diff --git a/x/xos/env.go b/x/xos/env.go index cd4386e8e..f74b45721 100644 --- a/x/xos/env.go +++ b/x/xos/env.go @@ -1,9 +1,9 @@ package xos import ( - "fmt" "os" "sort" + "strings" ) // GetenvDefault retrieves the value of the environment variable named by the key. @@ -15,25 +15,48 @@ func GetenvDefault(key, fallback string) string { return fallback } -// MapToEnv transform a map of key value to a slice of env in the form "key=value". +// EnvMapToSlice transform a map of key value to a slice of env in the form "key=value". // Env vars are sorted by names to get an accurate order while testing. -func MapToEnv(data map[string]string) []string { - env := make([]string, 0, len(data)) - for key, value := range data { - env = append(env, fmt.Sprintf("%s=%s", key, value)) +func EnvMapToSlice(values map[string]string) []string { + env := make([]string, 0, len(values)) + for k, v := range values { + env = append(env, k+"="+v) } sort.Strings(env) return env } -// MergeMapEnvs merges multiple maps storing environment varialbes into single one. +// EnvSliceToMap transform a slice of key=value to a map. +func EnvSliceToMap(values []string) map[string]string { + env := make(map[string]string, len(values)) + for _, v := range values { + if e := strings.SplitN(v, "=", 2); len(e) == 1 { + env[e[0]] = "" + } else { + env[e[0]] = e[1] + } + } + return env +} + +// EnvMergeMaps merges multiple maps into single one. // If the same key exist multiple time, it will be overwritten by the latest occurrence. -func MergeMapEnvs(envs ...map[string]string) map[string]string { +func EnvMergeMaps(values ...map[string]string) map[string]string { env := make(map[string]string) - for _, e := range envs { + for _, e := range values { for k, v := range e { env[k] = v } } return env } + +// EnvMergeSlices merges multiple slices into single one. +// If the same key exist multiple time, it will be added in occurrence order. +func EnvMergeSlices(values ...[]string) []string { + env := make([]string, 0, 16) + for _, v := range values { + env = append(env, v...) + } + return env +} diff --git a/x/xos/env_test.go b/x/xos/env_test.go index b0490b379..435ea22d6 100644 --- a/x/xos/env_test.go +++ b/x/xos/env_test.go @@ -23,19 +23,29 @@ func TestGetenvDefault(t *testing.T) { } } -func TestMapToEnv(t *testing.T) { - env := MapToEnv(map[string]string{ +func TestEnvMapToSlice(t *testing.T) { + env := EnvMapToSlice(map[string]string{ "a": "1", "b": "2", }) for _, v := range []string{"a=1", "b=2"} { if !xstrings.SliceContains(env, v) { - t.Errorf("envs dosen't contain %s", v) + t.Errorf("env slice dosen't contain %s", v) } } } -func TestMergeMapEnvs(t *testing.T) { - envs := []map[string]string{ + +func TestEnvSliceToMap(t *testing.T) { + env := EnvSliceToMap([]string{"a=1", "b=2"}) + for k, v := range map[string]string{"a": "1", "b": "2"} { + if env[k] != v { + t.Errorf("env map dosen't contain %s=%v", k, v) + } + } +} + +func TestEnvMergeMaps(t *testing.T) { + values := []map[string]string{ { "a": "1", "b": "2", @@ -45,10 +55,22 @@ func TestMergeMapEnvs(t *testing.T) { "c": "3", }, } - env := MergeMapEnvs(envs...) + env := EnvMergeMaps(values...) for k, v := range map[string]string{"a": "2", "b": "2", "c": "3"} { if env[k] != v { - t.Errorf("envs dosen't contain %s=%s", k, v) + t.Errorf("env map dosen't contain %s=%s", k, v) + } + } +} +func TestEnvMergeSlices(t *testing.T) { + values := [][]string{ + {"a=1", "b=2"}, + {"a=2", "c=3"}, + } + env := EnvMergeSlices(values...) + for i, v := range []string{"a=1", "b=2", "a=2", "c=3"} { + if env[i] != v { + t.Errorf("env slice dosen't contain %s", v) } } } From 32ce5159844c57d212d9cb5f3f80991697ce72cc Mon Sep 17 00:00:00 2001 From: krhubert Date: Tue, 18 Dec 2018 15:49:18 +0100 Subject: [PATCH 10/13] Update docs --- service/dependency.go | 2 +- service/importer/definition.go | 2 +- service/service.go | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/service/dependency.go b/service/dependency.go index a53bcbd22..a68c7f715 100644 --- a/service/dependency.go +++ b/service/dependency.go @@ -31,7 +31,7 @@ type Dependency struct { // Argument holds the args to pass to the Docker container Args []string `hash:"name:7"` - // Env is a slice of all key=value. + // Env is a slice of environment variables in key=value format. Env []string `hash:"name:8"` // service is the dependency's service. diff --git a/service/importer/definition.go b/service/importer/definition.go index 037af5949..69d2a1dfb 100644 --- a/service/importer/definition.go +++ b/service/importer/definition.go @@ -61,7 +61,7 @@ type Dependency struct { // Args hold the args to pass to the Docker container Args []string `yaml:"args"` - // Env is a slice of all defiend environments variables in format key=value. + // Env is a slice of environment variables in key=value format. Env []string `yaml:"env"` } diff --git a/service/service.go b/service/service.go index 18f80d100..49bac1533 100644 --- a/service/service.go +++ b/service/service.go @@ -118,7 +118,7 @@ func New(tarball io.Reader, env map[string]string, options ...Option) (*Service, // if the all keys exists append to configuration env. // The order of variables allows to safely append new variables - // without removing previous one. The last variable in slice will take precedens. + // without removing previous one. The last variable in a slice will take the precedence. s.configuration.Env = append(s.configuration.Env, xos.EnvMapToSlice(env)...) if err := s.deploy(); err != nil { @@ -252,8 +252,7 @@ func (s *Service) getDependency(dependencyKey string) (*Dependency, error) { return nil, fmt.Errorf("dependency %s do not exist", dependencyKey) } -// validateConfigurationEnv checks if every variable from env map -// has been defiend in mesg.yml in env section. +// validateConfigurationEnv checks presence of env variables in mesg.yml under env section. func (s *Service) validateConfigurationEnv(env map[string]string) error { for key := range env { exist := false From 1f8fec36c4a993e95f171427315f0130a3fa0b2f Mon Sep 17 00:00:00 2001 From: krhubert Date: Tue, 18 Dec 2018 15:51:40 +0100 Subject: [PATCH 11/13] Change validation of chunk reading --- interface/grpc/core/deploy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/grpc/core/deploy.go b/interface/grpc/core/deploy.go index 7e69bed12..42a7d9981 100644 --- a/interface/grpc/core/deploy.go +++ b/interface/grpc/core/deploy.go @@ -107,11 +107,11 @@ func (r *deployChunkReader) Read(p []byte) (n int, err error) { if err != nil { return 0, err } - if in.GetUrl() != "" { - return 0, errors.New("deploy: got url after tarball stream") + + r.buf, r.i = in.GetChunk(), 0 + if len(r.buf) == 0 { + return 0, errors.New("deploy: got empty chunk of tarball") } - r.buf = in.GetChunk() - r.i = 0 } n = copy(p, r.buf[r.i:]) r.i += n From 23776c46b1eae7b2c51bf88b6099f133a0dff4df Mon Sep 17 00:00:00 2001 From: krhubert Date: Tue, 18 Dec 2018 16:28:38 +0100 Subject: [PATCH 12/13] Replace default env variables in service --- service/service.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/service/service.go b/service/service.go index 49bac1533..7a4354f67 100644 --- a/service/service.go +++ b/service/service.go @@ -116,10 +116,9 @@ func New(tarball io.Reader, env map[string]string, options ...Option) (*Service, return nil, err } - // if the all keys exists append to configuration env. - // The order of variables allows to safely append new variables - // without removing previous one. The last variable in a slice will take the precedence. - s.configuration.Env = append(s.configuration.Env, xos.EnvMapToSlice(env)...) + // replace default env with new one. + defenv := xos.EnvSliceToMap(s.configuration.Env) + s.configuration.Env = xos.EnvMapToSlice(xos.EnvMergeMaps(defenv, env)) if err := s.deploy(); err != nil { return nil, err From c8775575b921c22b09030d7f4d2c3495391dd522 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 20 Dec 2018 12:24:49 +0700 Subject: [PATCH 13/13] Generate doc for core api --- docs/api/core.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api/core.md b/docs/api/core.md index 3b0594aef..d7b22dfbd 100644 --- a/docs/api/core.md +++ b/docs/api/core.md @@ -1465,6 +1465,7 @@ The reply's data of the `ListServices` API. { "services": [{ "id": "idX", + "sid": "sidX", "name": "serviceX", "description": "descriptionX", "status": "statusX", @@ -1686,6 +1687,7 @@ The reply's data of the `GetService` API. { "service": { "id": "idX", + "sid": "sidX", "name": "serviceX", "description": "descriptionX", "status": "statusX",