Skip to content

Commit

Permalink
Merge pull request #1060 from mesg-foundation/fix/instancesdk-env
Browse files Browse the repository at this point in the history
sdk/instancesdk: [fix] pass env vars to service and its dependencies on create
  • Loading branch information
antho1404 authored Jun 20, 2019
2 parents acc3e08 + 3304bf1 commit 3acde18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sdk/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (i *Instance) Create(id string, env []string) (*instance.Instance, error) {
return nil, err
}

// overwrite default env vars with user defined ones.
// calculate the final env vars by overwriting user defined one's with defaults.
instanceEnv := xos.EnvMergeMaps(xos.EnvSliceToMap(srv.Configuration.Env), xos.EnvSliceToMap(env))

// calculate instance's hash.
Expand All @@ -92,7 +92,7 @@ func (i *Instance) Create(id string, env []string) (*instance.Instance, error) {
return nil, err
}

_, err = i.start(o)
_, err = i.start(o, xos.EnvMapToSlice(instanceEnv))
return o, err
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/instance/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// Start starts the service.
func (i *Instance) start(inst *instance.Instance) (serviceIDs []string, err error) {
func (i *Instance) start(inst *instance.Instance, env []string) (serviceIDs []string, err error) {
srv, err := i.serviceDB.Get(inst.ServiceHash)
if err != nil {
return nil, err
Expand Down Expand Up @@ -55,7 +55,7 @@ func (i *Instance) start(inst *instance.Instance) (serviceIDs []string, err erro
Image: d.Image,
Args: d.Args,
Command: d.Command,
Env: xos.EnvMergeSlices(d.Env, []string{
Env: xos.EnvMergeSlices(env, []string{
"MESG_TOKEN=" + inst.Hash,
"MESG_ENDPOINT=" + endpoint,
"MESG_ENDPOINT_TCP=" + endpoint,
Expand Down

0 comments on commit 3acde18

Please sign in to comment.